OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.base.test.util; |
| 6 |
| 7 import junit.framework.TestCase; |
| 8 |
| 9 import org.chromium.testing.local.LocalRobolectricTestRunner; |
| 10 import org.junit.Assert; |
| 11 import org.junit.Test; |
| 12 import org.junit.runner.RunWith; |
| 13 import org.robolectric.annotation.Config; |
| 14 |
| 15 /** Unit tests for MinAndroidSdkLevelSkipCheck. */ |
| 16 @RunWith(LocalRobolectricTestRunner.class) |
| 17 @Config(manifest = Config.NONE, reportSdk = 19) |
| 18 public class MinAndroidSdkLevelSkipCheckTest { |
| 19 |
| 20 private static class UnannotatedBaseClass extends TestCase { |
| 21 public UnannotatedBaseClass(String name) { |
| 22 super(name); |
| 23 } |
| 24 @MinAndroidSdkLevel(18) public void min18Method() {} |
| 25 @MinAndroidSdkLevel(20) public void min20Method() {} |
| 26 } |
| 27 |
| 28 @MinAndroidSdkLevel(18) |
| 29 private static class Min18Class extends UnannotatedBaseClass { |
| 30 public Min18Class(String name) { |
| 31 super(name); |
| 32 } |
| 33 public void unannotatedMethod() {} |
| 34 } |
| 35 |
| 36 @MinAndroidSdkLevel(20) |
| 37 private static class Min20Class extends UnannotatedBaseClass { |
| 38 public Min20Class(String name) { |
| 39 super(name); |
| 40 } |
| 41 public void unannotatedMethod() {} |
| 42 } |
| 43 |
| 44 private static class ExtendsMin18Class extends Min18Class { |
| 45 public ExtendsMin18Class(String name) { |
| 46 super(name); |
| 47 } |
| 48 public void unannotatedMethod() {} |
| 49 } |
| 50 |
| 51 private static class ExtendsMin20Class extends Min20Class { |
| 52 public ExtendsMin20Class(String name) { |
| 53 super(name); |
| 54 } |
| 55 public void unannotatedMethod() {} |
| 56 } |
| 57 |
| 58 @Test |
| 59 public void testAnnotatedMethodAboveMin() { |
| 60 Assert.assertFalse(new MinAndroidSdkLevelSkipCheck().shouldSkip( |
| 61 new UnannotatedBaseClass("min18Method"))); |
| 62 } |
| 63 |
| 64 @Test |
| 65 public void testAnnotatedMethodBelowMin() { |
| 66 Assert.assertTrue(new MinAndroidSdkLevelSkipCheck().shouldSkip( |
| 67 new UnannotatedBaseClass("min20Method"))); |
| 68 } |
| 69 |
| 70 @Test |
| 71 public void testAnnotatedClassAboveMin() { |
| 72 Assert.assertFalse(new MinAndroidSdkLevelSkipCheck().shouldSkip( |
| 73 new Min18Class("unannotatedMethod"))); |
| 74 } |
| 75 |
| 76 @Test |
| 77 public void testAnnotatedClassBelowMin() { |
| 78 Assert.assertTrue(new MinAndroidSdkLevelSkipCheck().shouldSkip( |
| 79 new Min20Class("unannotatedMethod"))); |
| 80 } |
| 81 |
| 82 @Test |
| 83 public void testAnnotatedSuperclassAboveMin() { |
| 84 Assert.assertFalse(new MinAndroidSdkLevelSkipCheck().shouldSkip( |
| 85 new ExtendsMin18Class("unannotatedMethod"))); |
| 86 } |
| 87 |
| 88 @Test |
| 89 public void testAnnotatedSuperclassBelowMin() { |
| 90 Assert.assertTrue(new MinAndroidSdkLevelSkipCheck().shouldSkip( |
| 91 new ExtendsMin20Class("unannotatedMethod"))); |
| 92 } |
| 93 } |
OLD | NEW |