Add unit test for sdk impl lib's lint report propagation to the apex

This change adds a unit test for https://r.android.com/3146677

Test: m nothing --no-skip-soong-tests
Bug: 339267677
Change-Id: I48e1c2681aaa153b32b209f05a93c501af5d1bac
This commit is contained in:
Jihoon Kang
2024-06-25 22:15:39 +00:00
parent 629e2a3e9a
commit 784c005241

View File

@@ -10037,6 +10037,56 @@ func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) {
}
}
func TestApexLintBcpFragmentSdkLibDeps(t *testing.T) {
bp := `
apex {
name: "myapex",
key: "myapex.key",
bootclasspath_fragments: ["mybootclasspathfragment"],
min_sdk_version: "29",
}
apex_key {
name: "myapex.key",
}
bootclasspath_fragment {
name: "mybootclasspathfragment",
contents: ["foo"],
apex_available: ["myapex"],
hidden_api: {
split_packages: ["*"],
},
}
java_sdk_library {
name: "foo",
srcs: ["MyClass.java"],
apex_available: [ "myapex" ],
sdk_version: "current",
min_sdk_version: "29",
compile_dex: true,
}
`
fs := android.MockFS{
"lint-baseline.xml": nil,
}
result := android.GroupFixturePreparers(
prepareForApexTest,
java.PrepareForTestWithJavaSdkLibraryFiles,
java.PrepareForTestWithJacocoInstrumentation,
java.FixtureWithLastReleaseApis("foo"),
android.FixtureModifyConfig(func(config android.Config) {
config.SetApiLibraries([]string{"foo"})
}),
android.FixtureMergeMockFs(fs),
).RunTestWithBp(t, bp)
myapex := result.ModuleForTests("myapex", "android_common_myapex")
lintReportInputs := strings.Join(myapex.Output("lint-report-xml.zip").Inputs.Strings(), " ")
android.AssertStringDoesContain(t,
"myapex lint report expected to contain that of the sdk library impl lib as an input",
lintReportInputs, "foo.impl")
}
// updatable apexes should propagate updatable=true to its apps
func TestUpdatableApexEnforcesAppUpdatability(t *testing.T) {
bp := `