aboutsummaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2023-09-18 22:23:33 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-09-18 22:23:33 +0000
commite50b0f55583123471ef00d0d148c5079837a41d4 (patch)
tree07a6f62d3e438965912392f3965a28b1f7de009e /java/java_test.go
parent8c04f3fd7a6ef7918c956cd67d40dcff26df98da (diff)
parent8fe1982e8bf6728b2f7d1de7380d9a2f86556fbe (diff)
Merge changes I8466db71,I83180699 into main
* changes: Sort api files by api surface in java_api_library Add java_api_contribution_import module type
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go43
1 files changed, 39 insertions, 4 deletions
diff --git a/java/java_test.go b/java/java_test.go
index 27933c3bf..2ee05ec73 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1865,11 +1865,13 @@ func TestJavaApiLibraryAndProviderLink(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
ctx, _ := testJavaWithFS(t, `
@@ -1919,24 +1921,28 @@ func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_c := `
java_api_contribution {
name: "foo3",
- api_file: "current.txt",
+ api_file: "system-current.txt",
+ api_surface: "system",
}
`
provider_bp_d := `
java_api_contribution {
name: "foo4",
- api_file: "current.txt",
+ api_file: "system-current.txt",
+ api_surface: "system",
}
`
ctx, _ := testJavaWithFS(t, `
@@ -1992,8 +1998,9 @@ func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
sourceTextFileDirs: []string{"a/current.txt", "b/current.txt"},
},
{
- moduleName: "bar3",
- sourceTextFileDirs: []string{"c/current.txt", "a/current.txt", "b/current.txt", "d/current.txt", "api1/current.txt", "api2/current.txt"},
+ moduleName: "bar3",
+ // API text files need to be sorted from the narrower api scope to the wider api scope
+ sourceTextFileDirs: []string{"a/current.txt", "b/current.txt", "api1/current.txt", "api2/current.txt", "c/system-current.txt", "d/system-current.txt"},
},
}
for _, c := range testcases {
@@ -2011,12 +2018,14 @@ func TestJavaApiLibraryJarGeneration(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
ctx, _ := testJavaWithFS(t, `
@@ -2064,12 +2073,14 @@ func TestJavaApiLibraryLibsLink(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
lib_bp_a := `
@@ -2139,12 +2150,14 @@ func TestJavaApiLibraryStaticLibsLink(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
lib_bp_a := `
@@ -2213,12 +2226,14 @@ func TestJavaApiLibraryFullApiSurfaceStub(t *testing.T) {
java_api_contribution {
name: "foo1",
api_file: "current.txt",
+ api_surface: "public",
}
`
provider_bp_b := `
java_api_contribution {
name: "foo2",
api_file: "current.txt",
+ api_surface: "public",
}
`
lib_bp_a := `
@@ -2388,3 +2403,23 @@ func TestHeadersOnly(t *testing.T) {
javac := ctx.ModuleForTests("foo", "android_common").MaybeRule("javac")
android.AssertDeepEquals(t, "javac rule", nil, javac.Rule)
}
+
+func TestJavaApiContributionImport(t *testing.T) {
+ ctx, _ := testJava(t, `
+ java_api_library {
+ name: "foo",
+ api_contributions: ["bar"],
+ }
+ java_api_contribution_import {
+ name: "bar",
+ api_file: "current.txt",
+ api_surface: "public",
+ }
+ `)
+ m := ctx.ModuleForTests("foo", "android_common")
+ manifest := m.Output("metalava.sbox.textproto")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, manifest)
+ manifestCommand := sboxProto.Commands[0].GetCommand()
+ sourceFilesFlag := "--source-files current.txt"
+ android.AssertStringDoesContain(t, "source text files not present", manifestCommand, sourceFilesFlag)
+}