SimpleChromeCustomTabsAvailableAppProvider implements AvailableAppProvider { @Override @WorkerThread public void findBestPackage(@NonNull PackageFoundCallback packageFoundCallback, Context context) { Runnable findBestPackageTask = findBestPackageTask(packageFoundCallback, context); executor.execute(findBestPackageTask); } SimpleChromeCustomTabsAvailableAppProvider(BestPackageFinder bestPackageFinder, Executor executor); @Override @WorkerThread void findBestPackage(@NonNull PackageFoundCallback packageFoundCallback, Context context);  }
@Test public void findBestPackageDelegatesToPackageFinder() { simpleChromeCustomTabsAvailableAppProvider.findBestPackage(mockPackageFoundCallback, mockActivity); verify(mockBestPackageFinder).findBestPackage(mockActivity); }
@Test public void packageIsFoundIfNotNullOrEmpty() { givenThatPackageNameIsNotNullOrEmpty(); simpleChromeCustomTabsAvailableAppProvider.findBestPackage(mockPackageFoundCallback, mockActivity); verify(mockPackageFoundCallback).onPackageFound(NON_EMPTY_PACKAGE); }
@Test public void packageIsNotFoundIfNull() { givenThatPackageIsNull(); simpleChromeCustomTabsAvailableAppProvider.findBestPackage(mockPackageFoundCallback, mockActivity); verify(mockPackageFoundCallback).onPackageNotFound(); }
@Test public void packageNotFoundIfEmpty() { givenThatPackageIsEmpty(); simpleChromeCustomTabsAvailableAppProvider.findBestPackage(mockPackageFoundCallback, mockActivity); verify(mockPackageFoundCallback).onPackageNotFound(); }
@Test public void ifPackageIsFoundThenPackageNotFoundWillNotBeCalled() { givenThatPackageIsFound(); simpleChromeCustomTabsAvailableAppProvider.findBestPackage(mockPackageFoundCallback, mockActivity); verify(mockPackageFoundCallback, never()).onPackageNotFound(); }
@Test public void ifPackageIsNotFoundThenPackageFoundWillNotBeCalled() { givenThatPackageIsNotFound(); simpleChromeCustomTabsAvailableAppProvider.findBestPackage(mockPackageFoundCallback, mockActivity); verify(mockPackageFoundCallback, never()).onPackageFound(anyString()); }