1// Copyright (C) 2022 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14package { 15 default_applicable_licenses: ["Android-Apache-2.0"], 16} 17 18java_defaults { 19 name: "AdServices-ServiceCoreUnitTest-Defaults", 20 defaults: ["adservices-extended-mockito-defaults"], 21 // Currently this test module is failing, which results in low test coverage 22 // The reason is the target test coverage system runs on is different as what this test 23 // configures. Add below line to address the issue. 24 // See b/233124651 for details. 25 compile_multilib: "both", 26 min_sdk_version: "Tiramisu", 27 sdk_version: "module_current", 28 plugins: [ 29 "auto_value_plugin", 30 "auto_annotation_plugin", 31 ], 32 static_libs: [ 33 "androidx.concurrent_concurrent-futures", 34 "androidx.test.rules", 35 "compatibility-device-util-axt", 36 "truth", 37 "gson", 38 "adservices-assets", 39 "adservices-service-core-schema", 40 "adservices-shared-testing", 41 "adservices-test-mockito-expectations", 42 "adservices-test-utility", 43 "androidx.room_room-runtime", 44 "androidx.room_room-testing", 45 "adservices-test-fixtures", 46 "mobile_data_downloader_lib", 47 "tflite_support_classifiers_java", 48 "opencensus-java-api", 49 "opencensus-java-contrib-grpc-metrics", 50 "adservices_flags_lib", // Used by FlagsConstantsTest 51 // Tests may run on the platforms that don't have ODP module installed. 52 // Without static_lib dependency, the framework code from ODP won't be 53 // packaged with the test APK and throw NoClassDefFoundError. 54 "framework-ondevicepersonalization.impl", 55 ], 56 libs: [ 57 "android.test.base", 58 "android.test.mock.stubs", 59 "framework-adservices.impl", 60 "framework-annotations-lib", 61 "framework-configinfrastructure", 62 "framework-sdksandbox.impl", 63 "auto_value_annotations", 64 ], 65 test_suites: [ 66 "general-tests", 67 "mts-adservices", 68 ], 69 instrumentation_for: "AdServicesApk", 70 jni_libs: [ 71 "libhpke_jni", 72 "libacttest_jni", 73 "libtflite_support_classifiers_native", 74 ], 75 aaptflags: [ 76 // avoid compression on lite and tflite files as the Interpreter 77 // can not load compressed flat buffer formats. (*appt compresses all 78 // assets into the apk by default) 79 // See https://elinux.org/Android_aapt for more detail. 80 "-0 .lite", 81 "-0 .tflite", 82 ], 83 lint: { 84 extra_check_modules: ["AdServicesTestLintChecker"], 85 test: false, // TODO(b/343741206): remove when checks will run on android_test 86 }, 87} 88 89android_test { 90 name: "AdServicesServiceCoreUnitTests", 91 srcs: [ 92 "src/**/*.java", 93 ], 94 exclude_srcs: [ 95 // The tests below are interacting with the JsSandbox singleton and should 96 // be run in a separate process 97 "src/com/android/adservices/service/js/JSScriptEngineTest.java", 98 "src/com/android/adservices/service/js/JavaScriptSandboxProviderTest.java", 99 // Exclude Mobile Data Download Test. This test need network connection and download files. 100 // This will run in a separate test suite. 101 "src/com/android/adservices/download/MobileDataDownloadTest.java", 102 // Measurement unit tests will be covered by AdServicesServiceCoreMeasurementUnitTests. 103 "src/com/android/adservices/service/measurement/**/*.java", 104 "src/com/android/adservices/data/measurement/**/*Test.java", 105 // Topics unit tests will be covered by AdServicesServiceCoreTopicsUnitTests. 106 "src/com/android/adservices/service/topics/**/*.java", 107 "src/com/android/adservices/data/topics/**/*Test.java", 108 ], 109 defaults: ["AdServices-ServiceCoreUnitTest-Defaults"], 110} 111 112android_test { 113 name: "AdServicesJsEngineUnitTests", 114 srcs: [ 115 "src/com/android/adservices/service/js/JSScriptEngineTest.java", 116 "src/com/android/adservices/service/js/JavaScriptSandboxProviderTest.java", 117 ], 118 defaults: ["modules-utils-testable-device-config-defaults"], 119 sdk_version: "module_current", 120 compile_multilib: "both", 121 min_sdk_version: "Tiramisu", 122 static_libs: [ 123 "androidx.concurrent_concurrent-futures", 124 "androidx.test.rules", 125 "compatibility-device-util-axt", 126 "mockito-target-extended-minus-junit4", 127 "truth", 128 "adservices-assets", 129 "adservices-test-fixtures", 130 ], 131 libs: [ 132 "android.test.base", 133 "android.test.mock.stubs", 134 "framework-adservices.impl", 135 "framework-annotations-lib", 136 "framework-statsd.stubs.module_lib", 137 ], 138 test_suites: [ 139 "general-tests", 140 "mts-adservices", 141 ], 142 test_config: "AndroidTest.JsScriptEngine.xml", 143 instrumentation_for: "AdServicesApk", 144 lint: { 145 extra_check_modules: ["AdServicesTestLintChecker"], 146 test: false, // TODO(b/343741206): remove when checks will run on android_test 147 }, 148} 149 150android_test { 151 // This test need network connection and download files so it could be more flaky and run longer. 152 name: "AdServicesMddIntegrationTests", 153 srcs: [ 154 "src/com/android/adservices/download/MobileDataDownloadTest.java", 155 // Contains DB Util methods which used in MobileDataDownloadTest.java 156 "src/com/android/adservices/data/DbTestUtil.java", 157 ], 158 defaults: ["modules-utils-testable-device-config-defaults"], 159 sdk_version: "module_current", 160 compile_multilib: "both", 161 min_sdk_version: "Tiramisu", 162 static_libs: [ 163 "androidx.concurrent_concurrent-futures", 164 "androidx.test.rules", 165 "compatibility-device-util-axt", 166 "mockito-target-extended-minus-junit4", 167 "truth", 168 "adservices-assets", 169 "adservices-test-fixtures", 170 "mobile_data_downloader_lib", 171 ], 172 libs: [ 173 "android.test.base", 174 "android.test.mock.stubs", 175 "framework-adservices.impl", 176 "framework-annotations-lib", 177 "framework-wifi", 178 ], 179 test_suites: [ 180 "general-tests", 181 "mts-adservices", 182 ], 183 test_config: "AndroidTestMDD.xml", 184 instrumentation_for: "AdServicesApk", 185 lint: { 186 extra_check_modules: ["AdServicesTestLintChecker"], 187 test: false, // TODO(b/343741206): remove when checks will run on android_test 188 }, 189} 190 191java_defaults { 192 name: "AdExtServices-ServiceCoreUnitTest-Defaults", 193 defaults: ["adservices-extended-mockito-defaults"], 194 sdk_version: "module_current", 195 // Currently this test module is failing, which results in low test coverage 196 // The reason is the target test coverage system runs on is different as what this test 197 // configures. Add below line to address the issue. 198 // See b/233124651 for details. 199 compile_multilib: "both", 200 min_sdk_version: "30", 201 max_sdk_version: "32", 202 static_libs: [ 203 "adservices-assets", 204 "adservices-service-core-schema", 205 "adservices-shared-testing", 206 "adservices-test-fixtures", 207 "adservices-test-mockito-expectations", 208 "adservices-test-utility", 209 "androidx.concurrent_concurrent-futures", 210 "androidx.room_room-runtime", 211 "androidx.room_room-testing", 212 "androidx.test.rules", 213 "compatibility-device-util-axt", 214 "mobile_data_downloader_lib", 215 "opencensus-java-api", 216 "opencensus-java-contrib-grpc-metrics", 217 "tflite_support_classifiers_java", 218 "truth", 219 "gson", 220 "adservices_flags_lib", // Used by FlagsConstantsTest 221 // Tests may run on the platforms that don't have ODP module installed. 222 // Without static_lib dependency, the framework code from ODP won't be 223 // packaged with the test APK and throw NoClassDefFoundError. 224 "framework-ondevicepersonalization.impl", 225 ], 226 libs: [ 227 "android.ext.adservices", 228 "android.test.base", 229 "android.test.mock.stubs", 230 "framework-annotations-lib", 231 "framework-configinfrastructure", 232 "framework-sdksandbox.impl", 233 ], 234 test_suites: [ 235 "general-tests", 236 "mts-extservices", 237 ], 238 instrumentation_for: "ExtServices-sminus", 239 jni_libs: [ 240 "libhpke_jni", 241 "libacttest_jni", 242 "libtflite_support_classifiers_native", 243 ], 244 aaptflags: [ 245 // avoid compression on lite and tflite files as the Interpreter 246 // can not load compressed flat buffer formats. (*appt compresses all 247 // assets into the apk by default) 248 // See https://elinux.org/Android_aapt for more detail. 249 "-0 .lite", 250 "-0 .tflite", 251 ], 252 lint: { 253 extra_check_modules: ["AdServicesTestLintChecker"], 254 test: false, // TODO(b/343741206): remove when checks will run on android_test 255 }, 256} 257 258android_test { 259 name: "AdExtServicesServiceCoreUnitTests", 260 defaults: ["AdExtServices-ServiceCoreUnitTest-Defaults"], 261 srcs: [ 262 "src/**/*.java", 263 ], 264 exclude_srcs: [ 265 // The tests below are interacting with the JsSandbox singleton and should 266 // be run in a separate process 267 "src/com/android/adservices/service/js/JSScriptEngineTest.java", 268 "src/com/android/adservices/service/js/JavaScriptSandboxProviderTest.java", 269 // Exclude Mobile Data Download Test. This test need network connection and download files. 270 // This will run in a separate test suite. 271 "src/com/android/adservices/download/MobileDataDownloadTest.java", 272 // Measurement unit tests will be covered by AdExtServicesServiceCoreMeasurementUnitTests. 273 "src/com/android/adservices/service/measurement/**/*.java", 274 "src/com/android/adservices/data/measurement/**/*Test.java", 275 // Topics unit tests will be covered by AdServicesServiceCoreTopicsUnitTests. 276 "src/com/android/adservices/service/topics/**/*.java", 277 "src/com/android/adservices/data/topics/**/*Test.java", 278 ], 279 test_config: "AndroidTest.ExtServices.xml", 280} 281 282android_test { 283 name: "AdServicesServiceCoreMeasurementUnitTests", 284 defaults: ["AdServices-ServiceCoreUnitTest-Defaults"], 285 srcs: [ 286 "src/com/android/adservices/service/measurement/**/*.java", 287 "src/com/android/adservices/data/measurement/**/*.java", 288 "src/com/android/adservices/data/DbTestUtil.java", 289 "src/com/android/adservices/MockWebServerRuleFactory.java", 290 ], 291 test_config: "AndroidTest.Measurement.xml", 292} 293 294android_test { 295 name: "AdExtServicesServiceCoreMeasurementUnitTests", 296 srcs: [ 297 "src/com/android/adservices/service/measurement/**/*.java", 298 "src/com/android/adservices/data/measurement/**/*.java", 299 "src/com/android/adservices/data/DbTestUtil.java", 300 "src/com/android/adservices/MockWebServerRuleFactory.java", 301 ], 302 defaults: ["AdExtServices-ServiceCoreUnitTest-Defaults"], 303 test_config: "AndroidTest.Measurement.ExtServices.xml", 304} 305 306android_test { 307 name: "AdServicesServiceCoreTopicsUnitTests", 308 defaults: ["AdServices-ServiceCoreUnitTest-Defaults"], 309 srcs: [ 310 "src/com/android/adservices/service/topics/**/*.java", 311 "src/com/android/adservices/data/topics/**/*.java", 312 "src/com/android/adservices/data/DbTestUtil.java", 313 "src/com/android/adservices/MockRandom.java", 314 ], 315 test_config: "AndroidTest.Topics.xml", 316} 317 318android_test { 319 name: "AdExtServicesServiceCoreTopicsUnitTests", 320 srcs: [ 321 "src/com/android/adservices/service/topics/**/*.java", 322 "src/com/android/adservices/data/topics/**/*.java", 323 "src/com/android/adservices/data/DbTestUtil.java", 324 "src/com/android/adservices/MockRandom.java", 325 ], 326 defaults: ["AdExtServices-ServiceCoreUnitTest-Defaults"], 327 test_config: "AndroidTest.Topics.ExtServices.xml", 328} 329 330android_test { 331 name: "AdExtServicesJsEngineUnitTests", 332 srcs: [ 333 "src/com/android/adservices/service/js/JSScriptEngineTest.java", 334 "src/com/android/adservices/service/js/JavaScriptSandboxProviderTest.java", 335 ], 336 defaults: ["modules-utils-testable-device-config-defaults"], 337 sdk_version: "module_current", 338 compile_multilib: "both", 339 min_sdk_version: "30", 340 max_sdk_version: "32", 341 static_libs: [ 342 "adservices-assets", 343 "adservices-test-fixtures", 344 "androidx.concurrent_concurrent-futures", 345 "androidx.test.rules", 346 "compatibility-device-util-axt", 347 "mockito-target-extended-minus-junit4", 348 "truth", 349 ], 350 libs: [ 351 "android.ext.adservices", 352 "android.test.base", 353 "android.test.mock.stubs", 354 "framework-annotations-lib", 355 "framework-statsd.stubs.module_lib", 356 ], 357 test_suites: [ 358 "general-tests", 359 "mts-extservices", 360 ], 361 test_config: "AndroidTest.JsScriptEngine.ExtServices.xml", 362 instrumentation_for: "ExtServices-sminus", 363 lint: { 364 extra_check_modules: ["AdServicesTestLintChecker"], 365 test: false, // TODO(b/343741206): remove when checks will run on android_test 366 }, 367} 368 369android_test { 370 // This test need network connection and download files so it could be more flaky and run longer. 371 name: "AdExtServicesMddIntegrationTests", 372 srcs: [ 373 "src/com/android/adservices/download/MobileDataDownloadTest.java", 374 // Contains DB Util methods which used in MobileDataDownloadTest.java 375 "src/com/android/adservices/data/DbTestUtil.java", 376 ], 377 defaults: ["modules-utils-testable-device-config-defaults"], 378 sdk_version: "module_current", 379 compile_multilib: "both", 380 min_sdk_version: "30", 381 max_sdk_version: "32", 382 static_libs: [ 383 "adservices-assets", 384 "adservices-test-fixtures", 385 "androidx.concurrent_concurrent-futures", 386 "androidx.test.rules", 387 "compatibility-device-util-axt", 388 "mobile_data_downloader_lib", 389 "mockito-target-extended-minus-junit4", 390 "truth", 391 ], 392 libs: [ 393 "android.ext.adservices", 394 "android.test.base", 395 "android.test.mock.stubs", 396 "framework-adservices.impl", 397 "framework-annotations-lib", 398 "framework-wifi", 399 ], 400 test_suites: [ 401 "general-tests", 402 "mts-extservices", 403 ], 404 test_config: "AndroidTestMDD.ExtServices.xml", 405 instrumentation_for: "ExtServices-sminus", 406 lint: { 407 extra_check_modules: ["AdServicesTestLintChecker"], 408 baseline_filename: "lint-baseline-adextservices-mdd.xml", 409 test: false, // TODO(b/343741206): remove when checks will run on android_test 410 }, 411} 412 413cc_library_shared { 414 name: "libacttest_jni", 415 min_sdk_version: "30", 416 sdk_version: "current", 417 stl: "libc++_static", 418 cflags: [ 419 "-Werror", 420 "-Wno-unused-parameter", 421 "-Wno-unused-but-set-variable", 422 ], 423 srcs: [ 424 "src/jni/cpp/act_util_jni.cpp", 425 ], 426 include_dirs: [ 427 "packages/modules/AdServices/adservices/service-core/jni/include", 428 "packages/modules/AdServices/adservices/tests/unittest/service-core/src/jni/cpp", 429 ], 430 header_libs: ["jni_headers"], 431 shared_libs: ["liblog"], 432 static_libs: [ 433 "libact", 434 "libcrypto_static", 435 ], 436 apex_available: [ 437 "com.android.adservices", 438 "com.android.extservices", 439 ], 440 visibility: [ 441 "//packages/modules/AdServices:__subpackages__", 442 "//packages/modules/ExtServices:__subpackages__", 443 ], 444} 445