summaryrefslogtreecommitdiff
path: root/test-runner/src
diff options
context:
space:
mode:
authorPaul Duffin <paulduffin@google.com>2017-06-22 13:29:26 +0100
committerPaul Duffin <paulduffin@google.com>2017-06-22 15:21:32 +0100
commitbd96f408085701fe04fb46acdd3a101cfdebe064 (patch)
tree211204ffbd93dbe997cbde7f1c78409ff902ae4d /test-runner/src
parent2a637cf9b0f2c2ebaf573a1f478e31dc1e6a8354 (diff)
Clean up TestCaseUtil
Part of the work of removing JUnit and dependent android.test classes from the Android API involves providing a static library that developers can include in their test applications to ease migration. That library will be built directly from the source (as opposed to android.jar which is built from stubs) and so developers will be able to see classes and methods that are not present in the stubs. This change is one of a number of similar changes that cleanup the existing non-API code in order to minimize the additional methods and classes exposed externally. The basic approach is to remove unused classes and methods, use least visible access modifier possible and generally minimize the amount of publicly visible code. TestCaseUtil.getTestCaseNames() is only used by tests but its tests did provide some coverage of the getTests() method so remove the method and the tests the method was simply moved into TestCaseUtilTest and the tests renamed to make it clearer that they are testing TestCaseUtil.getTests(). Similarly, TestCaseUtil.createTestSuite() was only used by tests but its tests did provide some coverage of the invokeSuiteMethodIfPossible() method so the tests were modified and renamed to preserve that coverage. TestCaseUtil.getTestAtIndex() was completely unused so was just removed. Bug: 30188076 Test: make checkbuild and ran FrameworkTestRunnerTests Change-Id: I62bbdbab428d7560f0c7df11f313fe60cfd31d13
Diffstat (limited to 'test-runner/src')
-rw-r--r--test-runner/src/android/test/TestCaseUtil.java44
1 files changed, 2 insertions, 42 deletions
diff --git a/test-runner/src/android/test/TestCaseUtil.java b/test-runner/src/android/test/TestCaseUtil.java
index dc053a2359a0..156290997a1b 100644
--- a/test-runner/src/android/test/TestCaseUtil.java
+++ b/test-runner/src/android/test/TestCaseUtil.java
@@ -40,16 +40,6 @@ public class TestCaseUtil {
private TestCaseUtil() {
}
- @SuppressWarnings("unchecked")
- public static List<String> getTestCaseNames(Test test, boolean flatten) {
- List<Test> tests = (List<Test>) getTests(test, flatten);
- List<String> testCaseNames = new ArrayList<>();
- for (Test aTest : tests) {
- testCaseNames.add(getTestName(aTest));
- }
- return testCaseNames;
- }
-
public static List<? extends Test> getTests(Test test, boolean flatten) {
return getTests(test, flatten, new HashSet<Class<?>>());
}
@@ -92,7 +82,7 @@ public class TestCaseUtil {
return testCases;
}
- private static Test invokeSuiteMethodIfPossible(Class testClass,
+ static Test invokeSuiteMethodIfPossible(Class testClass,
Set<Class<?>> seen) {
try {
Method suiteMethod = testClass.getMethod(
@@ -120,7 +110,7 @@ public class TestCaseUtil {
return null;
}
- public static String getTestName(Test test) {
+ static String getTestName(Test test) {
if (test instanceof TestCase) {
TestCase testCase = (TestCase) test;
return testCase.getName();
@@ -138,34 +128,4 @@ public class TestCaseUtil {
}
return "";
}
-
- public static Test getTestAtIndex(TestSuite testSuite, int position) {
- int index = 0;
- Enumeration enumeration = testSuite.tests();
- while (enumeration.hasMoreElements()) {
- Test test = (Test) enumeration.nextElement();
- if (index == position) {
- return test;
- }
- index++;
- }
- return null;
- }
-
- public static TestSuite createTestSuite(Class<? extends Test> testClass)
- throws InstantiationException, IllegalAccessException {
-
- Test test = invokeSuiteMethodIfPossible(testClass,
- new HashSet<Class<?>>());
- if (test == null) {
- return new TestSuite(testClass);
-
- } else if (TestCase.class.isAssignableFrom(test.getClass())) {
- TestSuite testSuite = new TestSuite(test.getClass().getName());
- testSuite.addTest(test);
- return testSuite;
- }
-
- return (TestSuite) test;
- }
}