Methods Summary |
---|
protected void | setUp()
super.setUp();
mTestBrowserController = new TestBrowserControllerImpl();
mTestBrowserView = new TestBrowserViewStub();
mTestBrowserController.registerView(mTestBrowserView);
|
public void | testGetIntentForRunAll()
TestSuite testSuite = new DummyTestSuite();
testSuite.addTestSuite(DummyTestCase.class);
mTestBrowserController.setTestSuite(testSuite);
Intent intent = mTestBrowserController.getIntentForTestAt(0);
verifyIntent(intent, DummyTestSuite.class, "com.android.testharness");
|
public void | testGetIntentForTestCase()
TestSuite testSuite = new TestSuite();
testSuite.addTest(new DummyTestCase());
mTestBrowserController.setTestSuite(testSuite);
Intent intent = mTestBrowserController.getIntentForTestAt(1);
verifyIntent(intent, DummyTestCase.class, "com.android.testharness");
assertEquals(TestBrowserControllerImpl.TEST_RUNNER_ACTIVITY_CLASS_NAME,
intent.getComponent().getClassName());
assertEquals("testDummyTest",
intent.getStringExtra(TestBrowserController.BUNDLE_EXTRA_TEST_METHOD_NAME));
|
public void | testGetIntentForTestSuite()
TestSuite testSuite = new TestSuite();
testSuite.addTestSuite(DummyTestCase.class);
String targetBrowserActvityClassName = "com.android.bogus.DummyActivity";
String expectedTargetPackageName = "com.android.bogus";
mTestBrowserController.setTargetBrowserActivityClassName(targetBrowserActvityClassName);
mTestBrowserController.setTestSuite(testSuite);
mTestBrowserController.setTargetPackageName(expectedTargetPackageName);
Intent intent = mTestBrowserController.getIntentForTestAt(1);
verifyIntent(intent, DummyTestCase.class, expectedTargetPackageName);
assertEquals(targetBrowserActvityClassName, intent.getComponent().getClassName());
|
public void | testSetTestSuite()
TestSuite testSuite = new TestSuite();
testSuite.addTestSuite(DummyTestCase.class);
mTestBrowserController.setTestSuite(testSuite);
verifyTestNames(Arrays.asList("Run All", DummyTestCase.class.getSimpleName()),
mTestBrowserView.getTestNames());
|
private static void | verifyIntent(android.content.Intent intent, java.lang.Class testClass, java.lang.String expectedPackageName)
assertEquals(Intent.ACTION_RUN, intent.getAction());
assertEquals(Intent.FLAG_ACTIVITY_NEW_TASK,
intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK);
assertEquals(Intent.FLAG_ACTIVITY_MULTIPLE_TASK,
intent.getFlags() & Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
assertEquals(testClass.getName(), intent.getData().toString());
assertEquals(expectedPackageName, intent.getComponent().getPackageName());
|
private static void | verifyTestNames(java.util.List expectedTestNames, java.util.List actualTestNames)
assertEquals(expectedTestNames.size(), actualTestNames.size());
// We use endsWith instead of equals because the return value of
// class.getSimpleName(), when called on an inner class, varies
// from one vm to another.
// This allows the test to pass in multiple environments.
for (int i = 0; i < expectedTestNames.size(); i++) {
assertTrue(actualTestNames.get(i).endsWith(expectedTestNames.get(i)));
}
|