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
This commit is contained in:
@@ -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",
|
||||
}, matches)
|
||||
}, 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",
|
||||
}, patterns)
|
||||
}
|
||||
|
||||
func TestDroidstubsSandbox(t *testing.T) {
|
||||
|
Reference in New Issue
Block a user