summaryrefslogtreecommitdiffstats
path: root/test-runner/tests
diff options
context:
space:
mode:
authorBrett Chabot <brettchabot@android.com>2011-06-01 18:38:44 -0700
committerBrett Chabot <brettchabot@android.com>2011-06-01 20:03:39 -0700
commit877d428e39200fc5f289bfc88d67069cf7b9662a (patch)
tree222cfa3b427254bf8cd0159c0669fb85a89b8afe /test-runner/tests
parent287bd83f9ea257594e0d483d3851236139e5744e (diff)
downloadframeworks_base-877d428e39200fc5f289bfc88d67069cf7b9662a.zip
frameworks_base-877d428e39200fc5f289bfc88d67069cf7b9662a.tar.gz
frameworks_base-877d428e39200fc5f289bfc88d67069cf7b9662a.tar.bz2
Test runner cleanup: delete unused old classes.
Change-Id: Iaaabd47d4074f936a811fc1b6575088d70842564
Diffstat (limited to 'test-runner/tests')
-rw-r--r--test-runner/tests/src/android/test/StubTestBrowserActivity.java33
-rw-r--r--test-runner/tests/src/android/test/TestBrowserActivityTest.java275
-rw-r--r--test-runner/tests/src/android/test/TestBrowserControllerImplTest.java134
-rw-r--r--test-runner/tests/src/android/test/TestBrowserTests.java22
4 files changed, 0 insertions, 464 deletions
diff --git a/test-runner/tests/src/android/test/StubTestBrowserActivity.java b/test-runner/tests/src/android/test/StubTestBrowserActivity.java
deleted file mode 100644
index 97ed3ce..0000000
--- a/test-runner/tests/src/android/test/StubTestBrowserActivity.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.test;
-
-import junit.framework.TestSuite;
-
-public class StubTestBrowserActivity extends TestBrowserActivity {
-
- private static TestSuite mTestSuite;
-
- static void setTopTestSuite(TestSuite testSuite) {
- mTestSuite = testSuite;
- }
-
- @Override
- public TestSuite getTopTestSuite() {
- return mTestSuite;
- }
-}
diff --git a/test-runner/tests/src/android/test/TestBrowserActivityTest.java b/test-runner/tests/src/android/test/TestBrowserActivityTest.java
deleted file mode 100644
index 355409e..0000000
--- a/test-runner/tests/src/android/test/TestBrowserActivityTest.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.test;
-
-import android.app.Activity;
-import android.app.Instrumentation;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.view.IWindowManager;
-import android.widget.ListView;
-
-import com.google.android.collect.Lists;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.util.List;
-
-public class TestBrowserActivityTest extends InstrumentationTestCase {
-
- private TestBrowserActivity mTestBrowserActivity;
- private StubTestBrowserController mTestBrowserController;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- StubTestBrowserActivity.setTopTestSuite(null);
- mTestBrowserController = new StubTestBrowserController();
- ServiceLocator.setTestBrowserController(mTestBrowserController);
- }
-
- @Override
- protected void tearDown() throws Exception {
- if (mTestBrowserActivity != null) {
- mTestBrowserActivity.finish();
- }
- mTestBrowserActivity = null;
- super.tearDown();
- }
-
- public void testEmptyListContent() throws Exception {
- 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 testOneListContent() throws Exception {
- List<String> testCaseNames = Lists.newArrayList("AllTests");
- StubTestBrowserActivity.setTopTestSuite(createTestSuite(testCaseNames));
-
- mTestBrowserActivity = createActivity();
-
- ListView listView = getListView();
- assertListViewContents(testCaseNames, listView);
- }
-
- public void testListWithTestCases() throws Exception {
- List<String> testCaseNames = Lists.newArrayList("AllTests", "Apples", "Bananas", "Oranges");
- StubTestBrowserActivity.setTopTestSuite(createTestSuite(testCaseNames));
-
- mTestBrowserActivity = createActivity();
-
- ListView listView = getListView();
- assertListViewContents(testCaseNames, listView);
- }
-
- public void testListWithTestSuite() throws Exception {
- List<String> testCaseNames = Lists.newArrayList(OneTestTestCase.class.getSimpleName());
- StubTestBrowserActivity.setTopTestSuite(new OneTestInTestSuite());
-
- mTestBrowserActivity = createActivity();
-
- ListView listView = getListView();
- assertListViewContents(testCaseNames, listView);
- }
-
- public void testSelectATestCase() throws Exception {
- 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 testCreateFromIntentWithOneTest() throws Exception {
- List<String> testCaseNames = Lists.newArrayList("testOne");
-
- mTestBrowserActivity = launchTestBrowserActivity(new TestSuite(OneTestTestCase.class));
-
- ListView listView = getListView();
- assertListViewContents(testCaseNames, listView);
- }
-
- public void testUpdateListOnStart() throws Exception {
- 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);
- }
-
- public void testTitleHasTestSuiteName() throws Exception {
- final String testSuiteName = "com.android.TestSuite";
- StubTestBrowserActivity.setTopTestSuite(new TestSuite(testSuiteName));
-
- mTestBrowserActivity = createActivity();
-
- assertEquals("TestSuite", mTestBrowserActivity.getTitle().toString());
- }
-
- private TestSuite createTestSuite(List<String> testCaseNames) {
- return createTestSuite(testCaseNames.toArray(new String[testCaseNames.size()]));
- }
-
- private TestSuite createTestSuite(String... testCaseNames) {
- TestSuite testSuite = new TestSuite();
- for (String testCaseName : testCaseNames) {
- testSuite.addTest(new FakeTestCase(testCaseName));
- }
-
- return testSuite;
- }
-
- public static class FakeTestCase extends TestCase {
- public FakeTestCase(String name) {
- super(name);
- }
- }
-
- public static class OneTestTestCase extends TestCase {
- public void testOne() throws Exception {
- }
- }
-
- public static class OneTestInTestSuite extends TestSuite {
- public static Test suite() {
- TestSuite suite = new TestSuite(OneTestInTestSuite.class.getName());
- suite.addTestSuite(OneTestTestCase.class);
- return suite;
- }
- }
-
- private void assertListViewContents(List<String> expectedTestCaseNames, 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 ListView getListView() {
- return mTestBrowserActivity.getListView();
- }
-
- private TestBrowserActivity createActivity() throws RemoteException {
- return launchActivity(getAndroidPackageName(), StubTestBrowserActivity.class, null);
- }
-
- private Intent createIntent(TestSuite testSuite) {
- Intent intent = new Intent(Intent.ACTION_RUN);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- String className = StubTestBrowserActivity.class.getName();
- String packageName = getAndroidPackageName();
- intent.setClassName(packageName, className);
- intent.setData(Uri.parse(testSuite.getName()));
- return intent;
- }
-
- private String getAndroidPackageName() {
- String packageName = getInstrumentation().getTargetContext().getPackageName();
- return packageName;
- }
-
- private TestBrowserActivity launchTestBrowserActivity(TestSuite testSuite)
- throws RemoteException {
- getInstrumentation().setInTouchMode(false);
-
- TestBrowserActivity activity =
- (TestBrowserActivity) getInstrumentation().startActivitySync(
- createIntent(testSuite));
- getInstrumentation().waitForIdleSync();
- return activity;
- }
-
- private static class StubTestBrowserController extends TestBrowserControllerImpl {
- private int mPosition;
- private Class<? extends TestCase> mTestCaseClass;
-
- public Intent getIntentForTestAt(int position) {
- mPosition = position;
-
- Intent intent = new Intent();
- intent.setAction(Intent.ACTION_RUN);
-
- String className = TestBrowserControllerImpl.TEST_RUNNER_ACTIVITY_CLASS_NAME;
- String testName = mTestCaseClass.getClass().getName();
-
- String packageName = className.substring(0, className.lastIndexOf("."));
- intent.setClassName(packageName, className);
- intent.setData(Uri.parse(testName));
-
- return intent;
- }
-
- public void setTestCase(Class<? extends TestCase> testCaseClass) {
- mTestCaseClass = testCaseClass;
- }
-
- public int getLastPosition() {
- return mPosition;
- }
- }
-}
diff --git a/test-runner/tests/src/android/test/TestBrowserControllerImplTest.java b/test-runner/tests/src/android/test/TestBrowserControllerImplTest.java
deleted file mode 100644
index 1315606..0000000
--- a/test-runner/tests/src/android/test/TestBrowserControllerImplTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.test;
-
-import android.content.Intent;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class TestBrowserControllerImplTest extends TestCase {
- private TestBrowserControllerImpl mTestBrowserController;
- private TestBrowserViewStub mTestBrowserView;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mTestBrowserController = new TestBrowserControllerImpl();
- mTestBrowserView = new TestBrowserViewStub();
- mTestBrowserController.registerView(mTestBrowserView);
- }
-
- public void testSetTestSuite() throws Exception {
- TestSuite testSuite = new TestSuite();
- testSuite.addTestSuite(DummyTestCase.class);
-
- mTestBrowserController.setTestSuite(testSuite);
-
- verifyTestNames(Arrays.asList("Run All", DummyTestCase.class.getSimpleName()),
- mTestBrowserView.getTestNames());
- }
-
- private static void verifyTestNames(List<String> expectedTestNames,
- List<String> 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)));
- }
- }
-
- public void testGetIntentForTestSuite() throws Exception {
- 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 testGetIntentForTestCase() throws Exception {
- 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 testGetIntentForRunAll() throws Exception {
- TestSuite testSuite = new DummyTestSuite();
- testSuite.addTestSuite(DummyTestCase.class);
-
- mTestBrowserController.setTestSuite(testSuite);
- Intent intent = mTestBrowserController.getIntentForTestAt(0);
- verifyIntent(intent, DummyTestSuite.class, "com.android.testharness");
- }
-
- private static void verifyIntent(Intent intent, Class testClass, 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 class DummyTestSuite extends TestSuite {
- private DummyTestSuite() {
- super(DummyTestSuite.class.getName());
- }
- }
-
- private static class DummyTestCase extends TestCase {
- private DummyTestCase() {
- super("testDummyTest");
- }
-
- public void testDummyTest() throws Exception {
- }
- }
-
- private class TestBrowserViewStub implements TestBrowserView {
- private List<String> mTestNames;
-
- public void setTestNames(List<String> testNames) {
- mTestNames = testNames;
- }
-
- public List<String> getTestNames() {
- return mTestNames;
- }
- }
-}
diff --git a/test-runner/tests/src/android/test/TestBrowserTests.java b/test-runner/tests/src/android/test/TestBrowserTests.java
deleted file mode 100644
index 535e2f8..0000000
--- a/test-runner/tests/src/android/test/TestBrowserTests.java
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2007 The Android Open Source Project
-
-
-package android.test;
-
-import junit.framework.TestSuite;
-
-public class TestBrowserTests extends TestBrowserActivity {
-
- @Override
- public TestSuite getTopTestSuite() {
- return suite();
- }
-
- public static TestSuite suite() {
- TestSuite testSuite = new TestSuite(TestBrowserTests.class.getName());
- testSuite.addTestSuite(TestBrowserControllerImplTest.class);
- testSuite.addTestSuite(TestCaseUtilTest.class);
-
- return testSuite;
- }
-}