diff options
Diffstat (limited to 'java/hiddenapi_singleton_test.go')
-rw-r--r-- | java/hiddenapi_singleton_test.go | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/java/hiddenapi_singleton_test.go b/java/hiddenapi_singleton_test.go index 5ea9a5bca..3ab22772a 100644 --- a/java/hiddenapi_singleton_test.go +++ b/java/hiddenapi_singleton_test.go @@ -23,12 +23,20 @@ import ( "github.com/google/blueprint/proptools" ) +// TODO(b/177892522): Move these tests into a more appropriate place. + func fixtureSetPrebuiltHiddenApiDirProductVariable(prebuiltHiddenApiDir *string) android.FixturePreparer { return android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.PrebuiltHiddenApiDir = prebuiltHiddenApiDir }) } +var prepareForTestWithDefaultPlatformBootclasspath = android.FixtureAddTextFile("frameworks/base/boot/Android.bp", ` + platform_bootclasspath { + name: "platform-bootclasspath", + } +`) + var hiddenApiFixtureFactory = android.GroupFixturePreparers( prepareForJavaTest, PrepareForTestWithHiddenApiBuildComponents) @@ -36,6 +44,7 @@ func TestHiddenAPISingleton(t *testing.T) { result := android.GroupFixturePreparers( hiddenApiFixtureFactory, FixtureConfigureBootJars("platform:foo"), + prepareForTestWithDefaultPlatformBootclasspath, ).RunTestWithBp(t, ` java_library { name: "foo", @@ -44,8 +53,8 @@ func TestHiddenAPISingleton(t *testing.T) { } `) - hiddenAPI := result.SingletonForTests("hiddenapi") - hiddenapiRule := hiddenAPI.Rule("hiddenapi") + hiddenAPI := result.ModuleForTests("platform-bootclasspath", "android_common") + hiddenapiRule := hiddenAPI.Rule("platform-bootclasspath-monolithic-hiddenapi-stub-flags") want := "--boot-dex=out/soong/.intermediates/foo/android_common/aligned/foo.jar" android.AssertStringDoesContain(t, "hiddenapi command", hiddenapiRule.RuleParams.Command, want) } @@ -59,6 +68,7 @@ func TestHiddenAPISingletonWithSourceAndPrebuiltPreferredButNoDex(t *testing.T) android.GroupFixturePreparers( hiddenApiFixtureFactory, FixtureConfigureBootJars("platform:foo"), + prepareForTestWithDefaultPlatformBootclasspath, ).ExtendWithErrorHandler(android.FixtureExpectsAtLeastOneErrorMatchingPattern(expectedErrorMessage)). RunTestWithBp(t, ` java_library { @@ -79,6 +89,7 @@ func TestHiddenAPISingletonWithPrebuilt(t *testing.T) { result := android.GroupFixturePreparers( hiddenApiFixtureFactory, FixtureConfigureBootJars("platform:foo"), + prepareForTestWithDefaultPlatformBootclasspath, ).RunTestWithBp(t, ` java_import { name: "foo", @@ -87,8 +98,8 @@ func TestHiddenAPISingletonWithPrebuilt(t *testing.T) { } `) - hiddenAPI := result.SingletonForTests("hiddenapi") - hiddenapiRule := hiddenAPI.Rule("hiddenapi") + hiddenAPI := result.ModuleForTests("platform-bootclasspath", "android_common") + hiddenapiRule := hiddenAPI.Rule("platform-bootclasspath-monolithic-hiddenapi-stub-flags") want := "--boot-dex=out/soong/.intermediates/foo/android_common/aligned/foo.jar" android.AssertStringDoesContain(t, "hiddenapi command", hiddenapiRule.RuleParams.Command, want) } @@ -97,6 +108,7 @@ func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) { result := android.GroupFixturePreparers( hiddenApiFixtureFactory, FixtureConfigureBootJars("platform:foo"), + prepareForTestWithDefaultPlatformBootclasspath, ).RunTestWithBp(t, ` java_library { name: "foo", @@ -112,8 +124,8 @@ func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) { } `) - hiddenAPI := result.SingletonForTests("hiddenapi") - hiddenapiRule := hiddenAPI.Rule("hiddenapi") + hiddenAPI := result.ModuleForTests("platform-bootclasspath", "android_common") + hiddenapiRule := hiddenAPI.Rule("platform-bootclasspath-monolithic-hiddenapi-stub-flags") fromSourceJarArg := "--boot-dex=out/soong/.intermediates/foo/android_common/aligned/foo.jar" android.AssertStringDoesContain(t, "hiddenapi command", hiddenapiRule.RuleParams.Command, fromSourceJarArg) @@ -125,6 +137,7 @@ func TestHiddenAPISingletonWithPrebuiltOverrideSource(t *testing.T) { result := android.GroupFixturePreparers( hiddenApiFixtureFactory, FixtureConfigureBootJars("platform:foo"), + prepareForTestWithDefaultPlatformBootclasspath, ).RunTestWithBp(t, ` java_library { name: "foo", @@ -140,8 +153,8 @@ func TestHiddenAPISingletonWithPrebuiltOverrideSource(t *testing.T) { } `) - hiddenAPI := result.SingletonForTests("hiddenapi") - hiddenapiRule := hiddenAPI.Rule("hiddenapi") + hiddenAPI := result.ModuleForTests("platform-bootclasspath", "android_common") + hiddenapiRule := hiddenAPI.Rule("platform-bootclasspath-monolithic-hiddenapi-stub-flags") prebuiltJarArg := "--boot-dex=out/soong/.intermediates/prebuilt_foo/android_common/dex/foo.jar" android.AssertStringDoesContain(t, "hiddenapi command", hiddenapiRule.RuleParams.Command, prebuiltJarArg) @@ -184,13 +197,14 @@ func TestHiddenAPISingletonSdks(t *testing.T) { result := android.GroupFixturePreparers( hiddenApiFixtureFactory, tc.preparer, + prepareForTestWithDefaultPlatformBootclasspath, android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) { variables.Always_use_prebuilt_sdks = proptools.BoolPtr(tc.unbundledBuild) }), ).RunTest(t) - hiddenAPI := result.SingletonForTests("hiddenapi") - hiddenapiRule := hiddenAPI.Rule("hiddenapi") + hiddenAPI := result.ModuleForTests("platform-bootclasspath", "android_common") + hiddenapiRule := hiddenAPI.Rule("platform-bootclasspath-monolithic-hiddenapi-stub-flags") wantPublicStubs := "--public-stub-classpath=" + generateSdkDexPath(tc.publicStub, tc.unbundledBuild) android.AssertStringDoesContain(t, "hiddenapi command", hiddenapiRule.RuleParams.Command, wantPublicStubs) |