• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package android.net.cts;
18 
19 import static com.android.testutils.DevSdkIgnoreRuleKt.SC_V2;
20 
21 import android.os.Build;
22 
23 import com.android.modules.utils.build.SdkLevel;
24 import com.android.networkstack.apishim.ConstantsShim;
25 
26 /**
27  * Utils class to provide common shared test helper methods or constants that behave differently
28  * depending on the SDK against which they are compiled.
29  */
30 public class TestUtils {
31     /**
32      * Whether to test S+ APIs. This requires a) that the test be running on an S+ device, and
33      * b) that the code be compiled against shims new enough to access these APIs.
34      */
shouldTestSApis()35     public static boolean shouldTestSApis() {
36         return SdkLevel.isAtLeastS() && ConstantsShim.VERSION > Build.VERSION_CODES.R;
37     }
38 
39     /**
40      * Whether to test T+ APIs. This requires a) that the test be running on an S+ device, and
41      * b) that the code be compiled against shims new enough to access these APIs.
42      */
shouldTestTApis()43     public static boolean shouldTestTApis() {
44         // TODO: replace SC_V2 with Build.VERSION_CODES.S_V2 when it's available in mainline branch.
45         return SdkLevel.isAtLeastT() && ConstantsShim.VERSION > SC_V2;
46     }
47 }
48