Move TestEnforceRRO test cases into test function
The test cases will need to reference buildDir, which is not yet set at global variable initialization time. Bug: 123510624 Test: TestEnforceRRO Change-Id: I0dda0184dfab496c820e11ed76b7594a60d5d587
This commit is contained in:
committed by
Anton Hansson
parent
cc2d11961c
commit
5c4791c71e
124
java/app_test.go
124
java/app_test.go
@@ -106,68 +106,68 @@ func TestApp(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
var testEnforceRROTests = []struct {
|
||||
name string
|
||||
enforceRROTargets []string
|
||||
enforceRROExcludedOverlays []string
|
||||
overlayFiles map[string][]string
|
||||
rroDirs map[string][]string
|
||||
}{
|
||||
{
|
||||
name: "no RRO",
|
||||
enforceRROTargets: nil,
|
||||
enforceRROExcludedOverlays: nil,
|
||||
overlayFiles: map[string][]string{
|
||||
"foo": []string{
|
||||
"device/vendor/blah/static_overlay/foo/res/values/strings.xml",
|
||||
"device/vendor/blah/overlay/foo/res/values/strings.xml",
|
||||
},
|
||||
"bar": []string{
|
||||
"device/vendor/blah/static_overlay/bar/res/values/strings.xml",
|
||||
"device/vendor/blah/overlay/bar/res/values/strings.xml",
|
||||
},
|
||||
},
|
||||
rroDirs: map[string][]string{
|
||||
"foo": nil,
|
||||
"bar": nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "enforce RRO on foo",
|
||||
enforceRROTargets: []string{"foo"},
|
||||
enforceRROExcludedOverlays: []string{"device/vendor/blah/static_overlay"},
|
||||
overlayFiles: map[string][]string{
|
||||
"foo": []string{"device/vendor/blah/static_overlay/foo/res/values/strings.xml"},
|
||||
"bar": []string{
|
||||
"device/vendor/blah/static_overlay/bar/res/values/strings.xml",
|
||||
"device/vendor/blah/overlay/bar/res/values/strings.xml",
|
||||
},
|
||||
},
|
||||
rroDirs: map[string][]string{
|
||||
"foo": []string{"device/vendor/blah/overlay/foo/res"},
|
||||
"bar": nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "enforce RRO on all",
|
||||
enforceRROTargets: []string{"*"},
|
||||
enforceRROExcludedOverlays: []string{
|
||||
// Excluding specific apps/res directories also allowed.
|
||||
"device/vendor/blah/static_overlay/foo",
|
||||
"device/vendor/blah/static_overlay/bar/res",
|
||||
},
|
||||
overlayFiles: map[string][]string{
|
||||
"foo": []string{"device/vendor/blah/static_overlay/foo/res/values/strings.xml"},
|
||||
"bar": []string{"device/vendor/blah/static_overlay/bar/res/values/strings.xml"},
|
||||
},
|
||||
rroDirs: map[string][]string{
|
||||
"foo": []string{"device/vendor/blah/overlay/foo/res"},
|
||||
"bar": []string{"device/vendor/blah/overlay/bar/res"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
func TestEnforceRRO(t *testing.T) {
|
||||
testCases := []struct {
|
||||
name string
|
||||
enforceRROTargets []string
|
||||
enforceRROExcludedOverlays []string
|
||||
overlayFiles map[string][]string
|
||||
rroDirs map[string][]string
|
||||
}{
|
||||
{
|
||||
name: "no RRO",
|
||||
enforceRROTargets: nil,
|
||||
enforceRROExcludedOverlays: nil,
|
||||
overlayFiles: map[string][]string{
|
||||
"foo": []string{
|
||||
"device/vendor/blah/static_overlay/foo/res/values/strings.xml",
|
||||
"device/vendor/blah/overlay/foo/res/values/strings.xml",
|
||||
},
|
||||
"bar": []string{
|
||||
"device/vendor/blah/static_overlay/bar/res/values/strings.xml",
|
||||
"device/vendor/blah/overlay/bar/res/values/strings.xml",
|
||||
},
|
||||
},
|
||||
rroDirs: map[string][]string{
|
||||
"foo": nil,
|
||||
"bar": nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "enforce RRO on foo",
|
||||
enforceRROTargets: []string{"foo"},
|
||||
enforceRROExcludedOverlays: []string{"device/vendor/blah/static_overlay"},
|
||||
overlayFiles: map[string][]string{
|
||||
"foo": []string{"device/vendor/blah/static_overlay/foo/res/values/strings.xml"},
|
||||
"bar": []string{
|
||||
"device/vendor/blah/static_overlay/bar/res/values/strings.xml",
|
||||
"device/vendor/blah/overlay/bar/res/values/strings.xml",
|
||||
},
|
||||
},
|
||||
rroDirs: map[string][]string{
|
||||
"foo": []string{"device/vendor/blah/overlay/foo/res"},
|
||||
"bar": nil,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "enforce RRO on all",
|
||||
enforceRROTargets: []string{"*"},
|
||||
enforceRROExcludedOverlays: []string{
|
||||
// Excluding specific apps/res directories also allowed.
|
||||
"device/vendor/blah/static_overlay/foo",
|
||||
"device/vendor/blah/static_overlay/bar/res",
|
||||
},
|
||||
overlayFiles: map[string][]string{
|
||||
"foo": []string{"device/vendor/blah/static_overlay/foo/res/values/strings.xml"},
|
||||
"bar": []string{"device/vendor/blah/static_overlay/bar/res/values/strings.xml"},
|
||||
},
|
||||
rroDirs: map[string][]string{
|
||||
"foo": []string{"device/vendor/blah/overlay/foo/res"},
|
||||
"bar": []string{"device/vendor/blah/overlay/bar/res"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
resourceOverlays := []string{
|
||||
"device/vendor/blah/overlay",
|
||||
"device/vendor/blah/overlay2",
|
||||
@@ -196,7 +196,7 @@ func TestEnforceRRO(t *testing.T) {
|
||||
}
|
||||
`
|
||||
|
||||
for _, testCase := range testEnforceRROTests {
|
||||
for _, testCase := range testCases {
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
config := testConfig(nil)
|
||||
config.TestProductVariables.ResourceOverlays = resourceOverlays
|
||||
|
Reference in New Issue
Block a user