1// Copyright (C) 2024 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
18android_test {
19    name: "AdServicesUIUnitTests",
20    srcs: [
21        "src/**/*.java",
22    ],
23    exclude_srcs: [
24        // The tests below are interacting with the JsSandbox singleton and should
25        // be run in a separate process
26        "src/com/android/adservices/service/js/JSScriptEngineTest.java",
27        "src/com/android/adservices/service/js/JavaScriptSandboxProviderTest.java",
28        // Exclude Mobile Data Download Test. This test need network connection and download files.
29        // This will run in a separate test suite.
30        "src/com/android/adservices/download/MobileDataDownloadTest.java",
31    ],
32    defaults: ["adservices-extended-mockito-defaults"],
33    sdk_version: "module_current",
34    // Currently this test module is failing, which results in low test coverage
35    // The reason is the target test coverage system runs on is different as what this test
36    // configures. Add below line to address the issue.
37    // See b/233124651 for details.
38    compile_multilib: "both",
39    min_sdk_version: "Tiramisu",
40
41    plugins: [
42        "auto_value_plugin",
43        "auto_annotation_plugin",
44    ],
45    static_libs: [
46        "androidx.concurrent_concurrent-futures",
47        "androidx.test.rules",
48        "compatibility-device-util-axt",
49        "truth",
50        "adservices-assets",
51        "adservices-service-core-schema",
52        "adservices-shared-testing",
53        "adservices-test-utility",
54        "androidx.room_room-runtime",
55        "androidx.room_room-testing",
56        "adservices-test-fixtures",
57        "mobile_data_downloader_lib",
58        "tflite_support_classifiers_java",
59        "opencensus-java-api",
60        "opencensus-java-contrib-grpc-metrics",
61        "gson",
62    ],
63    libs: [
64        "android.test.base.stubs.system",
65        "android.test.mock.stubs",
66        "framework-adservices.impl",
67        "framework-annotations-lib",
68        "framework-configinfrastructure.stubs.module_lib",
69        "framework-sdksandbox.impl",
70        "auto_value_annotations",
71    ],
72    test_suites: [
73        "general-tests",
74        "mts-adservices",
75    ],
76    instrumentation_for: "AdServicesApk",
77    jni_libs: [
78        "libhpke_jni",
79        "libtflite_support_classifiers_native",
80    ],
81    aaptflags: [
82        // avoid compression on lite and tflite files as the Interpreter
83        // can not load compressed flat buffer formats. (*appt compresses all
84        // assets into the apk by default)
85        // See https://elinux.org/Android_aapt for more detail.
86        "-0 .lite",
87        "-0 .tflite",
88    ],
89    lint: {
90        extra_check_modules: ["AdServicesTestLintChecker"],
91        baseline_filename: "lint-baseline-adservices.xml",
92        test: false, // TODO(b/343741206): remove when checks will run on android_test
93    },
94}
95
96android_test {
97    name: "AdExtServicesUIUnitTests",
98    srcs: [
99        "src/**/*.java",
100    ],
101    exclude_srcs: [
102        // The tests below are interacting with the JsSandbox singleton and should
103        // be run in a separate process
104        "src/com/android/adservices/service/js/JSScriptEngineTest.java",
105        "src/com/android/adservices/service/js/JavaScriptSandboxProviderTest.java",
106        // Exclude Mobile Data Download Test. This test need network connection and download files.
107        // This will run in a separate test suite.
108        "src/com/android/adservices/download/MobileDataDownloadTest.java",
109    ],
110    defaults: ["adservices-extended-mockito-defaults"],
111    sdk_version: "module_current",
112    // Currently this test module is failing, which results in low test coverage
113    // The reason is the target test coverage system runs on is different as what this test
114    // configures. Add below line to address the issue.
115    // See b/233124651 for details.
116    compile_multilib: "both",
117    min_sdk_version: "31",
118    max_sdk_version: "32",
119    static_libs: [
120        "adservices-assets",
121        "adservices-service-core-schema",
122        "adservices-shared-testing",
123        "adservices-test-fixtures",
124        "adservices-test-utility",
125        "androidx.concurrent_concurrent-futures",
126        "androidx.room_room-runtime",
127        "androidx.room_room-testing",
128        "androidx.test.rules",
129        "compatibility-device-util-axt",
130        "mobile_data_downloader_lib",
131        "opencensus-java-api",
132        "opencensus-java-contrib-grpc-metrics",
133        "tflite_support_classifiers_java",
134        "truth",
135        "gson",
136    ],
137    libs: [
138        "android.ext.adservices",
139        "android.test.base.stubs.system",
140        "android.test.mock.stubs",
141        "framework-annotations-lib",
142        "framework-configinfrastructure.stubs.module_lib",
143        "framework-sdksandbox.impl",
144    ],
145    test_suites: [
146        "general-tests",
147        "mts-extservices",
148    ],
149    test_config: "AndroidTest.ExtServices.xml",
150    instrumentation_for: "ExtServices-sminus",
151    jni_libs: [
152        "libhpke_jni",
153        "libtflite_support_classifiers_native",
154    ],
155    aaptflags: [
156        // avoid compression on lite and tflite files as the Interpreter
157        // can not load compressed flat buffer formats. (*appt compresses all
158        // assets into the apk by default)
159        // See https://elinux.org/Android_aapt for more detail.
160        "-0 .lite",
161        "-0 .tflite",
162    ],
163    lint: {
164        extra_check_modules: ["AdServicesTestLintChecker"],
165        baseline_filename: "lint-baseline-adextservices.xml",
166        test: false, // TODO(b/343741206): remove when checks will run on android_test
167    },
168}
169