xref: /aosp_15_r20/frameworks/base/ravenwood/tools/hoststubgen/test-tiny-framework/Android.bp (revision d57664e9bc4670b3ecf6748a746a57c557b6bc9e)
1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "frameworks_base_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-Apache-2.0
7    default_applicable_licenses: ["frameworks_base_license"],
8}
9
10// A library that simulates framework-all.jar
11java_library {
12    name: "hoststubgen-test-tiny-framework",
13    installable: true,
14    host_supported: true,
15    srcs: ["tiny-framework/src/**/*.java"],
16    static_libs: [
17        "hoststubgen-annotations",
18    ],
19    visibility: ["//frameworks/base/ravenwood/tools/hoststubgen:__subpackages__"],
20}
21
22// Create stub/impl jars from "hoststubgen-test-tiny-framework", using the following 3 rules.
23java_genrule_host {
24    name: "hoststubgen-test-tiny-framework-host-base",
25    defaults: ["hoststubgen-command-defaults"],
26    cmd: hoststubgen_common_options +
27        "--in-jar $(location :hoststubgen-test-tiny-framework) " +
28        "--policy-override-file $(location policy-override-tiny-framework.txt) " +
29        "--package-redirect com.unsupported:com.supported ",
30    srcs: [
31        ":hoststubgen-test-tiny-framework",
32        "policy-override-tiny-framework.txt",
33    ],
34    visibility: ["//visibility:private"],
35}
36
37java_genrule_host {
38    name: "hoststubgen-test-tiny-framework-host",
39    cmd: "cp $(in) $(out)",
40    srcs: [
41        ":hoststubgen-test-tiny-framework-host-base{host.jar}",
42    ],
43    out: [
44        "host.jar",
45    ],
46    visibility: ["//visibility:private"],
47}
48
49// Same as "hoststubgen-test-tiny-framework-host", but with more options, to test more hoststubgen
50// features.
51java_genrule_host {
52    name: "hoststubgen-test-tiny-framework-host-ext-base",
53    defaults: ["hoststubgen-command-defaults"],
54    cmd: hoststubgen_common_options +
55        "--in-jar $(location :hoststubgen-test-tiny-framework) " +
56        "--policy-override-file $(location policy-override-tiny-framework.txt) " +
57        "--package-redirect com.unsupported:com.supported " +
58
59        // More options.
60        "--default-method-call-hook com.android.hoststubgen.hosthelper.HostTestUtils.logMethodCall " +
61        "--default-class-load-hook com.android.hoststubgen.hosthelper.HostTestUtils.logClassLoaded ",
62    srcs: [
63        ":hoststubgen-test-tiny-framework",
64        "policy-override-tiny-framework.txt",
65    ],
66    visibility: ["//visibility:private"],
67}
68
69java_genrule_host {
70    name: "hoststubgen-test-tiny-framework-host-ext",
71    cmd: "cp $(in) $(out)",
72    srcs: [
73        ":hoststubgen-test-tiny-framework-host-ext-base{host.jar}",
74    ],
75    out: [
76        "host.jar",
77    ],
78    visibility: ["//visibility:private"],
79}
80
81// Compile the test jar, using 2 rules.
82// 1. Build the test against the original framework.
83java_library_host {
84    name: "hoststubgen-test-tiny-test-lib",
85    srcs: ["tiny-test/src/**/*.java"],
86
87    libs: [
88        "hoststubgen-test-tiny-framework",
89    ],
90    static_libs: [
91        "junit",
92        "truth",
93
94        // http://cs/h/googleplex-android/platform/superproject/main/+/main:platform_testing/libraries/annotations/src/android/platform/test/annotations/
95        "platform-test-annotations",
96    ],
97    visibility: ["//visibility:private"],
98}
99
100// 2. Link "hoststubgen-test-tiny-test-lib" with necessary runtime dependencies, so it can be
101// executed stand-alone.
102java_test_host {
103    name: "hoststubgen-test-tiny-test",
104    test_config: "AndroidTest-host.xml",
105    static_libs: [
106        "hoststubgen-test-tiny-test-lib",
107        "hoststubgen-helper-runtime",
108        "hoststubgen-test-tiny-framework-host",
109    ],
110    test_suites: ["general-tests"],
111}
112
113// Dump the original, stub and impl jars as text files.
114// We use them in test-and-update-golden.sh.
115java_genrule_host {
116    name: "hoststubgen-test-tiny-framework-orig-dump",
117    defaults: ["hoststubgen-jar-dump-defaults"],
118    srcs: [
119        ":hoststubgen-test-tiny-framework",
120    ],
121    out: [
122        "01-hoststubgen-test-tiny-framework-orig-dump.txt",
123    ],
124    visibility: ["//visibility:private"],
125}
126
127java_genrule_host {
128    name: "hoststubgen-test-tiny-framework-host-dump",
129    defaults: ["hoststubgen-jar-dump-defaults"],
130    srcs: [
131        ":hoststubgen-test-tiny-framework-host",
132    ],
133    out: [
134        "03-hoststubgen-test-tiny-framework-host-dump.txt",
135    ],
136    visibility: ["//visibility:private"],
137}
138
139java_genrule_host {
140    name: "hoststubgen-test-tiny-framework-host-ext-dump",
141    defaults: ["hoststubgen-jar-dump-defaults"],
142    srcs: [
143        ":hoststubgen-test-tiny-framework-host-ext",
144    ],
145    out: [
146        "13-hoststubgen-test-tiny-framework-host-ext-dump.txt",
147    ],
148    visibility: ["//visibility:private"],
149}
150
151// Run it with `atest`. Compare the dump of the jar files to the golden output.
152python_test_host {
153    name: "tiny-framework-dump-test",
154    srcs: [
155        "tiny-framework-dump-test.py",
156    ],
157    data: [
158        "golden-output/*.txt",
159        "golden-output.RELEASE_TARGET_JAVA_21/*.txt",
160    ],
161    java_data: [
162        "hoststubgen-test-tiny-framework-orig-dump",
163        "hoststubgen-test-tiny-framework-host-dump",
164        "hoststubgen-test-tiny-framework-host-ext-dump",
165    ],
166    test_suites: ["general-tests"],
167}
168