Convert app tests that depend on javaMockFS() to test fixtures
Bug: 182638834 Test: m nothing Change-Id: Ice668cf58695839d4929a0744822c0ded441d9c4
This commit is contained in:
parent
d234b418a5
commit
cdb88a996a
1 changed files with 40 additions and 47 deletions
|
@ -370,11 +370,12 @@ func TestUpdatableApps(t *testing.T) {
|
||||||
|
|
||||||
for _, test := range testCases {
|
for _, test := range testCases {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
if test.expectedError == "" {
|
errorHandler := android.FixtureExpectsNoErrors
|
||||||
testJava(t, test.bp)
|
if test.expectedError != "" {
|
||||||
} else {
|
errorHandler = android.FixtureExpectsAtLeastOneErrorMatchingPattern(test.expectedError)
|
||||||
testJavaError(t, test.expectedError, test.bp)
|
|
||||||
}
|
}
|
||||||
|
javaFixtureFactory.
|
||||||
|
ExtendWithErrorHandler(errorHandler).RunTestWithBp(t, test.bp)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -984,12 +985,8 @@ func TestAndroidResources(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkSdkVersion(t *testing.T, config android.Config, expectedSdkVersion string) {
|
func checkSdkVersion(t *testing.T, result *android.TestResult, expectedSdkVersion string) {
|
||||||
ctx := testContext(config)
|
foo := result.ModuleForTests("foo", "android_common")
|
||||||
|
|
||||||
run(t, ctx, config)
|
|
||||||
|
|
||||||
foo := ctx.ModuleForTests("foo", "android_common")
|
|
||||||
link := foo.Output("package-res.apk")
|
link := foo.Output("package-res.apk")
|
||||||
linkFlags := strings.Split(link.Args["flags"], " ")
|
linkFlags := strings.Split(link.Args["flags"], " ")
|
||||||
min := android.IndexList("--min-sdk-version", linkFlags)
|
min := android.IndexList("--min-sdk-version", linkFlags)
|
||||||
|
@ -1002,15 +999,9 @@ func checkSdkVersion(t *testing.T, config android.Config, expectedSdkVersion str
|
||||||
gotMinSdkVersion := linkFlags[min+1]
|
gotMinSdkVersion := linkFlags[min+1]
|
||||||
gotTargetSdkVersion := linkFlags[target+1]
|
gotTargetSdkVersion := linkFlags[target+1]
|
||||||
|
|
||||||
if gotMinSdkVersion != expectedSdkVersion {
|
android.AssertStringEquals(t, "incorrect --min-sdk-version", expectedSdkVersion, gotMinSdkVersion)
|
||||||
t.Errorf("incorrect --min-sdk-version, expected %q got %q",
|
|
||||||
expectedSdkVersion, gotMinSdkVersion)
|
|
||||||
}
|
|
||||||
|
|
||||||
if gotTargetSdkVersion != expectedSdkVersion {
|
android.AssertStringEquals(t, "incorrect --target-sdk-version", expectedSdkVersion, gotTargetSdkVersion)
|
||||||
t.Errorf("incorrect --target-sdk-version, expected %q got %q",
|
|
||||||
expectedSdkVersion, gotTargetSdkVersion)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAppSdkVersion(t *testing.T) {
|
func TestAppSdkVersion(t *testing.T) {
|
||||||
|
@ -1083,13 +1074,16 @@ func TestAppSdkVersion(t *testing.T) {
|
||||||
%s
|
%s
|
||||||
}`, moduleType, test.sdkVersion, platformApiProp)
|
}`, moduleType, test.sdkVersion, platformApiProp)
|
||||||
|
|
||||||
config := testAppConfig(nil, bp, nil)
|
result := javaFixtureFactory.Extend(
|
||||||
config.TestProductVariables.Platform_sdk_version = &test.platformSdkInt
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
config.TestProductVariables.Platform_sdk_codename = &test.platformSdkCodename
|
variables.Platform_sdk_version = &test.platformSdkInt
|
||||||
config.TestProductVariables.Platform_version_active_codenames = test.activeCodenames
|
variables.Platform_sdk_codename = &test.platformSdkCodename
|
||||||
config.TestProductVariables.Platform_sdk_final = &test.platformSdkFinal
|
variables.Platform_version_active_codenames = test.activeCodenames
|
||||||
checkSdkVersion(t, config, test.expectedMinSdkVersion)
|
variables.Platform_sdk_final = &test.platformSdkFinal
|
||||||
|
}),
|
||||||
|
).RunTestWithBp(t, bp)
|
||||||
|
|
||||||
|
checkSdkVersion(t, result, test.expectedMinSdkVersion)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1145,13 +1139,17 @@ func TestVendorAppSdkVersion(t *testing.T) {
|
||||||
vendor: true,
|
vendor: true,
|
||||||
}`, moduleType, sdkKind, test.sdkVersion)
|
}`, moduleType, sdkKind, test.sdkVersion)
|
||||||
|
|
||||||
config := testAppConfig(nil, bp, nil)
|
result := javaFixtureFactory.Extend(
|
||||||
config.TestProductVariables.Platform_sdk_version = &test.platformSdkInt
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
config.TestProductVariables.Platform_sdk_codename = &test.platformSdkCodename
|
variables.Platform_sdk_version = &test.platformSdkInt
|
||||||
config.TestProductVariables.Platform_sdk_final = &test.platformSdkFinal
|
variables.Platform_sdk_codename = &test.platformSdkCodename
|
||||||
config.TestProductVariables.DeviceCurrentApiLevelForVendorModules = &test.deviceCurrentApiLevelForVendorModules
|
variables.Platform_sdk_final = &test.platformSdkFinal
|
||||||
config.TestProductVariables.DeviceSystemSdkVersions = []string{"28", "29"}
|
variables.DeviceCurrentApiLevelForVendorModules = &test.deviceCurrentApiLevelForVendorModules
|
||||||
checkSdkVersion(t, config, test.expectedMinSdkVersion)
|
variables.DeviceSystemSdkVersions = []string{"28", "29"}
|
||||||
|
}),
|
||||||
|
).RunTestWithBp(t, bp)
|
||||||
|
|
||||||
|
checkSdkVersion(t, result, test.expectedMinSdkVersion)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2707,28 +2705,23 @@ func TestUncompressDex(t *testing.T) {
|
||||||
test := func(t *testing.T, bp string, want bool, unbundled bool) {
|
test := func(t *testing.T, bp string, want bool, unbundled bool) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
|
|
||||||
config := testAppConfig(nil, bp, nil)
|
result := javaFixtureFactory.Extend(
|
||||||
|
android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
|
||||||
if unbundled {
|
if unbundled {
|
||||||
config.TestProductVariables.Unbundled_build = proptools.BoolPtr(true)
|
variables.Unbundled_build = proptools.BoolPtr(true)
|
||||||
config.TestProductVariables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
|
variables.Always_use_prebuilt_sdks = proptools.BoolPtr(true)
|
||||||
}
|
}
|
||||||
|
}),
|
||||||
|
).RunTestWithBp(t, bp)
|
||||||
|
|
||||||
ctx := testContext(config)
|
foo := result.ModuleForTests("foo", "android_common")
|
||||||
|
|
||||||
run(t, ctx, config)
|
|
||||||
|
|
||||||
foo := ctx.ModuleForTests("foo", "android_common")
|
|
||||||
dex := foo.Rule("r8")
|
dex := foo.Rule("r8")
|
||||||
uncompressedInDexJar := strings.Contains(dex.Args["zipFlags"], "-L 0")
|
uncompressedInDexJar := strings.Contains(dex.Args["zipFlags"], "-L 0")
|
||||||
aligned := foo.MaybeRule("zipalign").Rule != nil
|
aligned := foo.MaybeRule("zipalign").Rule != nil
|
||||||
|
|
||||||
if uncompressedInDexJar != want {
|
android.AssertBoolEquals(t, "uncompressed in dex", want, uncompressedInDexJar)
|
||||||
t.Errorf("want uncompressed in dex %v, got %v", want, uncompressedInDexJar)
|
|
||||||
}
|
|
||||||
|
|
||||||
if aligned != want {
|
android.AssertBoolEquals(t, "aligne", want, aligned)
|
||||||
t.Errorf("want aligned %v, got %v", want, aligned)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range testCases {
|
for _, tt := range testCases {
|
||||||
|
|
Loading…
Reference in a new issue