blob: 7bb7cb562b328019119f4cd94510642f89d012df [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
24java_library {
25 name: "FrameworksNetCommonTests",
Remi NGUYEN VAN3912c802021-03-16 01:31:07 +000026 defaults: ["framework-connectivity-test-defaults"],
27 srcs: [
28 "java/**/*.java",
29 "java/**/*.kt",
30 ],
Remi NGUYEN VAN31022d62021-05-11 13:37:06 +000031 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-test-annotations",
40 ],
41 libs: [
42 "android.test.base.stubs",
43 ],
44}
Remi NGUYEN VAN679a8e02021-05-14 07:24:53 +000045
markchiene59f5e32022-04-02 00:45:53 +080046// Combine Connectivity, NetworkStack and Tethering jarjar rules for coverage target.
47// The jarjar files are simply concatenated in the order specified in srcs.
48// jarjar stops at the first matching rule, so order of concatenation affects the output.
49genrule {
50 name: "ConnectivityCoverageJarJarRules",
51 srcs: [
52 "tethering-jni-jarjar-rules.txt",
53 ":connectivity-jarjar-rules",
54 ":TetheringTestsJarJarRules",
55 ":NetworkStackJarJarRules",
56 ],
57 out: ["jarjar-rules-connectivity-coverage.txt"],
58 // Concat files with a line break in the middle
59 cmd: "for src in $(in); do cat $${src}; echo; done > $(out)",
60 visibility: ["//visibility:private"],
61}
62
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090063android_library {
64 name: "ConnectivityCoverageTestsLib",
65 min_sdk_version: "30",
66 static_libs: [
67 "FrameworksNetTestsLib",
68 "NetdStaticLibTestsLib",
69 "NetworkStaticLibTestsLib",
markchiene59f5e32022-04-02 00:45:53 +080070 "NetworkStackTestsLib",
71 "TetheringTestsLatestSdkLib",
72 "TetheringIntegrationTestsLatestSdkLib",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090073 ],
markchiene59f5e32022-04-02 00:45:53 +080074 jarjar_rules: ":ConnectivityCoverageJarJarRules",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090075 manifest: "AndroidManifest_coverage.xml",
76 visibility: ["//visibility:private"],
77}
78
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +090079android_test {
80 name: "ConnectivityCoverageTests",
81 // Tethering started on SDK 30
82 min_sdk_version: "30",
Chiachang Wang76df50c2021-12-22 17:47:26 +080083 target_sdk_version: "31",
Kimberly Kreiderc5b3f342021-10-20 18:16:59 +000084 test_suites: ["general-tests", "mts-tethering"],
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +090085 defaults: [
86 "framework-connectivity-test-defaults",
87 "FrameworksNetTests-jni-defaults",
88 "libnetworkstackutilsjni_deps",
89 ],
90 manifest: "AndroidManifest_coverage.xml",
91 test_config: "AndroidTest_Coverage.xml",
92 static_libs: [
93 // Added first so all tests use extended mockito, instead of all tests using regular mockito
94 // (some tests would fail).
95 // TODO: consider removing extended mockito usage in tests that use it, for performance
96 "mockito-target-extended-minus-junit4",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +090097 "modules-utils-native-coverage-listener",
Remi NGUYEN VAN8ea5ee62021-06-28 18:48:43 +090098 "ConnectivityCoverageTestsLib",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +090099 ],
100 jni_libs: [
101 // For mockito extended
102 "libdexmakerjvmtiagent",
103 "libstaticjvmtiagent",
104 // For NetworkStackUtils included in NetworkStackBase
105 "libnetworkstackutilsjni",
Remi NGUYEN VAN2ba9dbe2022-02-01 23:07:33 +0900106 "libandroid_net_connectivity_com_android_net_module_util_jni",
markchienf967b112021-11-09 16:56:23 +0800107 "libcom_android_networkstack_tethering_util_jni",
Remi NGUYEN VANfe20e132021-06-07 13:10:49 +0900108 // For framework tests
109 "libservice-connectivity",
110 ],
111 libs: [
112 // Although not required to compile the static libs together, the "libs" used to build each
113 // of the common static test libs are necessary for R8 to avoid "Missing class" warnings and
114 // incorrect optimizations
115 "framework-tethering.impl",
116 "framework-wifi.stubs.module_lib",
117 ],
118 compile_multilib: "both",
119}
120
Remi NGUYEN VAN679a8e02021-05-14 07:24:53 +0000121// defaults for tests that need to build against framework-connectivity's @hide APIs
122// Only usable from targets that have visibility on framework-connectivity.impl.
123// Instead of using this, consider avoiding to depend on hidden connectivity APIs in
124// tests.
125java_defaults {
126 name: "framework-connectivity-test-defaults",
127 sdk_version: "core_platform", // tests can use @CorePlatformApi's
128 libs: [
129 // order matters: classes in framework-connectivity are resolved before framework,
130 // meaning @hide APIs in framework-connectivity are resolved before @SystemApi
131 // stubs in framework
132 "framework-connectivity.impl",
paulhu537f7202022-02-08 21:25:28 +0800133 "framework-connectivity-t.impl",
markchien2fbd3e72021-08-17 23:59:09 +0800134 "framework-tethering.impl",
Remi NGUYEN VAN679a8e02021-05-14 07:24:53 +0000135 "framework",
136
137 // if sdk_version="" this gets automatically included, but here we need to add manually.
138 "framework-res",
139 ],
140}
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900141
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900142// Defaults for tests that want to run in mainline-presubmit.
143// Not widely used because many of our tests have AndroidTest.xml files and
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900144// use the mainline-param config-descriptor metadata in AndroidTest.xml.
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900145
146// test_mainline_modules is an array of strings. Each element in the array is a list of modules
147// separated by "+". The modules in this list must be in alphabetical order.
148// See SuiteModuleLoader.java.
149// TODO: why are the modules separated by + instead of being separate entries in the array?
150mainline_presubmit_modules = [
151 "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex",
152]
153
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900154cc_defaults {
155 name: "connectivity-mainline-presubmit-cc-defaults",
Lorenzo Colittibe53da12022-01-18 00:27:59 +0900156 test_mainline_modules: mainline_presubmit_modules,
157}
158
159java_defaults {
160 name: "connectivity-mainline-presubmit-java-defaults",
161 test_mainline_modules: mainline_presubmit_modules,
Lorenzo Colittida0c43e2022-01-14 11:13:15 +0900162}