Fix handling of "android.test.mock" in class loader context.

Mimick the way PackageManager handles it at runtime: do add it to class
loader context for apps with targetSdkVersion < 30, but only if
"android.test.runner" is used. Previously it was not added at all.

Test: lunch aosp_cf_x86_phone-userdebug && m
Bug: 132357300
Change-Id: I4c06635277ab13e21069b9fa0b46eb6a2547dfdd
This commit is contained in:
Ulya Trafimovich
2020-10-21 13:20:55 +01:00
parent 24813e1d80
commit 46b3d5bd05
2 changed files with 8 additions and 3 deletions

View File

@@ -2838,6 +2838,7 @@ func TestUsesLibraries(t *testing.T) {
}
// Test conditional context for target SDK version 30.
// "android.test.mock" is absent because "android.test.runner" is not used.
if w := `--target-classpath-for-sdk 30` +
` /system/framework/android.test.base.jar `; !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
@@ -2852,8 +2853,10 @@ func TestUsesLibraries(t *testing.T) {
}
// Test conditional context for target SDK version 30.
// "android.test.mock" is present because "android.test.runner" is used.
if w := `--target-classpath-for-sdk 30` +
` /system/framework/android.test.base.jar `; !strings.Contains(cmd, w) {
` /system/framework/android.test.base.jar` +
`:/system/framework/android.test.mock.jar `; !strings.Contains(cmd, w) {
t.Errorf("wanted %q in %q", w, cmd)
}
}