blob: 8e4723513fedad5287ac1c8c4a3c03b6f121b6fd [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 {
20 // See: http://go/android-license-faq
Baligh Uddin36847132021-05-23 16:38:40 +000021 default_applicable_licenses: ["Android-Apache-2.0"],
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000022}
23
Lorenzo Colitticc5054b2022-07-22 12:37:17 +090024// The target SDK version of the "latest released SDK" CTS tests.
25// This should be updated soon after a new SDK level is finalized.
26// It is different from the target SDK version of production code (e.g., the Tethering,
27// NetworkStack, and CaptivePortalLogin APKs):
28// - The target SDK of production code influences the behaviour of the production code.
29// - The target SDK of the CTS tests validates the behaviour seen by apps that call production APIs.
30// - The behaviour seen by apps that target previous SDKs is tested by previous CTS versions
31// (currently, CTS 10, 11, and 12).
32java_defaults {
33 name: "ConnectivityTestsLatestSdkDefaults",
34 target_sdk_version: "33",
35}
36
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000037java_library {
38 name: "FrameworksNetCommonTests",
Remi NGUYEN VANe55a88d2022-04-20 15:59:16 +090039 defaults: ["framework-connectivity-internal-test-defaults"],
Remi NGUYEN VAN3912c802021-03-16 01:31:07 +000040 srcs: [
41 "java/**/*.java",
42 "java/**/*.kt",
43 ],
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000044 static_libs: [
45 "androidx.core_core",
46 "androidx.test.rules",
47 "junit",
48 "mockito-target-minus-junit4",
49 "modules-utils-build",
50 "net-tests-utils",
51 "net-utils-framework-common",
Taras Antoshchuk30d41e52021-08-02 18:06:35 +020052 "platform-compat-test-rules",
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000053 "platform-test-annotations",
54 ],
55 libs: [
56 "android.test.base.stubs",
57 ],
58}
Remi NGUYEN VAN679a8e02021-05-14 07:24:53 +000059
markchiene59f5e32022-04-02 00:45:53 +080060// Combine Connectivity, NetworkStack and Tethering jarjar rules for coverage target.
61// The jarjar files are simply concatenated in the order specified in srcs.
62// jarjar stops at the first matching rule, so order of concatenation affects the output.
63genrule {
64 name: "ConnectivityCoverageJarJarRules",
Remi NGUYEN VANe55a88d2022-04-20 15:59:16 +090065 defaults: ["jarjar-rules-combine-defaults"],
markchiene59f5e32022-04-02 00:45:53 +080066 srcs: [
67 "tethering-jni-jarjar-rules.txt",
Mark53e71c32023-01-13 07:00:25 +000068 ":frameworks-net-tests-jarjar-rules",
markchiene59f5e32022-04-02 00:45:53 +080069 ":TetheringTestsJarJarRules",
70 ":NetworkStackJarJarRules",
71 ],
72 out: ["jarjar-rules-connectivity-coverage.txt"],
markchiene59f5e32022-04-02 00:45:53 +080073 visibility: ["//visibility:private"],
74}
75
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090076android_library {
77 name: "ConnectivityCoverageTestsLib",
78 min_sdk_version: "30",
79 static_libs: [
80 "FrameworksNetTestsLib",
81 "NetdStaticLibTestsLib",
82 "NetworkStaticLibTestsLib",
markchiene59f5e32022-04-02 00:45:53 +080083 "NetworkStackTestsLib",
84 "TetheringTestsLatestSdkLib",
85 "TetheringIntegrationTestsLatestSdkLib",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090086 ],
markchiene59f5e32022-04-02 00:45:53 +080087 jarjar_rules: ":ConnectivityCoverageJarJarRules",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090088 manifest: "AndroidManifest_coverage.xml",
89 visibility: ["//visibility:private"],
90}
91
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +090092android_test {
93 name: "ConnectivityCoverageTests",
94 // Tethering started on SDK 30
95 min_sdk_version: "30",
Kimberly Kreiderc5b3f342021-10-20 18:16:59 +000096 test_suites: ["general-tests", "mts-tethering"],
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +090097 defaults: [
Lorenzo Colitticc5054b2022-07-22 12:37:17 +090098 "ConnectivityTestsLatestSdkDefaults",
Remi NGUYEN VANe55a88d2022-04-20 15:59:16 +090099 "framework-connectivity-internal-test-defaults",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900100 "FrameworksNetTests-jni-defaults",
101 "libnetworkstackutilsjni_deps",
102 ],
103 manifest: "AndroidManifest_coverage.xml",
104 test_config: "AndroidTest_Coverage.xml",
105 static_libs: [
106 // Added first so all tests use extended mockito, instead of all tests using regular mockito
107 // (some tests would fail).
108 // TODO: consider removing extended mockito usage in tests that use it, for performance
109 "mockito-target-extended-minus-junit4",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900110 "modules-utils-native-coverage-listener",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +0900111 "ConnectivityCoverageTestsLib",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900112 ],
113 jni_libs: [
114 // For mockito extended
115 "libdexmakerjvmtiagent",
116 "libstaticjvmtiagent",
117 // For NetworkStackUtils included in NetworkStackBase
118 "libnetworkstackutilsjni",
Remi NGUYEN VAN2ba9dbe2022-02-01 23:07:33 +0900119 "libandroid_net_connectivity_com_android_net_module_util_jni",
markchienf967b112021-11-09 16:56:23 +0800120 "libcom_android_networkstack_tethering_util_jni",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900121 // For framework tests
122 "libservice-connectivity",
123 ],
124 libs: [
125 // Although not required to compile the static libs together, the "libs" used to build each
126 // of the common static test libs are necessary for R8 to avoid "Missing class" warnings and
127 // incorrect optimizations
128 "framework-tethering.impl",
129 "framework-wifi.stubs.module_lib",
130 ],
131 compile_multilib: "both",
132}
133
Remi NGUYEN VAN679a8e02021-05-14 07:24:53 +0000134// defaults for tests that need to build against framework-connectivity's @hide APIs
135// Only usable from targets that have visibility on framework-connectivity.impl.
136// Instead of using this, consider avoiding to depend on hidden connectivity APIs in
137// tests.
138java_defaults {
139 name: "framework-connectivity-test-defaults",
140 sdk_version: "core_platform", // tests can use @CorePlatformApi's
141 libs: [
142 // order matters: classes in framework-connectivity are resolved before framework,
143 // meaning @hide APIs in framework-connectivity are resolved before @SystemApi
144 // stubs in framework
145 "framework-connectivity.impl",
paulhu537f7202022-02-08 21:25:28 +0800146 "framework-connectivity-t.impl",
markchien2fbd3e72021-08-17 23:59:09 +0800147 "framework-tethering.impl",
Remi NGUYEN VAN679a8e02021-05-14 07:24:53 +0000148 "framework",
149
150 // if sdk_version="" this gets automatically included, but here we need to add manually.
151 "framework-res",
152 ],
153}
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900154
Remi NGUYEN VAN1a8ee102022-05-30 12:42:24 +0900155// defaults for tests that need to build against framework-connectivity's @hide APIs, but also
156// using fully @hide classes that are jarjared (because they have no API member). Similar to
157// framework-connectivity-test-defaults above but uses pre-jarjar class names.
158// Only usable from targets that have visibility on framework-connectivity-pre-jarjar, and apply
159// connectivity jarjar rules so that references to jarjared classes still match: this is limited to
160// connectivity internal tests only.
161java_defaults {
162 name: "framework-connectivity-internal-test-defaults",
163 sdk_version: "core_platform", // tests can use @CorePlatformApi's
164 libs: [
165 // order matters: classes in framework-connectivity are resolved before framework,
166 // meaning @hide APIs in framework-connectivity are resolved before @SystemApi
167 // stubs in framework
168 "framework-connectivity-pre-jarjar",
169 "framework-connectivity-t-pre-jarjar",
170 "framework-tethering.impl",
171 "framework",
172
173 // if sdk_version="" this gets automatically included, but here we need to add manually.
174 "framework-res",
175 ],
176 defaults_visibility: ["//packages/modules/Connectivity/tests:__subpackages__"],
177}
178
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900179// Defaults for tests that want to run in mainline-presubmit.
180// Not widely used because many of our tests have AndroidTest.xml files and
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900181// use the mainline-param config-descriptor metadata in AndroidTest.xml.
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900182
183// test_mainline_modules is an array of strings. Each element in the array is a list of modules
184// separated by "+". The modules in this list must be in alphabetical order.
185// See SuiteModuleLoader.java.
186// TODO: why are the modules separated by + instead of being separate entries in the array?
187mainline_presubmit_modules = [
188 "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex",
189]
190
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900191cc_defaults {
192 name: "connectivity-mainline-presubmit-cc-defaults",
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900193 test_mainline_modules: mainline_presubmit_modules,
194}
195
196java_defaults {
197 name: "connectivity-mainline-presubmit-java-defaults",
198 test_mainline_modules: mainline_presubmit_modules,
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900199}