diff options
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 61b718d00..11556b05c 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -4798,3 +4798,76 @@ override_android_app { android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, overrideVendorOverlayApk.Rule != nil) } } + +func TestNoAutogeneratedStaticRroForDisabledOverrideApps(t *testing.T) { + t.Parallel() + bp := ` +soong_config_module_type { + name: "my_custom_override_android_app", + module_type: "override_android_app", + config_namespace: "my_namespace", + value_variables: ["my_app_enabled"], + properties: ["enabled"], +} +soong_config_bool_variable { + name: "my_app_enabled", +} +android_app { + name: "foo", + srcs: ["foo.java"], + platform_apis: true, +} +my_custom_override_android_app { + name: "override_foo", + base: "foo", + soong_config_variables: { + my_app_enabled: { + enabled: true, + conditions_default: { + enabled: false + }, + }, + } +} +` + testCases := []struct { + desc string + preparer android.FixturePreparer + overlayApkExpected bool + }{ + { + desc: "my_app_enabled is empty", + overlayApkExpected: false, + }, + { + desc: "my_app_enabled is true", + overlayApkExpected: true, + preparer: android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.VendorVars = map[string]map[string]string{ + "my_namespace": { + "my_app_enabled": "true", + }, + } + }), + }, + } + for _, tc := range testCases { + result := android.GroupFixturePreparers( + PrepareForTestWithJavaDefaultModules, + android.PrepareForTestWithSoongConfigModuleBuildComponents, + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.EnforceRROTargets = []string{"*"} + }), + android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { + variables.DeviceResourceOverlays = []string{"device/company/test_product"} + }), + android.MockFS{ + "res/foo.xml": nil, + "device/company/test_product/res/foo.xml": nil, + }.AddToFixture(), + android.OptionalFixturePreparer(tc.preparer), + ).RunTestWithBp(t, bp) + overrideVendorOverlayApk := result.ModuleForTests("override_foo__test_product__auto_generated_rro_vendor", "android_arm64_armv8-a").Module().(*AutogenRuntimeResourceOverlay) + android.AssertBoolEquals(t, tc.desc, tc.overlayApkExpected, overrideVendorOverlayApk.exportPackage != nil) + } +} |