Chromium Code Reviews| Index: base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java |
| diff --git a/base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java b/base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java |
| index efca73402ebd05f289498f397dbf05c6a0eb70e6..613594920e0dda054dc0e830f14f0214fe73022f 100644 |
| --- a/base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java |
| +++ b/base/test/android/junit/src/org/chromium/base/test/util/SkipCheckTest.java |
| @@ -4,12 +4,15 @@ |
| package org.chromium.base.test.util; |
| +import android.text.TextUtils; |
| + |
| import junit.framework.TestCase; |
| import org.chromium.testing.local.LocalRobolectricTestRunner; |
| import org.junit.Assert; |
| import org.junit.Test; |
| import org.junit.runner.RunWith; |
| +import org.junit.runners.model.FrameworkMethod; |
| import org.robolectric.annotation.Config; |
| import java.lang.annotation.Annotation; |
| @@ -30,8 +33,12 @@ public class SkipCheckTest { |
| return getAnnotations(element, annotationClass); |
| } |
| + public static FrameworkMethod getTestFrameworkMethodForTesting(TestCase testCase) { |
| + return getTestFrameworkMethod(testCase); |
| + } |
| + |
| @Override |
| - public boolean shouldSkip(TestCase t) { |
| + public boolean shouldSkip(FrameworkMethod m) { |
| return false; |
| } |
| } |
| @@ -39,6 +46,13 @@ public class SkipCheckTest { |
| @Retention(RetentionPolicy.RUNTIME) |
| private @interface TestAnnotation {} |
| + private class ExtendsTestCaseClass extends TestCase { |
|
jbudorick
2016/09/15 22:52:29
nit: drop this below ExtendsAnnotatedBaseClass
the real yoland
2016/09/20 21:26:43
Done.
|
| + public ExtendsTestCaseClass(String name) { |
| + super(name); |
| + } |
| + public void testMethodA() {} |
| + } |
| + |
| private class UnannotatedBaseClass { |
| public void unannotatedMethod() {} |
| @TestAnnotation public void annotatedMethod() {} |
| @@ -120,4 +134,20 @@ public class SkipCheckTest { |
| Assert.assertEquals(2, annotations.size()); |
| } |
| + @Test |
| + public void getExistingTestFrameworkMethod() { |
| + String testMethodName = "testMethodA"; |
| + ExtendsTestCaseClass testCase = new ExtendsTestCaseClass(testMethodName); |
| + FrameworkMethod method = TestableSkipCheck.getTestFrameworkMethodForTesting(testCase); |
| + Assert.assertNotNull(method); |
| + Assert.assertTrue(TextUtils.equals(testMethodName, method.getName())); |
| + } |
| + |
| + @Test |
| + public void getNoneTestFrameworkMethod() { |
| + String testMethodName = "noSuchTestMethod"; |
| + ExtendsTestCaseClass testCase = new ExtendsTestCaseClass(testMethodName); |
| + FrameworkMethod method = TestableSkipCheck.getTestFrameworkMethodForTesting(testCase); |
| + Assert.assertNull(method); |
| + } |
| } |