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 android.os.Build; | |
newt (away)
2016/03/07 18:07:09
One import from each top-level package. Impressive
jbudorick
2016/03/08 00:18:54
yeah, it felt weird writing it.
| |
8 | |
9 import junit.framework.TestCase; | |
10 | |
11 import org.chromium.base.Log; | |
12 | |
13 import java.lang.reflect.Method; | |
14 | |
15 /** | |
16 * Checks the device's SDK level against any specified minimum requirement. | |
17 */ | |
18 public class MinAndroidSdkLevelSkipCheck extends SkipCheck { | |
19 | |
20 private static final String TAG = "base_test"; | |
21 | |
22 /** | |
23 * If {@link MinAndroidSdkLevel} is present, checks its value | |
24 * against the device's SDK level. | |
25 * | |
26 * @param testCase The test to check. | |
27 * @return true if the device's SDK level is below the specified minimum. | |
28 */ | |
29 @Override | |
30 public boolean shouldSkip(TestCase testCase) { | |
31 Class testClass = testCase.getClass(); | |
32 Method testMethod = getTestMethod(testCase); | |
33 | |
34 int minSdkLevel = 0; | |
35 for (MinAndroidSdkLevel m : getAnnotations(testMethod, MinAndroidSdkLeve l.class)) { | |
36 minSdkLevel = Math.max(minSdkLevel, m.value()); | |
37 } | |
38 | |
39 if (Build.VERSION.SDK_INT < minSdkLevel) { | |
40 Log.i(TAG, "Test " + testClass.getName() + "#" + testCase.getName() | |
41 + " is not enabled at SDK level " + Build.VERSION.SDK_INT | |
42 + "."); | |
43 return true; | |
44 } | |
45 return false; | |
46 } | |
47 } | |
OLD | NEW |