Remi NGUYEN VAN | 31022d6 | 2021-05-11 13:37:06 +0000 | [diff] [blame] | 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. |
| 19 | package { |
| 20 | // See: http://go/android-license-faq |
Baligh Uddin | 3684713 | 2021-05-23 16:38:40 +0000 | [diff] [blame] | 21 | default_applicable_licenses: ["Android-Apache-2.0"], |
Remi NGUYEN VAN | 31022d6 | 2021-05-11 13:37:06 +0000 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | java_library { |
| 25 | name: "FrameworksNetCommonTests", |
Remi NGUYEN VAN | 7b92ff2 | 2022-04-20 15:59:16 +0900 | [diff] [blame] | 26 | defaults: ["framework-connectivity-internal-test-defaults"], |
Remi NGUYEN VAN | 3912c80 | 2021-03-16 01:31:07 +0000 | [diff] [blame] | 27 | srcs: [ |
| 28 | "java/**/*.java", |
| 29 | "java/**/*.kt", |
| 30 | ], |
Remi NGUYEN VAN | 31022d6 | 2021-05-11 13:37:06 +0000 | [diff] [blame] | 31 | 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", |
Taras Antoshchuk | 30d41e5 | 2021-08-02 18:06:35 +0200 | [diff] [blame] | 39 | "platform-compat-test-rules", |
Remi NGUYEN VAN | 31022d6 | 2021-05-11 13:37:06 +0000 | [diff] [blame] | 40 | "platform-test-annotations", |
| 41 | ], |
| 42 | libs: [ |
| 43 | "android.test.base.stubs", |
| 44 | ], |
| 45 | } |
Remi NGUYEN VAN | 679a8e0 | 2021-05-14 07:24:53 +0000 | [diff] [blame] | 46 | |
markchien | e59f5e3 | 2022-04-02 00:45:53 +0800 | [diff] [blame] | 47 | // Combine Connectivity, NetworkStack and Tethering jarjar rules for coverage target. |
| 48 | // The jarjar files are simply concatenated in the order specified in srcs. |
| 49 | // jarjar stops at the first matching rule, so order of concatenation affects the output. |
| 50 | genrule { |
| 51 | name: "ConnectivityCoverageJarJarRules", |
Remi NGUYEN VAN | 7b92ff2 | 2022-04-20 15:59:16 +0900 | [diff] [blame] | 52 | defaults: ["jarjar-rules-combine-defaults"], |
markchien | e59f5e3 | 2022-04-02 00:45:53 +0800 | [diff] [blame] | 53 | srcs: [ |
| 54 | "tethering-jni-jarjar-rules.txt", |
| 55 | ":connectivity-jarjar-rules", |
| 56 | ":TetheringTestsJarJarRules", |
| 57 | ":NetworkStackJarJarRules", |
| 58 | ], |
| 59 | out: ["jarjar-rules-connectivity-coverage.txt"], |
markchien | e59f5e3 | 2022-04-02 00:45:53 +0800 | [diff] [blame] | 60 | visibility: ["//visibility:private"], |
| 61 | } |
| 62 | |
Remi NGUYEN VAN | 8ea5ee6 | 2021-06-28 18:48:43 +0900 | [diff] [blame] | 63 | android_library { |
| 64 | name: "ConnectivityCoverageTestsLib", |
| 65 | min_sdk_version: "30", |
| 66 | static_libs: [ |
| 67 | "FrameworksNetTestsLib", |
| 68 | "NetdStaticLibTestsLib", |
| 69 | "NetworkStaticLibTestsLib", |
markchien | e59f5e3 | 2022-04-02 00:45:53 +0800 | [diff] [blame] | 70 | "NetworkStackTestsLib", |
| 71 | "TetheringTestsLatestSdkLib", |
| 72 | "TetheringIntegrationTestsLatestSdkLib", |
Remi NGUYEN VAN | 8ea5ee6 | 2021-06-28 18:48:43 +0900 | [diff] [blame] | 73 | ], |
markchien | e59f5e3 | 2022-04-02 00:45:53 +0800 | [diff] [blame] | 74 | jarjar_rules: ":ConnectivityCoverageJarJarRules", |
Remi NGUYEN VAN | 8ea5ee6 | 2021-06-28 18:48:43 +0900 | [diff] [blame] | 75 | manifest: "AndroidManifest_coverage.xml", |
| 76 | visibility: ["//visibility:private"], |
| 77 | } |
| 78 | |
Remi NGUYEN VAN | fe20e13 | 2021-06-07 13:10:49 +0900 | [diff] [blame] | 79 | android_test { |
| 80 | name: "ConnectivityCoverageTests", |
| 81 | // Tethering started on SDK 30 |
| 82 | min_sdk_version: "30", |
Chiachang Wang | 76df50c | 2021-12-22 17:47:26 +0800 | [diff] [blame] | 83 | target_sdk_version: "31", |
Kimberly Kreider | c5b3f34 | 2021-10-20 18:16:59 +0000 | [diff] [blame] | 84 | test_suites: ["general-tests", "mts-tethering"], |
Remi NGUYEN VAN | fe20e13 | 2021-06-07 13:10:49 +0900 | [diff] [blame] | 85 | defaults: [ |
Remi NGUYEN VAN | 7b92ff2 | 2022-04-20 15:59:16 +0900 | [diff] [blame] | 86 | "framework-connectivity-internal-test-defaults", |
Remi NGUYEN VAN | fe20e13 | 2021-06-07 13:10:49 +0900 | [diff] [blame] | 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 VAN | fe20e13 | 2021-06-07 13:10:49 +0900 | [diff] [blame] | 97 | "modules-utils-native-coverage-listener", |
Remi NGUYEN VAN | 8ea5ee6 | 2021-06-28 18:48:43 +0900 | [diff] [blame] | 98 | "ConnectivityCoverageTestsLib", |
Remi NGUYEN VAN | fe20e13 | 2021-06-07 13:10:49 +0900 | [diff] [blame] | 99 | ], |
| 100 | jni_libs: [ |
| 101 | // For mockito extended |
| 102 | "libdexmakerjvmtiagent", |
| 103 | "libstaticjvmtiagent", |
| 104 | // For NetworkStackUtils included in NetworkStackBase |
| 105 | "libnetworkstackutilsjni", |
Remi NGUYEN VAN | 2ba9dbe | 2022-02-01 23:07:33 +0900 | [diff] [blame] | 106 | "libandroid_net_connectivity_com_android_net_module_util_jni", |
markchien | f967b11 | 2021-11-09 16:56:23 +0800 | [diff] [blame] | 107 | "libcom_android_networkstack_tethering_util_jni", |
Remi NGUYEN VAN | fe20e13 | 2021-06-07 13:10:49 +0900 | [diff] [blame] | 108 | // 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 VAN | 679a8e0 | 2021-05-14 07:24:53 +0000 | [diff] [blame] | 121 | // 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. |
| 125 | java_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", |
paulhu | 537f720 | 2022-02-08 21:25:28 +0800 | [diff] [blame] | 133 | "framework-connectivity-t.impl", |
markchien | 2fbd3e7 | 2021-08-17 23:59:09 +0800 | [diff] [blame] | 134 | "framework-tethering.impl", |
Remi NGUYEN VAN | 679a8e0 | 2021-05-14 07:24:53 +0000 | [diff] [blame] | 135 | "framework", |
| 136 | |
| 137 | // if sdk_version="" this gets automatically included, but here we need to add manually. |
| 138 | "framework-res", |
| 139 | ], |
| 140 | } |
Lorenzo Colitti | da0c43e | 2022-01-14 11:13:15 +0900 | [diff] [blame] | 141 | |
Remi NGUYEN VAN | 7b92ff2 | 2022-04-20 15:59:16 +0900 | [diff] [blame] | 142 | // defaults for tests that need to build against framework-connectivity's @hide APIs, but also |
| 143 | // using fully @hide classes that are jarjared (because they have no API member). Similar to |
| 144 | // framework-connectivity-test-defaults above but uses pre-jarjar class names. |
| 145 | // Only usable from targets that have visibility on framework-connectivity-pre-jarjar, and apply |
| 146 | // connectivity jarjar rules so that references to jarjared classes still match: this is limited to |
| 147 | // connectivity internal tests only. |
| 148 | java_defaults { |
| 149 | name: "framework-connectivity-internal-test-defaults", |
| 150 | sdk_version: "core_platform", // tests can use @CorePlatformApi's |
| 151 | libs: [ |
| 152 | // order matters: classes in framework-connectivity are resolved before framework, |
| 153 | // meaning @hide APIs in framework-connectivity are resolved before @SystemApi |
| 154 | // stubs in framework |
| 155 | "framework-connectivity-pre-jarjar", |
| 156 | "framework-connectivity-t-pre-jarjar", |
| 157 | "framework-tethering.impl", |
| 158 | "framework", |
| 159 | |
| 160 | // if sdk_version="" this gets automatically included, but here we need to add manually. |
| 161 | "framework-res", |
| 162 | ], |
| 163 | defaults_visibility: ["//packages/modules/Connectivity/tests:__subpackages__"], |
| 164 | } |
| 165 | |
Lorenzo Colitti | be53da1 | 2022-01-18 00:27:59 +0900 | [diff] [blame] | 166 | // Defaults for tests that want to run in mainline-presubmit. |
| 167 | // Not widely used because many of our tests have AndroidTest.xml files and |
Lorenzo Colitti | da0c43e | 2022-01-14 11:13:15 +0900 | [diff] [blame] | 168 | // use the mainline-param config-descriptor metadata in AndroidTest.xml. |
Lorenzo Colitti | be53da1 | 2022-01-18 00:27:59 +0900 | [diff] [blame] | 169 | |
| 170 | // test_mainline_modules is an array of strings. Each element in the array is a list of modules |
| 171 | // separated by "+". The modules in this list must be in alphabetical order. |
| 172 | // See SuiteModuleLoader.java. |
| 173 | // TODO: why are the modules separated by + instead of being separate entries in the array? |
| 174 | mainline_presubmit_modules = [ |
| 175 | "CaptivePortalLoginGoogle.apk+NetworkStackGoogle.apk+com.google.android.resolv.apex+com.google.android.tethering.apex", |
| 176 | ] |
| 177 | |
Lorenzo Colitti | da0c43e | 2022-01-14 11:13:15 +0900 | [diff] [blame] | 178 | cc_defaults { |
| 179 | name: "connectivity-mainline-presubmit-cc-defaults", |
Lorenzo Colitti | be53da1 | 2022-01-18 00:27:59 +0900 | [diff] [blame] | 180 | test_mainline_modules: mainline_presubmit_modules, |
| 181 | } |
| 182 | |
| 183 | java_defaults { |
| 184 | name: "connectivity-mainline-presubmit-java-defaults", |
| 185 | test_mainline_modules: mainline_presubmit_modules, |
Lorenzo Colitti | da0c43e | 2022-01-14 11:13:15 +0900 | [diff] [blame] | 186 | } |