blob: bb1009b44b3294246b9c1f7ef1989ca92983e173 [file] [log] [blame]
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +00001//
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 {
Aditya Choudhary01b5ede2024-01-31 11:08:57 +000020 default_team: "trendy_team_fwk_core_networking",
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000021 // See: http://go/android-license-faq
Baligh Uddin36847132021-05-23 16:38:40 +000022 default_applicable_licenses: ["Android-Apache-2.0"],
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000023}
24
Lorenzo Colitticc5054b2022-07-22 12:37:17 +090025// The target SDK version of the "latest released SDK" CTS tests.
26// This should be updated soon after a new SDK level is finalized.
27// It is different from the target SDK version of production code (e.g., the Tethering,
28// NetworkStack, and CaptivePortalLogin APKs):
29// - The target SDK of production code influences the behaviour of the production code.
30// - The target SDK of the CTS tests validates the behaviour seen by apps that call production APIs.
31// - The behaviour seen by apps that target previous SDKs is tested by previous CTS versions
32// (currently, CTS 10, 11, and 12).
33java_defaults {
34 name: "ConnectivityTestsLatestSdkDefaults",
Yuyang Huang79a245e2023-05-24 15:28:21 +090035 target_sdk_version: "34",
Lorenzo Colitticc5054b2022-07-22 12:37:17 +090036}
37
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000038java_library {
39 name: "FrameworksNetCommonTests",
Remi NGUYEN VANe55a88d2022-04-20 15:59:16 +090040 defaults: ["framework-connectivity-internal-test-defaults"],
Remi NGUYEN VAN3912c802021-03-16 01:31:07 +000041 srcs: [
42 "java/**/*.java",
43 "java/**/*.kt",
44 ],
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000045 static_libs: [
46 "androidx.core_core",
47 "androidx.test.rules",
48 "junit",
49 "mockito-target-minus-junit4",
50 "modules-utils-build",
51 "net-tests-utils",
52 "net-utils-framework-common",
Taras Antoshchuk30d41e52021-08-02 18:06:35 +020053 "platform-compat-test-rules",
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000054 "platform-test-annotations",
55 ],
56 libs: [
57 "android.test.base.stubs",
58 ],
59}
Remi NGUYEN VAN679a8e02021-05-14 07:24:53 +000060
markchiene59f5e32022-04-02 00:45:53 +080061// Combine Connectivity, NetworkStack and Tethering jarjar rules for coverage target.
62// The jarjar files are simply concatenated in the order specified in srcs.
63// jarjar stops at the first matching rule, so order of concatenation affects the output.
Cole Faust9ff8f4c2024-10-22 16:31:00 -070064java_genrule {
markchiene59f5e32022-04-02 00:45:53 +080065 name: "ConnectivityCoverageJarJarRules",
Remi NGUYEN VANe55a88d2022-04-20 15:59:16 +090066 defaults: ["jarjar-rules-combine-defaults"],
markchiene59f5e32022-04-02 00:45:53 +080067 srcs: [
68 "tethering-jni-jarjar-rules.txt",
Mark53e71c32023-01-13 07:00:25 +000069 ":frameworks-net-tests-jarjar-rules",
markchiene59f5e32022-04-02 00:45:53 +080070 ":TetheringTestsJarJarRules",
71 ":NetworkStackJarJarRules",
72 ],
73 out: ["jarjar-rules-connectivity-coverage.txt"],
markchiene59f5e32022-04-02 00:45:53 +080074 visibility: ["//visibility:private"],
75}
76
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090077android_library {
78 name: "ConnectivityCoverageTestsLib",
79 min_sdk_version: "30",
80 static_libs: [
Remi NGUYEN VAN96267ec2024-10-16 09:56:17 +090081 "ConnectivityUnitTestsLib",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090082 "NetdStaticLibTestsLib",
83 "NetworkStaticLibTestsLib",
markchiene59f5e32022-04-02 00:45:53 +080084 "NetworkStackTestsLib",
85 "TetheringTestsLatestSdkLib",
86 "TetheringIntegrationTestsLatestSdkLib",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090087 ],
markchiene59f5e32022-04-02 00:45:53 +080088 jarjar_rules: ":ConnectivityCoverageJarJarRules",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090089 manifest: "AndroidManifest_coverage.xml",
90 visibility: ["//visibility:private"],
91}
92
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +090093android_test {
94 name: "ConnectivityCoverageTests",
95 // Tethering started on SDK 30
96 min_sdk_version: "30",
Aditya Choudhary01b5ede2024-01-31 11:08:57 +000097 test_suites: [
98 "general-tests",
99 "mts-tethering",
100 ],
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900101 defaults: [
Lorenzo Colitticc5054b2022-07-22 12:37:17 +0900102 "ConnectivityTestsLatestSdkDefaults",
Remi NGUYEN VANe55a88d2022-04-20 15:59:16 +0900103 "framework-connectivity-internal-test-defaults",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900104 "FrameworksNetTests-jni-defaults",
105 "libnetworkstackutilsjni_deps",
106 ],
107 manifest: "AndroidManifest_coverage.xml",
108 test_config: "AndroidTest_Coverage.xml",
109 static_libs: [
110 // Added first so all tests use extended mockito, instead of all tests using regular mockito
111 // (some tests would fail).
112 // TODO: consider removing extended mockito usage in tests that use it, for performance
113 "mockito-target-extended-minus-junit4",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900114 "modules-utils-native-coverage-listener",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +0900115 "ConnectivityCoverageTestsLib",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900116 ],
117 jni_libs: [
118 // For mockito extended
119 "libdexmakerjvmtiagent",
120 "libstaticjvmtiagent",
121 // For NetworkStackUtils included in NetworkStackBase
122 "libnetworkstackutilsjni",
Remi NGUYEN VAN2ba9dbe2022-02-01 23:07:33 +0900123 "libandroid_net_connectivity_com_android_net_module_util_jni",
markchienf967b112021-11-09 16:56:23 +0800124 "libcom_android_networkstack_tethering_util_jni",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900125 // For framework tests
126 "libservice-connectivity",
127 ],
128 libs: [
129 // Although not required to compile the static libs together, the "libs" used to build each
130 // of the common static test libs are necessary for R8 to avoid "Missing class" warnings and
131 // incorrect optimizations
132 "framework-tethering.impl",
133 "framework-wifi.stubs.module_lib",
134 ],
135 compile_multilib: "both",
136}
137
Remi NGUYEN VAN679a8e02021-05-14 07:24:53 +0000138// defaults for tests that need to build against framework-connectivity's @hide APIs
139// Only usable from targets that have visibility on framework-connectivity.impl.
140// Instead of using this, consider avoiding to depend on hidden connectivity APIs in
141// tests.
142java_defaults {
143 name: "framework-connectivity-test-defaults",
144 sdk_version: "core_platform", // tests can use @CorePlatformApi's
145 libs: [
146 // order matters: classes in framework-connectivity are resolved before framework,
147 // meaning @hide APIs in framework-connectivity are resolved before @SystemApi
148 // stubs in framework
149 "framework-connectivity.impl",
paulhu537f7202022-02-08 21:25:28 +0800150 "framework-connectivity-t.impl",
markchien2fbd3e72021-08-17 23:59:09 +0800151 "framework-tethering.impl",
Remi NGUYEN VAN679a8e02021-05-14 07:24:53 +0000152 "framework",
153
154 // if sdk_version="" this gets automatically included, but here we need to add manually.
155 "framework-res",
156 ],
157}
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900158
Remi NGUYEN VAN1a8ee102022-05-30 12:42:24 +0900159// defaults for tests that need to build against framework-connectivity's @hide APIs, but also
160// using fully @hide classes that are jarjared (because they have no API member). Similar to
161// framework-connectivity-test-defaults above but uses pre-jarjar class names.
162// Only usable from targets that have visibility on framework-connectivity-pre-jarjar, and apply
163// connectivity jarjar rules so that references to jarjared classes still match: this is limited to
164// connectivity internal tests only.
165java_defaults {
166 name: "framework-connectivity-internal-test-defaults",
167 sdk_version: "core_platform", // tests can use @CorePlatformApi's
168 libs: [
169 // order matters: classes in framework-connectivity are resolved before framework,
170 // meaning @hide APIs in framework-connectivity are resolved before @SystemApi
171 // stubs in framework
172 "framework-connectivity-pre-jarjar",
173 "framework-connectivity-t-pre-jarjar",
174 "framework-tethering.impl",
175 "framework",
176
177 // if sdk_version="" this gets automatically included, but here we need to add manually.
178 "framework-res",
179 ],
180 defaults_visibility: ["//packages/modules/Connectivity/tests:__subpackages__"],
181}
182
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900183// Defaults for tests that want to run in mainline-presubmit.
184// Not widely used because many of our tests have AndroidTest.xml files and
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900185// use the mainline-param config-descriptor metadata in AndroidTest.xml.
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900186
187// test_mainline_modules is an array of strings. Each element in the array is a list of modules
188// separated by "+". The modules in this list must be in alphabetical order.
189// See SuiteModuleLoader.java.
190// TODO: why are the modules separated by + instead of being separate entries in the array?
191mainline_presubmit_modules = [
Aditya Choudhary01b5ede2024-01-31 11:08:57 +0000192 "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex",
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900193]
194
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900195cc_defaults {
196 name: "connectivity-mainline-presubmit-cc-defaults",
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900197 test_mainline_modules: mainline_presubmit_modules,
198}
199
200java_defaults {
201 name: "connectivity-mainline-presubmit-java-defaults",
202 test_mainline_modules: mainline_presubmit_modules,
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900203}
Ryan Prichard3ae062d2024-05-20 15:34:32 -0700204
205filegroup {
206 name: "connectivity_mainline_test_map",
207 srcs: ["connectivity_mainline_test.map"],
208}