summaryrefslogtreecommitdiff
path: root/java/droidstubs_test.go
diff options
context:
space:
mode:
author Anton Hansson <hansson@google.com> 2022-05-09 09:30:26 +0000
committer Anton Hansson <hansson@google.com> 2022-05-09 12:18:17 +0000
commitc04a16ef0b5a2a7acd82b36b3210411bc336d3b6 (patch)
treeeec72a3bb1b863ca1a511a08fd0b99787eb0df57 /java/droidstubs_test.go
parentea17a45c262d7ddb4eb78ea424c29e9833d17c66 (diff)
Support using api-versions.xml from another module
Metalava has two different flags surrounding api-levels: - one for generating api-versions.xml to a file - one for applying api-versions.xml from a file Previously, soong always applied both of these arguments at the same time, such that framework-doc-stubs both generated and applied api-versions.xml. Add support for using api-versions.xml from another module name as well. Bug: 187398174 Test: droidstubs_test.go Change-Id: I8288fe4788336d5d5c60d09d48b00ca111449fba
Diffstat (limited to 'java/droidstubs_test.go')
-rw-r--r--java/droidstubs_test.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 10d99f3a5..9fdfddeb1 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -46,6 +46,12 @@ func TestDroidstubs(t *testing.T) {
api_levels_annotations_enabled: true,
api_levels_jar_filename: "android.other.jar",
}
+
+ droidstubs {
+ name: "stubs-applying-api-versions",
+ srcs: ["bar-doc/a.java"],
+ api_levels_module: "bar-stubs-other",
+ }
`,
map[string][]byte{
"bar-doc/a.java": nil,
@@ -53,26 +59,37 @@ func TestDroidstubs(t *testing.T) {
testcases := []struct {
moduleName string
expectedJarFilename string
+ generate_xml bool
high_mem bool
}{
{
moduleName: "bar-stubs",
+ generate_xml: true,
expectedJarFilename: "android.jar",
high_mem: false,
},
{
moduleName: "bar-stubs-other",
+ generate_xml: true,
expectedJarFilename: "android.other.jar",
high_mem: true,
},
+ {
+ moduleName: "stubs-applying-api-versions",
+ generate_xml: false,
+ },
}
for _, c := range testcases {
m := ctx.ModuleForTests(c.moduleName, "android_common")
manifest := m.Output("metalava.sbox.textproto")
sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
- expected := "--android-jar-pattern ./%/public/" + c.expectedJarFilename
- if actual := String(sboxProto.Commands[0].Command); !strings.Contains(actual, expected) {
- t.Errorf("For %q, expected metalava argument %q, but was not found %q", c.moduleName, expected, actual)
+ cmdline := String(sboxProto.Commands[0].Command)
+ android.AssertStringContainsEquals(t, "api-versions generation flag", cmdline, "--generate-api-levels", c.generate_xml)
+ if c.expectedJarFilename != "" {
+ expected := "--android-jar-pattern ./%/public/" + c.expectedJarFilename
+ if !strings.Contains(cmdline, expected) {
+ t.Errorf("For %q, expected metalava argument %q, but was not found %q", c.moduleName, expected, cmdline)
+ }
}
metalava := m.Rule("metalava")