• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1//
2// Copyright (C) 2019 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// Tests in this folder are included both in unit tests and CTS.
18// They must be fast and stable, and exercise public or test APIs.
19package {
20    // See: http://go/android-license-faq
21    default_applicable_licenses: ["Android-Apache-2.0"],
22}
23
24java_library {
25    name: "FrameworksNetCommonTests",
26    defaults: ["framework-connectivity-test-defaults"],
27    srcs: [
28        "java/**/*.java",
29        "java/**/*.kt",
30    ],
31    static_libs: [
32        "androidx.core_core",
33        "androidx.test.rules",
34        "junit",
35        "mockito-target-minus-junit4",
36        "modules-utils-build",
37        "net-tests-utils",
38        "net-utils-framework-common",
39        "platform-compat-test-rules",
40        "platform-test-annotations",
41    ],
42    libs: [
43        "android.test.base.stubs",
44    ],
45}
46
47// Combine Connectivity, NetworkStack and Tethering jarjar rules for coverage target.
48// The jarjar files are simply concatenated in the order specified in srcs.
49// jarjar stops at the first matching rule, so order of concatenation affects the output.
50genrule {
51    name: "ConnectivityCoverageJarJarRules",
52    srcs: [
53        "tethering-jni-jarjar-rules.txt",
54        ":connectivity-jarjar-rules",
55        ":TetheringTestsJarJarRules",
56        ":NetworkStackJarJarRules",
57    ],
58    out: ["jarjar-rules-connectivity-coverage.txt"],
59    // Concat files with a line break in the middle
60    cmd: "for src in $(in); do cat $${src}; echo; done > $(out)",
61    visibility: ["//visibility:private"],
62}
63
64android_library {
65    name: "ConnectivityCoverageTestsLib",
66    min_sdk_version: "30",
67    static_libs: [
68        "FrameworksNetTestsLib",
69        "NetdStaticLibTestsLib",
70        "NetworkStaticLibTestsLib",
71        "NetworkStackTestsLib",
72        "TetheringTestsLatestSdkLib",
73        "TetheringIntegrationTestsLatestSdkLib",
74    ],
75    jarjar_rules: ":ConnectivityCoverageJarJarRules",
76    manifest: "AndroidManifest_coverage.xml",
77    visibility: ["//visibility:private"],
78}
79
80android_test {
81    name: "ConnectivityCoverageTests",
82    // Tethering started on SDK 30
83    min_sdk_version: "30",
84    target_sdk_version: "31",
85    test_suites: ["general-tests", "mts-tethering"],
86    defaults: [
87        "framework-connectivity-test-defaults",
88        "FrameworksNetTests-jni-defaults",
89        "libnetworkstackutilsjni_deps",
90    ],
91    manifest: "AndroidManifest_coverage.xml",
92    test_config: "AndroidTest_Coverage.xml",
93    static_libs: [
94        // Added first so all tests use extended mockito, instead of all tests using regular mockito
95        // (some tests would fail).
96        // TODO: consider removing extended mockito usage in tests that use it, for performance
97        "mockito-target-extended-minus-junit4",
98        "modules-utils-native-coverage-listener",
99        "ConnectivityCoverageTestsLib",
100    ],
101    jni_libs: [
102        // For mockito extended
103        "libdexmakerjvmtiagent",
104        "libstaticjvmtiagent",
105        // For NetworkStackUtils included in NetworkStackBase
106        "libnetworkstackutilsjni",
107        "libandroid_net_connectivity_com_android_net_module_util_jni",
108        "libcom_android_networkstack_tethering_util_jni",
109        // For framework tests
110        "libservice-connectivity",
111    ],
112    libs: [
113        // Although not required to compile the static libs together, the "libs" used to build each
114        // of the common static test libs are necessary for R8 to avoid "Missing class" warnings and
115        // incorrect optimizations
116        "framework-tethering.impl",
117        "framework-wifi.stubs.module_lib",
118    ],
119    compile_multilib: "both",
120}
121
122// defaults for tests that need to build against framework-connectivity's @hide APIs
123// Only usable from targets that have visibility on framework-connectivity.impl.
124// Instead of using this, consider avoiding to depend on hidden connectivity APIs in
125// tests.
126java_defaults {
127    name: "framework-connectivity-test-defaults",
128    sdk_version: "core_platform", // tests can use @CorePlatformApi's
129    libs: [
130        // order matters: classes in framework-connectivity are resolved before framework,
131        // meaning @hide APIs in framework-connectivity are resolved before @SystemApi
132        // stubs in framework
133        "framework-connectivity.impl",
134        "framework-connectivity-t.impl",
135        "framework-tethering.impl",
136        "framework",
137
138        // if sdk_version="" this gets automatically included, but here we need to add manually.
139        "framework-res",
140    ],
141}
142
143// defaults for tests that need to build against framework-connectivity's @hide APIs, but also
144// using fully @hide classes that are jarjared (because they have no API member). Similar to
145// framework-connectivity-test-defaults above but uses pre-jarjar class names.
146// Only usable from targets that have visibility on framework-connectivity-pre-jarjar, and apply
147// connectivity jarjar rules so that references to jarjared classes still match: this is limited to
148// connectivity internal tests only.
149java_defaults {
150    name: "framework-connectivity-internal-test-defaults",
151    sdk_version: "core_platform", // tests can use @CorePlatformApi's
152    libs: [
153        // order matters: classes in framework-connectivity are resolved before framework,
154        // meaning @hide APIs in framework-connectivity are resolved before @SystemApi
155        // stubs in framework
156        "framework-connectivity-pre-jarjar",
157        "framework-connectivity-t-pre-jarjar",
158        "framework-tethering.impl",
159        "framework",
160
161        // if sdk_version="" this gets automatically included, but here we need to add manually.
162        "framework-res",
163    ],
164    defaults_visibility: ["//packages/modules/Connectivity/tests:__subpackages__"],
165}
166
167// Defaults for tests that want to run in mainline-presubmit.
168// Not widely used because many of our tests have AndroidTest.xml files and
169// use the mainline-param config-descriptor metadata in AndroidTest.xml.
170
171// test_mainline_modules is an array of strings. Each element in the array is a list of modules
172// separated by "+". The modules in this list must be in alphabetical order.
173// See SuiteModuleLoader.java.
174// TODO: why are the modules separated by + instead of being separate entries in the array?
175mainline_presubmit_modules = [
176        "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex",
177]
178
179cc_defaults {
180    name: "connectivity-mainline-presubmit-cc-defaults",
181    test_mainline_modules: mainline_presubmit_modules,
182}
183
184java_defaults {
185    name: "connectivity-mainline-presubmit-java-defaults",
186    test_mainline_modules: mainline_presubmit_modules,
187}
188