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 24// 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 37java_library { 38 name: "FrameworksNetCommonTests", 39 defaults: ["framework-connectivity-internal-test-defaults"], 40 srcs: [ 41 "java/**/*.java", 42 "java/**/*.kt", 43 ], 44 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", 52 "platform-compat-test-rules", 53 "platform-test-annotations", 54 ], 55 libs: [ 56 "android.test.base.stubs", 57 ], 58} 59 60// 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", 65 defaults: ["jarjar-rules-combine-defaults"], 66 srcs: [ 67 "tethering-jni-jarjar-rules.txt", 68 ":frameworks-net-tests-jarjar-rules", 69 ":TetheringTestsJarJarRules", 70 ":NetworkStackJarJarRules", 71 ], 72 out: ["jarjar-rules-connectivity-coverage.txt"], 73 visibility: ["//visibility:private"], 74} 75 76android_library { 77 name: "ConnectivityCoverageTestsLib", 78 min_sdk_version: "30", 79 static_libs: [ 80 "FrameworksNetTestsLib", 81 "NetdStaticLibTestsLib", 82 "NetworkStaticLibTestsLib", 83 "NetworkStackTestsLib", 84 "TetheringTestsLatestSdkLib", 85 "TetheringIntegrationTestsLatestSdkLib", 86 ], 87 jarjar_rules: ":ConnectivityCoverageJarJarRules", 88 manifest: "AndroidManifest_coverage.xml", 89 visibility: ["//visibility:private"], 90} 91 92android_test { 93 name: "ConnectivityCoverageTests", 94 // Tethering started on SDK 30 95 min_sdk_version: "30", 96 test_suites: ["general-tests", "mts-tethering"], 97 defaults: [ 98 "ConnectivityTestsLatestSdkDefaults", 99 "framework-connectivity-internal-test-defaults", 100 "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", 110 "modules-utils-native-coverage-listener", 111 "ConnectivityCoverageTestsLib", 112 ], 113 jni_libs: [ 114 // For mockito extended 115 "libdexmakerjvmtiagent", 116 "libstaticjvmtiagent", 117 // For NetworkStackUtils included in NetworkStackBase 118 "libnetworkstackutilsjni", 119 "libandroid_net_connectivity_com_android_net_module_util_jni", 120 "libcom_android_networkstack_tethering_util_jni", 121 // 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 134// 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", 146 "framework-connectivity-t.impl", 147 "framework-tethering.impl", 148 "framework", 149 150 // if sdk_version="" this gets automatically included, but here we need to add manually. 151 "framework-res", 152 ], 153} 154 155// 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 179// Defaults for tests that want to run in mainline-presubmit. 180// Not widely used because many of our tests have AndroidTest.xml files and 181// use the mainline-param config-descriptor metadata in AndroidTest.xml. 182 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 191cc_defaults { 192 name: "connectivity-mainline-presubmit-cc-defaults", 193 test_mainline_modules: mainline_presubmit_modules, 194} 195 196java_defaults { 197 name: "connectivity-mainline-presubmit-java-defaults", 198 test_mainline_modules: mainline_presubmit_modules, 199} 200