blob: 3bbf1167090d4598b412a9907c173f7b76cb8e86 [file] [log] [blame]
Jared Duke51b0a102022-09-27 16:53:11 -07001// Copyright 2022 Google Inc. All rights reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package java
16
17import (
18 "testing"
19
20 "android/soong/android"
21)
22
23func TestShrinkResourcesArgs(t *testing.T) {
24 result := android.GroupFixturePreparers(
25 PrepareForTestWithJavaDefaultModules,
26 ).RunTestWithBp(t, `
27 android_app {
28 name: "app_shrink",
29 platform_apis: true,
30 optimize: {
31 shrink_resources: true,
32 }
33 }
34
35 android_app {
36 name: "app_no_shrink",
37 platform_apis: true,
38 optimize: {
39 shrink_resources: false,
40 }
41 }
42 `)
43
44 appShrink := result.ModuleForTests("app_shrink", "android_common")
45 appShrinkResources := appShrink.Rule("shrinkResources")
46 android.AssertStringDoesContain(t, "expected shrinker.xml in app_shrink resource shrinker flags",
47 appShrinkResources.Args["raw_resources"], "shrinker.xml")
48
49 appNoShrink := result.ModuleForTests("app_no_shrink", "android_common")
50 if appNoShrink.MaybeRule("shrinkResources").Rule != nil {
51 t.Errorf("unexpected shrinkResources rule for app_no_shrink")
52 }
53}