diff options
author | Colin Cross <ccross@android.com> | 2019-02-07 15:30:01 -0800 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2019-02-08 00:24:01 +0000 |
commit | 0ddae7fddd510b514f39a7f476f053ece7b420ea (patch) | |
tree | 9f11f0c9f7143ff7c981529d3cfc2aec2ed28828 /java/app_test.go | |
parent | 7cf14099b70241950e813fd9196a0b3f2cc4e981 (diff) | |
download | android_build_soong-0ddae7fddd510b514f39a7f476f053ece7b420ea.tar.gz android_build_soong-0ddae7fddd510b514f39a7f476f053ece7b420ea.tar.bz2 android_build_soong-0ddae7fddd510b514f39a7f476f053ece7b420ea.zip |
Allow disabling implicit resource_dirs and asset_dirs
Specifying [] for resource_dirs or asset_dirs will prevent using
the default "res" or "assets" directories.
Test: TestResourceDirs
Bug: 124035856
Change-Id: I96e38ac1319260db43950299a8b1774da68ea85e
Diffstat (limited to 'java/app_test.go')
-rw-r--r-- | java/app_test.go | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/java/app_test.go b/java/app_test.go index 93d20d09..103f24bd 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -106,6 +106,64 @@ func TestApp(t *testing.T) { } } +func TestResourceDirs(t *testing.T) { + testCases := []struct { + name string + prop string + resources []string + }{ + { + name: "no resource_dirs", + prop: "", + resources: []string{"res/res/values/strings.xml"}, + }, + { + name: "resource_dirs", + prop: `resource_dirs: ["res"]`, + resources: []string{"res/res/values/strings.xml"}, + }, + { + name: "empty resource_dirs", + prop: `resource_dirs: []`, + resources: nil, + }, + } + + fs := map[string][]byte{ + "res/res/values/strings.xml": nil, + } + + bp := ` + android_app { + name: "foo", + %s + } + ` + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + config := testConfig(nil) + ctx := testContext(config, fmt.Sprintf(bp, testCase.prop), fs) + run(t, ctx, config) + + module := ctx.ModuleForTests("foo", "android_common") + resourceList := module.MaybeOutput("aapt2/res.list") + + var resources []string + if resourceList.Rule != nil { + for _, compiledResource := range resourceList.Inputs.Strings() { + resources = append(resources, module.Output(compiledResource).Inputs.Strings()...) + } + } + + if !reflect.DeepEqual(resources, testCase.resources) { + t.Errorf("expected resource files %q, got %q", + testCase.resources, resources) + } + }) + } +} + func TestEnforceRRO(t *testing.T) { testCases := []struct { name string |