summaryrefslogtreecommitdiff
path: root/java/droidstubs_test.go
diff options
context:
space:
mode:
author Pedro Loureiro <pedroql@google.com> 2021-10-04 17:24:00 +0000
committer Pedro Loureiro <pedroql@google.com> 2021-10-05 15:40:46 +0000
commitcc203505b9915a5597c52fae405378ea8938d083 (patch)
tree8d9092e7470880a0dc364ece25540d27da232c9d /java/droidstubs_test.go
parent2df9ebf9cae3cb160926816548882c7f7db2e39d (diff)
Add module-lib to droidstubs' supported sdk types
If the android.jar is not found in the module-lib folder, it falls back to searching it in the system folder and then falls back on the public folder. This only brings the functionality, we are not yet using it. Test: m nothing Bug: 202023154 Change-Id: I99c9004740c8e51faf53ebc3ba2444e8164215f3
Diffstat (limited to 'java/droidstubs_test.go')
-rw-r--r--java/droidstubs_test.go42
1 files changed, 36 insertions, 6 deletions
diff --git a/java/droidstubs_test.go b/java/droidstubs_test.go
index 60d0bea5d..10d99f3a5 100644
--- a/java/droidstubs_test.go
+++ b/java/droidstubs_test.go
@@ -15,6 +15,7 @@
package java
import (
+ "fmt"
"reflect"
"regexp"
"strings"
@@ -82,8 +83,10 @@ func TestDroidstubs(t *testing.T) {
}
}
-func TestSystemDroidstubs(t *testing.T) {
- ctx, _ := testJavaWithFS(t, `
+// runs a test for droidstubs with a customizable sdkType argument and returns
+// the list of jar patterns that is passed as `--android-jar-pattern`
+func getAndroidJarPatternsForDroidstubs(t *testing.T, sdkType string) []string {
+ ctx, _ := testJavaWithFS(t, fmt.Sprintf(`
droiddoc_exported_dir {
name: "some-exported-dir",
path: "somedir",
@@ -102,9 +105,9 @@ func TestSystemDroidstubs(t *testing.T) {
"some-other-exported-dir",
],
api_levels_annotations_enabled: true,
- api_levels_sdk_type: "system",
+ api_levels_sdk_type: "%s",
}
- `,
+ `, sdkType),
map[string][]byte{
"foo-doc/a.java": nil,
})
@@ -113,13 +116,40 @@ func TestSystemDroidstubs(t *testing.T) {
manifest := m.Output("metalava.sbox.textproto")
cmd := String(android.RuleBuilderSboxProtoForTests(t, manifest).Commands[0].Command)
r := regexp.MustCompile(`--android-jar-pattern [^ ]+/android.jar`)
- matches := r.FindAllString(cmd, -1)
+ return r.FindAllString(cmd, -1)
+}
+
+func TestPublicDroidstubs(t *testing.T) {
+ patterns := getAndroidJarPatternsForDroidstubs(t, "public")
+
+ android.AssertArrayString(t, "order of patterns", []string{
+ "--android-jar-pattern somedir/%/public/android.jar",
+ "--android-jar-pattern someotherdir/%/public/android.jar",
+ }, patterns)
+}
+
+func TestSystemDroidstubs(t *testing.T) {
+ patterns := getAndroidJarPatternsForDroidstubs(t, "system")
+
+ android.AssertArrayString(t, "order of patterns", []string{
+ "--android-jar-pattern somedir/%/system/android.jar",
+ "--android-jar-pattern someotherdir/%/system/android.jar",
+ "--android-jar-pattern somedir/%/public/android.jar",
+ "--android-jar-pattern someotherdir/%/public/android.jar",
+ }, patterns)
+}
+
+func TestModuleLibDroidstubs(t *testing.T) {
+ patterns := getAndroidJarPatternsForDroidstubs(t, "module-lib")
+
android.AssertArrayString(t, "order of patterns", []string{
+ "--android-jar-pattern somedir/%/module-lib/android.jar",
+ "--android-jar-pattern someotherdir/%/module-lib/android.jar",
"--android-jar-pattern somedir/%/system/android.jar",
"--android-jar-pattern someotherdir/%/system/android.jar",
"--android-jar-pattern somedir/%/public/android.jar",
"--android-jar-pattern someotherdir/%/public/android.jar",
- }, matches)
+ }, patterns)
}
func TestDroidstubsSandbox(t *testing.T) {