Methods Summary |
---|
private void | assertListViewContents(java.util.List expectedTestCaseNames, android.widget.ListView listView)
assertEquals("Run All", listView.getItemAtPosition(0).toString());
assertEquals("Unexpected number of items on list view.",
expectedTestCaseNames.size() + 1, listView.getCount());
for (int i = 0; i < expectedTestCaseNames.size(); i++) {
String expectedTestCaseName = expectedTestCaseNames.get(i);
String actualTestCaseName = listView.getItemAtPosition(i + 1).toString();
assertEquals("Unexpected test case name. Index: " + i,
expectedTestCaseName, actualTestCaseName);
}
|
private TestBrowserActivity | createActivity()
return launchActivity("android.test", StubTestBrowserActivity.class, null);
|
private android.content.Intent | createIntent(junit.framework.TestSuite testSuite)
Intent intent = new Intent(Intent.ACTION_RUN);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
String className = StubTestBrowserActivity.class.getName();
String packageName = className.substring(0, className.lastIndexOf("."));
intent.setClassName(packageName, className);
intent.setData(Uri.parse(testSuite.getName()));
return intent;
|
private junit.framework.TestSuite | createTestSuite(java.util.List testCaseNames)
return createTestSuite(testCaseNames.toArray(new String[testCaseNames.size()]));
|
private junit.framework.TestSuite | createTestSuite(java.lang.String testCaseNames)
TestSuite testSuite = new TestSuite();
for (String testCaseName : testCaseNames) {
testSuite.addTest(new FakeTestCase(testCaseName));
}
return testSuite;
|
private android.widget.ListView | getListView()
return mTestBrowserActivity.getListView();
|
private TestBrowserActivity | launchTestBrowserActivity(junit.framework.TestSuite testSuite)
getInstrumentation().setInTouchMode(false);
TestBrowserActivity activity =
(TestBrowserActivity) getInstrumentation().startActivitySync(
createIntent(testSuite));
getInstrumentation().waitForIdleSync();
return activity;
|
protected void | setUp()
super.setUp();
StubTestBrowserActivity.setTopTestSuite(null);
mTestBrowserController = new StubTestBrowserController();
ServiceLocator.setTestBrowserController(mTestBrowserController);
|
protected void | tearDown()
if (mTestBrowserActivity != null) {
mTestBrowserActivity.finish();
}
mTestBrowserActivity = null;
super.tearDown();
|
public void | testCreateFromIntentWithOneTest()
List<String> testCaseNames = Lists.newArrayList("testOne");
mTestBrowserActivity = launchTestBrowserActivity(new TestSuite(OneTestTestCase.class));
ListView listView = getListView();
assertListViewContents(testCaseNames, listView);
|
public void | testEmptyListContent()
StubTestBrowserActivity.setTopTestSuite(new TestSuite());
mTestBrowserActivity = createActivity();
ListView listView = getListView();
// There is always an item on the list for running all tests.
assertEquals("Unexpected number of items on list view.", 1, listView.getCount());
assertEquals("Stubbed Test Browser", mTestBrowserActivity.getTitle().toString());
|
public void | testListWithTestCases()
List<String> testCaseNames = Lists.newArrayList("AllTests", "Apples", "Bananas", "Oranges");
StubTestBrowserActivity.setTopTestSuite(createTestSuite(testCaseNames));
mTestBrowserActivity = createActivity();
ListView listView = getListView();
assertListViewContents(testCaseNames, listView);
|
public void | testListWithTestSuite()
List<String> testCaseNames = Lists.newArrayList(OneTestTestCase.class.getSimpleName());
StubTestBrowserActivity.setTopTestSuite(new OneTestInTestSuite());
mTestBrowserActivity = createActivity();
ListView listView = getListView();
assertListViewContents(testCaseNames, listView);
|
public void | testOneListContent()
List<String> testCaseNames = Lists.newArrayList("AllTests");
StubTestBrowserActivity.setTopTestSuite(createTestSuite(testCaseNames));
mTestBrowserActivity = createActivity();
ListView listView = getListView();
assertListViewContents(testCaseNames, listView);
|
public void | testSelectATestCase()
List<String> testCaseNames = Lists.newArrayList("AllTests");
TestSuite testSuite = createTestSuite(testCaseNames);
StubTestBrowserActivity.setTopTestSuite(testSuite);
mTestBrowserController.setTestCase(OneTestTestCase.class);
mTestBrowserActivity = createActivity();
Instrumentation.ActivityMonitor activityMonitor = getInstrumentation().addMonitor(
TestBrowserControllerImpl.TEST_RUNNER_ACTIVITY_CLASS_NAME, null, false);
try {
assertEquals(0, activityMonitor.getHits());
ListView listView = getListView();
int invokedTestCaseIndex = 0;
listView.performItemClick(listView, invokedTestCaseIndex, 0);
Activity activity = activityMonitor.waitForActivityWithTimeout(2000);
assertNotNull(activity);
try {
assertEquals(1, activityMonitor.getHits());
assertEquals(invokedTestCaseIndex, mTestBrowserController.getLastPosition());
} finally {
activity.finish();
}
} finally {
getInstrumentation().removeMonitor(activityMonitor);
}
|
public void | testTitleHasTestSuiteName()
final String testSuiteName = "com.android.TestSuite";
StubTestBrowserActivity.setTopTestSuite(new TestSuite(testSuiteName));
mTestBrowserActivity = createActivity();
assertEquals("TestSuite", mTestBrowserActivity.getTitle().toString());
|
public void | testUpdateListOnStart()
StubTestBrowserActivity.setTopTestSuite(new TestSuite());
mTestBrowserActivity = createActivity();
ListView listView = getListView();
assertEquals("Unexpected number of items on list view.", 1, listView.getCount());
List<String> testCaseNames = Lists.newArrayList("AllTests");
StubTestBrowserActivity.setTopTestSuite(createTestSuite(testCaseNames));
getInstrumentation().runOnMainSync(new Runnable() {
public void run() {
((StubTestBrowserActivity) mTestBrowserActivity).onStart();
}
});
listView = getListView();
assertListViewContents(testCaseNames, listView);
|