summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
authorLiz Kammer <eakammer@google.com>2020-08-04 09:55:13 -0700
committerLiz Kammer <eakammer@google.com>2020-08-04 09:55:13 -0700
commit3d894b728a83c244f120d39b065fae1d24ecb74b (patch)
treed851d083e934bad79c20f3e6a463643224001ff1 /java/java_test.go
parentbbec4c4325203295e8c9451bc6d3c9e7178a520e (diff)
Add property api_levels_jar_filename to droidstubs
The default is android.jar to maintain current behavior but allows users to specify a different filepath to support generating api-versions for docs other than the platform (e.g. auto). Bug: 162552181 Test: m doc Test: go test java_test Change-Id: I9e51abaf7d5451d68ca782157d9b739f76c5da82
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go56
1 files changed, 56 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go
index a3c78540f..50c40c38c 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1170,6 +1170,62 @@ func TestDroiddocArgsAndFlagsCausesError(t *testing.T) {
`)
}
+func TestDroidstubs(t *testing.T) {
+ ctx, _ := testJavaWithFS(t, `
+ droiddoc_exported_dir {
+ name: "droiddoc-templates-sdk",
+ path: ".",
+ }
+
+ droidstubs {
+ name: "bar-stubs",
+ srcs: [
+ "bar-doc/a.java",
+ ],
+ api_levels_annotations_dirs: [
+ "droiddoc-templates-sdk",
+ ],
+ api_levels_annotations_enabled: true,
+ }
+
+ droidstubs {
+ name: "bar-stubs-other",
+ srcs: [
+ "bar-doc/a.java",
+ ],
+ api_levels_annotations_dirs: [
+ "droiddoc-templates-sdk",
+ ],
+ api_levels_annotations_enabled: true,
+ api_levels_jar_filename: "android.other.jar",
+ }
+ `,
+ map[string][]byte{
+ "bar-doc/a.java": nil,
+ })
+ testcases := []struct {
+ moduleName string
+ expectedJarFilename string
+ }{
+ {
+ moduleName: "bar-stubs",
+ expectedJarFilename: "android.jar",
+ },
+ {
+ moduleName: "bar-stubs-other",
+ expectedJarFilename: "android.other.jar",
+ },
+ }
+ for _, c := range testcases {
+ m := ctx.ModuleForTests(c.moduleName, "android_common")
+ metalava := m.Rule("metalava")
+ expected := "--android-jar-pattern ./%/public/" + c.expectedJarFilename
+ if actual := metalava.RuleParams.Command; !strings.Contains(actual, expected) {
+ t.Errorf("For %q, expected metalava argument %q, but was not found %q", c.moduleName, expected, actual)
+ }
+ }
+}
+
func TestDroidstubsWithSystemModules(t *testing.T) {
ctx, _ := testJava(t, `
droidstubs {