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
Merged-In: I6ea2f3c1d26992259e4e9e6a6d8cecf091d39c43
(cherry picked from commit 2db1c3f1c4)
Exempt-From-Owner-Approval: clean cherry-pick
This commit is contained in:
Artur Satayev
2020-04-08 19:09:30 +01:00
parent ee42b2079d
commit e5ac15a1b7
4 changed files with 154 additions and 13 deletions

View File

@@ -264,6 +264,108 @@ func TestAndroidAppLinkType(t *testing.T) {
`)
}
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