diff options
| author | 2021-12-10 01:32:01 +0000 | |
|---|---|---|
| committer | 2021-12-10 01:32:01 +0000 | |
| commit | 6affb8f1eabe38349a765ec7c063969220f99f50 (patch) | |
| tree | d34ac9edc4ba7f03026c40d64d32529cc413804e /java/app_test.go | |
| parent | 643f93911afb52a91b1cc9f967825d77a6105e28 (diff) | |
| parent | b04b40c2e07d04d6b47ae1a19d528ae36f2aef4b (diff) | |
Merge "Set targetSdkVersion to 10000 iff a module is targeting an unreleased sdk" am: 2ee7ac02e7 am: a9938be03e am: c21325dd15 am: b04b40c2e0
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1914977
Change-Id: I44fde0c605bb23da64128b89eccd34f5eda42243
Diffstat (limited to 'java/app_test.go')
| -rw-r--r-- | java/app_test.go | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/java/app_test.go b/java/app_test.go index a6bb04baf..dbb57681c 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -2876,3 +2876,76 @@ func TestExportedProguardFlagFiles(t *testing.T) { t.Errorf("App does not use library proguard config") } } + +func TestTargetSdkVersionManifestFixer(t *testing.T) { + platform_sdk_codename := "Tiramisu" + testCases := []struct { + name string + targetSdkVersionInBp string + targetSdkVersionExpected string + unbundledBuild bool + }{ + { + name: "Non-Unbundled build: Android.bp has targetSdkVersion", + targetSdkVersionInBp: "30", + targetSdkVersionExpected: "30", + unbundledBuild: false, + }, + { + name: "Unbundled build: Android.bp has targetSdkVersion", + targetSdkVersionInBp: "30", + targetSdkVersionExpected: "30", + unbundledBuild: true, + }, + { + name: "Non-Unbundled build: Android.bp has targetSdkVersion equal to platform_sdk_codename", + targetSdkVersionInBp: platform_sdk_codename, + targetSdkVersionExpected: platform_sdk_codename, + unbundledBuild: false, + }, + { + name: "Unbundled build: Android.bp has targetSdkVersion equal to platform_sdk_codename", + targetSdkVersionInBp: platform_sdk_codename, + targetSdkVersionExpected: "10000", + unbundledBuild: true, + }, + + { + name: "Non-Unbundled build: Android.bp has no targetSdkVersion", + targetSdkVersionExpected: platform_sdk_codename, + unbundledBuild: false, + }, + { + name: "Unbundled build: Android.bp has no targetSdkVersion", + targetSdkVersionExpected: "10000", + unbundledBuild: true, + }, + } + for _, testCase := range testCases { + bp := fmt.Sprintf(` + android_app { + name: "foo", + sdk_version: "current", + target_sdk_version: "%v", + } + `, testCase.targetSdkVersionInBp) + fixture := android.GroupFixturePreparers( + prepareForJavaTest, + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + // explicitly set platform_sdk_codename to make the test deterministic + variables.Platform_sdk_codename = &platform_sdk_codename + variables.Platform_version_active_codenames = []string{platform_sdk_codename} + // create a non-empty list if unbundledBuild==true + if testCase.unbundledBuild { + variables.Unbundled_build_apps = []string{"apex_a", "apex_b"} + } + }), + ) + + result := fixture.RunTestWithBp(t, bp) + foo := result.ModuleForTests("foo", "android_common") + + manifestFixerArgs := foo.Output("manifest_fixer/AndroidManifest.xml").Args + android.AssertStringEquals(t, testCase.name, testCase.targetSdkVersionExpected, manifestFixerArgs["targetSdkVersion"]) + } +} |