Check updatable APKs compile against managed SDKs.
As a follow up, this property will be set to APKs participating in mainline program.
Bug: 153333044
Test: m
Change-Id: I6ea2f3c1d26992259e4e9e6a6d8cecf091d39c43
diff --git a/java/app_test.go b/java/app_test.go
index 43696db..7b04e46 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -264,6 +264,108 @@
`)
}
+func TestUpdatableApps(t *testing.T) {
+ testCases := []struct {
+ name string
+ bp string
+ expectedError string
+ }{
+ {
+ name: "Stable public SDK",
+ bp: `android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "29",
+ updatable: true,
+ }`,
+ },
+ {
+ name: "Stable system SDK",
+ bp: `android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "system_29",
+ updatable: true,
+ }`,
+ },
+ {
+ name: "Current public SDK",
+ bp: `android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "current",
+ updatable: true,
+ }`,
+ },
+ {
+ name: "Current system SDK",
+ bp: `android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "system_current",
+ updatable: true,
+ }`,
+ },
+ {
+ name: "Current module SDK",
+ bp: `android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "module_current",
+ updatable: true,
+ }`,
+ },
+ {
+ name: "Current core SDK",
+ bp: `android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "core_current",
+ updatable: true,
+ }`,
+ },
+ {
+ name: "No Platform APIs",
+ bp: `android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ platform_apis: true,
+ updatable: true,
+ }`,
+ expectedError: "Updatable apps must use stable SDKs",
+ },
+ {
+ name: "No Core Platform APIs",
+ bp: `android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ sdk_version: "core_platform",
+ updatable: true,
+ }`,
+ expectedError: "Updatable apps must use stable SDKs",
+ },
+ {
+ name: "No unspecified APIs",
+ bp: `android_app {
+ name: "foo",
+ srcs: ["a.java"],
+ updatable: true,
+ }`,
+ expectedError: "Updatable apps must use stable SDK",
+ },
+ }
+
+ for _, test := range testCases {
+ t.Run(test.name, func(t *testing.T) {
+ if test.expectedError == "" {
+ testJava(t, test.bp)
+ } else {
+ testJavaError(t, test.expectedError, test.bp)
+ }
+ })
+ }
+}
+
func TestResourceDirs(t *testing.T) {
testCases := []struct {
name string