diff options
author | 2024-01-09 06:02:12 +0000 | |
---|---|---|
committer | 2024-01-09 06:02:12 +0000 | |
commit | 539b46b6bd0ebacbc79016a8e0043dce02072263 (patch) | |
tree | 2d51540d678be094eb877f715bc4124a2104ad3a /java/sdk_library_test.go | |
parent | 0d2afbbfc02d8b4671e9031ab9dd13d5190985e0 (diff) | |
parent | fa4a90d4341c5f54a03022e626b817acbee8bf78 (diff) |
Merge "Generate "exportable" stubs library in java_sdk_library" into main
Diffstat (limited to 'java/sdk_library_test.go')
-rw-r--r-- | java/sdk_library_test.go | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/java/sdk_library_test.go b/java/sdk_library_test.go index 63419d6b1..c14f3e611 100644 --- a/java/sdk_library_test.go +++ b/java/sdk_library_test.go @@ -1423,7 +1423,7 @@ func TestJavaSdkLibraryDist(t *testing.T) { for _, tt := range testCases { t.Run(tt.module, func(t *testing.T) { - m := result.ModuleForTests(tt.module+".stubs", "android_common").Module().(*Library) + m := result.ModuleForTests(apiScopePublic.exportableStubsLibraryModuleName(tt.module), "android_common").Module().(*Library) dists := m.Dists() if len(dists) != 1 { t.Fatalf("expected exactly 1 dist entry, got %d", len(dists)) @@ -1693,3 +1693,56 @@ func TestSdkLibraryDependency(t *testing.T) { android.AssertStringDoesContain(t, "bar.xml java_sdk_xml command", barPermissions.RuleParams.Command, `dependency=\"foo\"`) } + +func TestSdkLibraryExportableStubsLibrary(t *testing.T) { + result := android.GroupFixturePreparers( + prepareForJavaTest, + PrepareForTestWithJavaSdkLibraryFiles, + FixtureWithLastReleaseApis("foo"), + android.FixtureModifyConfig(func(config android.Config) { + config.SetApiLibraries([]string{"foo"}) + }), + ).RunTestWithBp(t, ` + aconfig_declarations { + name: "bar", + package: "com.example.package", + srcs: [ + "bar.aconfig", + ], + } + java_sdk_library { + name: "foo", + srcs: ["a.java", "b.java"], + api_packages: ["foo"], + system: { + enabled: true, + }, + module_lib: { + enabled: true, + }, + test: { + enabled: true, + }, + aconfig_declarations: [ + "bar", + ], + } + `) + + exportableStubsLibraryModuleName := apiScopePublic.exportableStubsLibraryModuleName("foo") + exportableSourceStubsLibraryModuleName := apiScopePublic.exportableSourceStubsLibraryModuleName("foo") + + // Check modules generation + topLevelModule := result.ModuleForTests(exportableStubsLibraryModuleName, "android_common") + result.ModuleForTests(exportableSourceStubsLibraryModuleName, "android_common") + + // Check static lib dependency + android.AssertBoolEquals(t, "exportable top level stubs library module depends on the"+ + "exportable source stubs library module", true, + CheckModuleHasDependency(t, result.TestContext, exportableStubsLibraryModuleName, + "android_common", exportableSourceStubsLibraryModuleName), + ) + android.AssertArrayString(t, "exportable source stub library is a static lib of the"+ + "top level exportable stubs library", []string{exportableSourceStubsLibraryModuleName}, + topLevelModule.Module().(*Library).properties.Static_libs) +} |