summaryrefslogtreecommitdiff
path: root/java/rro_test.go
diff options
context:
space:
mode:
author Liana Kazanova <lkazanova@google.com> 2024-12-03 21:47:31 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-12-03 21:47:31 +0000
commite8ef6f1540ca7518e2e2998779b5f2d37b7a1479 (patch)
treeb687aa09570c734179b2e9dd82edbc8fe35f476d /java/rro_test.go
parentef56908c70ae9777388987857995fd6e6404fdf6 (diff)
Revert "Use soong built autogenerated RROs"
Revert submission 3362490-autogen_app_overlay Reason for revert: DroidMonitor: Potential culprit for http://b/382076898 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted. Reverted changes: /q/submissionid:3362490-autogen_app_overlay Change-Id: Ib3eb370625a4ab2cbf9a1337f82a1f0bc281a3a8
Diffstat (limited to 'java/rro_test.go')
-rw-r--r--java/rro_test.go97
1 files changed, 97 insertions, 0 deletions
diff --git a/java/rro_test.go b/java/rro_test.go
index 4d58bb498..4d791305e 100644
--- a/java/rro_test.go
+++ b/java/rro_test.go
@@ -255,6 +255,103 @@ func TestOverrideRuntimeResourceOverlay(t *testing.T) {
}
}
+func TestEnforceRRO_propagatesToDependencies(t *testing.T) {
+ testCases := []struct {
+ name string
+ enforceRROTargets []string
+ rroDirs map[string][]string
+ }{
+ {
+ name: "no RRO",
+ enforceRROTargets: nil,
+ rroDirs: map[string][]string{
+ "foo": nil,
+ "bar": nil,
+ },
+ },
+ {
+ name: "enforce RRO on all",
+ enforceRROTargets: []string{"*"},
+ rroDirs: map[string][]string{
+ "foo": {"product/vendor/blah/overlay/lib2/res"},
+ "bar": {"product/vendor/blah/overlay/lib2/res"},
+ },
+ },
+ {
+ name: "enforce RRO on foo",
+ enforceRROTargets: []string{"foo"},
+ rroDirs: map[string][]string{
+ "foo": {"product/vendor/blah/overlay/lib2/res"},
+ "bar": nil,
+ },
+ },
+ }
+
+ productResourceOverlays := []string{
+ "product/vendor/blah/overlay",
+ }
+
+ fs := android.MockFS{
+ "lib2/res/values/strings.xml": nil,
+ "product/vendor/blah/overlay/lib2/res/values/strings.xml": nil,
+ }
+
+ bp := `
+ android_app {
+ name: "foo",
+ sdk_version: "current",
+ resource_dirs: [],
+ static_libs: ["lib"],
+ }
+
+ android_app {
+ name: "bar",
+ sdk_version: "current",
+ resource_dirs: [],
+ static_libs: ["lib"],
+ }
+
+ android_library {
+ name: "lib",
+ sdk_version: "current",
+ resource_dirs: [],
+ static_libs: ["lib2"],
+ }
+
+ android_library {
+ name: "lib2",
+ sdk_version: "current",
+ resource_dirs: ["lib2/res"],
+ }
+ `
+
+ for _, testCase := range testCases {
+ t.Run(testCase.name, func(t *testing.T) {
+ result := android.GroupFixturePreparers(
+ PrepareForTestWithJavaDefaultModules,
+ fs.AddToFixture(),
+ android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
+ variables.ProductResourceOverlays = productResourceOverlays
+ if testCase.enforceRROTargets != nil {
+ variables.EnforceRROTargets = testCase.enforceRROTargets
+ }
+ }),
+ ).RunTestWithBp(t, bp)
+
+ modules := []string{"foo", "bar"}
+ for _, moduleName := range modules {
+ module := result.ModuleForTests(moduleName, "android_common")
+ mkEntries := android.AndroidMkEntriesForTest(t, result.TestContext, module.Module())[0]
+ actualRRODirs := mkEntries.EntryMap["LOCAL_SOONG_PRODUCT_RRO_DIRS"]
+ if !reflect.DeepEqual(actualRRODirs, testCase.rroDirs[moduleName]) {
+ t.Errorf("exected %s LOCAL_SOONG_PRODUCT_RRO_DIRS entry: %v\ngot:%q",
+ moduleName, testCase.rroDirs[moduleName], actualRRODirs)
+ }
+ }
+ })
+ }
+}
+
func TestRuntimeResourceOverlayPartition(t *testing.T) {
bp := `
runtime_resource_overlay {