зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1290014 - Add additional unit tests. r=ahunt,Grisha
MozReview-Commit-ID: Ib5OI7eb2sq --HG-- extra : rebase_source : 03b754f45a92952533e7fe935a30bc97df678bf7
This commit is contained in:
Родитель
fb80b68a08
Коммит
b05071f783
|
@ -7,6 +7,7 @@ import org.junit.Assert;
|
|||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mozilla.gecko.GeckoAppShell;
|
||||
import org.mozilla.gecko.background.testhelpers.TestRunner;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
|
||||
|
@ -137,4 +138,22 @@ public class TestIconRequestBuilder {
|
|||
|
||||
Assert.assertTrue(request.shouldRunOnBackgroundThread());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testForLauncherIcon() {
|
||||
// This code will call into GeckoAppShell to determine the launcher icon size for this configuration
|
||||
GeckoAppShell.setApplicationContext(RuntimeEnvironment.application);
|
||||
|
||||
IconRequest request = Icons.with(RuntimeEnvironment.application)
|
||||
.pageUrl(TEST_PAGE_URL_1)
|
||||
.build();
|
||||
|
||||
Assert.assertEquals(32, request.getTargetSize());
|
||||
|
||||
request.modify()
|
||||
.forLauncherIcon()
|
||||
.deferBuild();
|
||||
|
||||
Assert.assertEquals(48, request.getTargetSize());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -464,6 +464,45 @@ public class TestIconTask {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoLoadersOrProcessorsAreExecutedForPrepareOnlyTasks() {
|
||||
final List<Preparer> preparers = createListOfPreparers();
|
||||
final List<IconLoader> loaders = createListWithSuccessfulLoader();
|
||||
final List<Processor> processors = createListOfProcessors();
|
||||
final IconLoader generator = createGenerator();
|
||||
|
||||
final IconRequest request = createIconRequest()
|
||||
.modify()
|
||||
.prepareOnly()
|
||||
.build();
|
||||
|
||||
final IconTask task = new IconTask(
|
||||
request,
|
||||
preparers,
|
||||
loaders,
|
||||
processors,
|
||||
generator);
|
||||
|
||||
IconResponse response = task.call();
|
||||
|
||||
Assert.assertNull(response);
|
||||
|
||||
// Verify that all preparers are called
|
||||
for (Preparer preparer : preparers) {
|
||||
verify(preparer).prepare(request);
|
||||
}
|
||||
|
||||
// Verify that no loaders are called
|
||||
for (IconLoader loader : loaders) {
|
||||
verify(loader, never()).load(request);
|
||||
}
|
||||
|
||||
// Verify that no processors are called
|
||||
for (Processor processor : processors) {
|
||||
verify(processor, never()).process(eq(request), any(IconResponse.class));
|
||||
}
|
||||
}
|
||||
|
||||
public List<IconLoader> createListWithSuccessfulLoader() {
|
||||
return Arrays.asList(
|
||||
createFailingLoader(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче