1// Copyright (C) 2023 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.
14
15package {
16    default_applicable_licenses: ["Android-Apache-2.0"],
17}
18
19filegroup {
20    name: "adservices-test-utility-sources",
21    srcs: [
22        "java/**/*.java",
23    ],
24    exclude_srcs: [
25        "java/com/android/adservices/mockito/*.java",
26    ],
27    path: "java",
28    visibility: [
29        "//packages/modules/AdServices:__subpackages__",
30    ],
31}
32
33// Java classes that are used by both device-side and host-side tests
34filegroup {
35    name: "adservices-test-utility-sideless-sources",
36    srcs: [
37        "side-less/**/*.java",
38    ],
39    path: "side-less",
40    visibility: [
41        ":__pkg__",
42    ],
43}
44
45android_library {
46    name: "adservices-test-utility",
47    sdk_version: "module_current",
48    min_sdk_version: "30",
49    srcs: [
50        ":adservices-test-utility-sideless-sources",
51        ":adservices-test-utility-sources",
52        ":adservices-service-core-phflags-sources",
53        // TODO(b/345219434): should use java-defaults instead of manually including
54        // the 2 sources below
55        ":adservices-extended-mockito-rule-sources",
56        ":adservices-shared-extended-mockito-rule-sources",
57    ],
58    libs: [
59        "error_prone_annotations",
60        "framework-adservices-lib",
61        "framework-annotations-lib",
62        "framework-configinfrastructure",
63        "junit",
64    ],
65    static_libs: [
66        "auto_value_annotations",
67        // TODO(b/338132355): Clean up dependencies for adservices-test-utility.
68        "adservices-service-core",
69        "adservices-shared-mockito-expectations", // TODO(b/338132355): should not be needed if mocker is split
70        "adservices-shared-testing",
71        "androidx.test.runner",
72        "compatibility-device-util-axt",
73        "modules-utils-preconditions",
74        "adservices-shared-util", // For checkState method uses varargs.
75        "adservices-clients",
76        // TODO(b/345219434): remove dependency below (and/or replace it by
77        // modules-utils-extended-mockito-rule) and move it to test projects
78        // instead (as it's only needed by tests that uses the static fixture)
79        "modules-utils-testable-device-config",
80        // TODO(b/345219434): should use java-defaults instead of manually including
81        "adservices-shared-static-class-checker",
82    ],
83    apex_available: [
84        "com.android.adservices",
85        "com.android.extservices",
86    ],
87    visibility: [
88        "//packages/modules/AdServices:__subpackages__",
89        "//vendor:__subpackages__", // used by some integration tests
90    ],
91    lint: {
92        extra_check_modules: ["AdServicesTestLintChecker"],
93    },
94    plugins: ["auto_annotation_plugin"],
95}
96
97android_library {
98    name: "adservices-test-mockito-expectations",
99    sdk_version: "module_current",
100    min_sdk_version: "30",
101    srcs: [
102        "java/com/android/adservices/mockito/*MockitoExpectations.java",
103        ":adservices-service-core-phflags-sources",
104    ],
105    libs: [
106        "framework-adservices-lib",
107        "framework-annotations-lib",
108        "framework-configinfrastructure",
109    ],
110    static_libs: [
111        "adservices-service-core",
112        "adservices-shared-testing",
113        "adservices-test-utility",
114        "mockito-target-extended-minus-junit4",
115        "truth",
116    ],
117    apex_available: [
118        "com.android.adservices",
119        "com.android.extservices",
120    ],
121    lint: {
122        extra_check_modules: ["AdServicesTestLintChecker"],
123    },
124}
125
126java_library_host {
127    name: "adservices-host-side-test-utility",
128    srcs: [
129        "host-side/**/*.java",
130        ":adservices-service-core-flags-constants-sources",
131        ":adservices-test-utility-sideless-sources",
132    ],
133    static_libs: [
134        "compatibility-host-util",
135        "adservices-shared-hostside-testing",
136    ],
137    libs: [
138        "tradefed",
139        "framework-annotations-lib",
140    ],
141}
142
143// TODO(b/338132355): remove / split / create new lib for expectations
144filegroup {
145    name: "adservices-extended-mockito-rule-sources",
146    srcs: [
147        "java/com/android/adservices/mockito/AdServicesStaticMockitoMocker.java",
148        "java/com/android/adservices/mockito/AdServicesExtendedMockitoMocker.java",
149    ],
150    path: "java",
151    visibility: [
152        "//packages/modules/AdServices:__subpackages__",
153    ],
154}
155
156java_defaults {
157    name: "adservices-extended-mockito-defaults",
158    srcs: [
159        ":adservices-extended-mockito-rule-sources",
160    ],
161    defaults: ["adservices-shared-extended-mockito-defaults"],
162    static_libs: [
163        "adservices-service-core",
164        "modules-utils-testable-device-config", // For TestableDeviceConfig
165    ],
166    visibility: [
167        "//packages/modules/AdServices:__subpackages__",
168    ],
169}
170