summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
author Jihoon Kang <jihoonkang@google.com> 2023-01-24 18:08:49 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2023-01-24 18:08:49 +0000
commit6cf5e0d9cb89b909b5087d4057e6f09e4d093f85 (patch)
treed5cd44b3dbf126600fed3aef42396e48b0bd8293 /java/java_test.go
parent6f0aef34e81eb582c489285187253873b8a1e0af (diff)
parent362aa9db1236f6cf09a01c6295b2f401fc483d7c (diff)
Merge "Add libs property to java_api_library module"
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go90
1 files changed, 85 insertions, 5 deletions
diff --git a/java/java_test.go b/java/java_test.go
index 49adefbde..ae77842a5 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1895,22 +1895,26 @@ func TestJavaApiLibraryAndProviderLink(t *testing.T) {
}
func TestJavaApiLibraryAndDefaultsLink(t *testing.T) {
- provider_bp_a := `java_api_contribution {
+ provider_bp_a := `
+ java_api_contribution {
name: "foo1",
api_file: "foo1.txt",
}
`
- provider_bp_b := `java_api_contribution {
+ provider_bp_b := `
+ java_api_contribution {
name: "foo2",
api_file: "foo2.txt",
}
`
- provider_bp_c := `java_api_contribution {
+ provider_bp_c := `
+ java_api_contribution {
name: "foo3",
api_file: "foo3.txt",
}
`
- provider_bp_d := `java_api_contribution {
+ provider_bp_d := `
+ java_api_contribution {
name: "foo4",
api_file: "foo4.txt",
}
@@ -1989,7 +1993,8 @@ func TestJavaApiLibraryJarGeneration(t *testing.T) {
api_file: "foo1.txt",
}
`
- provider_bp_b := `java_api_contribution {
+ provider_bp_b := `
+ java_api_contribution {
name: "foo2",
api_file: "foo2.txt",
}
@@ -2034,6 +2039,81 @@ func TestJavaApiLibraryJarGeneration(t *testing.T) {
}
}
+func TestJavaApiLibraryLibsLink(t *testing.T) {
+ provider_bp_a := `
+ java_api_contribution {
+ name: "foo1",
+ api_file: "foo1.txt",
+ }
+ `
+ provider_bp_b := `
+ java_api_contribution {
+ name: "foo2",
+ api_file: "foo2.txt",
+ }
+ `
+ lib_bp_a := `
+ java_library {
+ name: "lib1",
+ srcs: ["Lib.java"],
+ }
+ `
+ lib_bp_b := `
+ java_library {
+ name: "lib2",
+ srcs: ["Lib.java"],
+ }
+ `
+
+ ctx, _ := testJavaWithFS(t, `
+ java_api_library {
+ name: "bar1",
+ api_surface: "public",
+ api_contributions: ["foo1"],
+ libs: ["lib1"],
+ }
+
+ java_api_library {
+ name: "bar2",
+ api_surface: "system",
+ api_contributions: ["foo1", "foo2"],
+ libs: ["lib1", "lib2", "bar1"],
+ }
+ `,
+ map[string][]byte{
+ "a/Android.bp": []byte(provider_bp_a),
+ "b/Android.bp": []byte(provider_bp_b),
+ "c/Android.bp": []byte(lib_bp_a),
+ "c/Lib.java": {},
+ "d/Android.bp": []byte(lib_bp_b),
+ "d/Lib.java": {},
+ })
+
+ testcases := []struct {
+ moduleName string
+ classPathJarNames []string
+ }{
+ {
+ moduleName: "bar1",
+ classPathJarNames: []string{"lib1.jar"},
+ },
+ {
+ moduleName: "bar2",
+ classPathJarNames: []string{"lib1.jar", "lib2.jar", "bar1/android.jar"},
+ },
+ }
+ for _, c := range testcases {
+ m := ctx.ModuleForTests(c.moduleName, "android_common")
+ javacRules := m.Rule("javac")
+ classPathArgs := javacRules.Args["classpath"]
+ for _, jarName := range c.classPathJarNames {
+ if !strings.Contains(classPathArgs, jarName) {
+ t.Errorf("Module output does not contain expected jar %s", jarName)
+ }
+ }
+ }
+}
+
func TestTradefedOptions(t *testing.T) {
result := PrepareForTestWithJavaBuildComponents.RunTestWithBp(t, `
java_test_host {