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 default_team: "trendy_team_fwk_core_networking", 21 // See: http://go/android-license-faq 22 default_applicable_licenses: ["Android-Apache-2.0"], 23} 24 25// 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", 35 target_sdk_version: "34", 36} 37 38java_library { 39 name: "FrameworksNetCommonTests", 40 defaults: ["framework-connectivity-internal-test-defaults"], 41 srcs: [ 42 "java/**/*.java", 43 "java/**/*.kt", 44 ], 45 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", 53 "platform-compat-test-rules", 54 "platform-test-annotations", 55 ], 56 libs: [ 57 "android.test.base.stubs", 58 ], 59} 60 61// 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. 64java_genrule { 65 name: "ConnectivityCoverageJarJarRules", 66 defaults: ["jarjar-rules-combine-defaults"], 67 srcs: [ 68 "tethering-jni-jarjar-rules.txt", 69 ":frameworks-net-tests-jarjar-rules", 70 ":TetheringTestsJarJarRules", 71 ":NetworkStackJarJarRules", 72 ], 73 out: ["jarjar-rules-connectivity-coverage.txt"], 74 visibility: ["//visibility:private"], 75} 76 77android_library { 78 name: "ConnectivityCoverageTestsLib", 79 min_sdk_version: "30", 80 static_libs: [ 81 "ConnectivityUnitTestsLib", 82 "NetdStaticLibTestsLib", 83 "NetworkStaticLibTestsLib", 84 "NetworkStackTestsLib", 85 "TetheringTestsLatestSdkLib", 86 "TetheringIntegrationTestsLatestSdkLib", 87 ], 88 jarjar_rules: ":ConnectivityCoverageJarJarRules", 89 manifest: "AndroidManifest_coverage.xml", 90 visibility: ["//visibility:private"], 91} 92 93android_test { 94 name: "ConnectivityCoverageTests", 95 // Tethering started on SDK 30 96 min_sdk_version: "30", 97 test_suites: [ 98 "general-tests", 99 "mts-tethering", 100 ], 101 defaults: [ 102 "ConnectivityTestsLatestSdkDefaults", 103 "framework-connectivity-internal-test-defaults", 104 "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", 114 "modules-utils-native-coverage-listener", 115 "ConnectivityCoverageTestsLib", 116 ], 117 jni_libs: [ 118 // For mockito extended 119 "libdexmakerjvmtiagent", 120 "libstaticjvmtiagent", 121 // For NetworkStackUtils included in NetworkStackBase 122 "libnetworkstackutilsjni", 123 "libandroid_net_connectivity_com_android_net_module_util_jni", 124 "libcom_android_networkstack_tethering_util_jni", 125 // 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 138// 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", 150 "framework-connectivity-b.impl", 151 "framework-connectivity-t.impl", 152 "framework-tethering.impl", 153 "framework", 154 155 // if sdk_version="" this gets automatically included, but here we need to add manually. 156 "framework-res", 157 ], 158} 159 160// defaults for tests that need to build against framework-connectivity's @hide APIs, but also 161// using fully @hide classes that are jarjared (because they have no API member). Similar to 162// framework-connectivity-test-defaults above but uses pre-jarjar class names. 163// Only usable from targets that have visibility on framework-connectivity-pre-jarjar, and apply 164// connectivity jarjar rules so that references to jarjared classes still match: this is limited to 165// connectivity internal tests only. 166java_defaults { 167 name: "framework-connectivity-internal-test-defaults", 168 sdk_version: "core_platform", // tests can use @CorePlatformApi's 169 libs: [ 170 // order matters: classes in framework-connectivity are resolved before framework, 171 // meaning @hide APIs in framework-connectivity are resolved before @SystemApi 172 // stubs in framework 173 "framework-connectivity-pre-jarjar", 174 "framework-connectivity-t-pre-jarjar", 175 "framework-tethering.impl", 176 "framework", 177 178 // if sdk_version="" this gets automatically included, but here we need to add manually. 179 "framework-res", 180 ], 181 defaults_visibility: ["//packages/modules/Connectivity/tests:__subpackages__"], 182} 183 184// Defaults for tests that want to run in mainline-presubmit. 185// Not widely used because many of our tests have AndroidTest.xml files and 186// use the mainline-param config-descriptor metadata in AndroidTest.xml. 187 188// test_mainline_modules is an array of strings. Each element in the array is a list of modules 189// separated by "+". The modules in this list must be in alphabetical order. 190// See SuiteModuleLoader.java. 191// TODO: why are the modules separated by + instead of being separate entries in the array? 192mainline_presubmit_modules = [ 193 "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex", 194] 195 196cc_defaults { 197 name: "connectivity-mainline-presubmit-cc-defaults", 198 test_mainline_modules: mainline_presubmit_modules, 199} 200 201java_defaults { 202 name: "connectivity-mainline-presubmit-java-defaults", 203 test_mainline_modules: mainline_presubmit_modules, 204} 205 206filegroup { 207 name: "connectivity_mainline_test_map", 208 srcs: ["connectivity_mainline_test.map"], 209} 210