Add unit test to verify contents of bootclasspath.pb.textproto
The unit test is useful for verifying that min_sdk_version/max_sdk_version information is populated correctly. Followup to https://r.android.com/3128893 Bug: 345621958 Test: go test ./apex Change-Id: Id7696a8cefaab6d0b7f38b65a33e326152ac12d3
This commit is contained in:
parent
306804fe41
commit
fcea0a8cc4
1 changed files with 85 additions and 0 deletions
|
@ -1366,4 +1366,89 @@ func TestBootclasspathFragment_AndroidNonUpdatable_AlwaysUsePrebuiltSdks(t *test
|
|||
android.AssertStringDoesContain(t, "test", command, "--test-stub-classpath="+nonUpdatableTestStubs)
|
||||
}
|
||||
|
||||
func TestBootclasspathFragmentProtoContainsMinSdkVersion(t *testing.T) {
|
||||
result := android.GroupFixturePreparers(
|
||||
prepareForTestWithBootclasspathFragment,
|
||||
prepareForTestWithMyapex,
|
||||
// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
|
||||
java.FixtureConfigureApexBootJars("myapex:foo", "myapex:bar"),
|
||||
// Make sure that the frameworks/base/Android.bp file exists as otherwise hidden API encoding
|
||||
// is disabled.
|
||||
android.FixtureAddTextFile("frameworks/base/Android.bp", ""),
|
||||
|
||||
java.PrepareForTestWithJavaSdkLibraryFiles,
|
||||
java.FixtureWithLastReleaseApis("foo", "bar"),
|
||||
).RunTestWithBp(t, `
|
||||
apex {
|
||||
name: "myapex",
|
||||
key: "myapex.key",
|
||||
bootclasspath_fragments: [
|
||||
"mybootclasspathfragment",
|
||||
],
|
||||
updatable: false,
|
||||
}
|
||||
|
||||
apex_key {
|
||||
name: "myapex.key",
|
||||
public_key: "testkey.avbpubkey",
|
||||
private_key: "testkey.pem",
|
||||
}
|
||||
|
||||
java_sdk_library {
|
||||
name: "foo",
|
||||
srcs: ["b.java"],
|
||||
shared_library: false,
|
||||
public: {enabled: true},
|
||||
apex_available: [
|
||||
"myapex",
|
||||
],
|
||||
min_sdk_version: "33",
|
||||
}
|
||||
|
||||
java_sdk_library {
|
||||
name: "bar",
|
||||
srcs: ["b.java"],
|
||||
shared_library: false,
|
||||
public: {enabled: true},
|
||||
apex_available: [
|
||||
"myapex",
|
||||
],
|
||||
min_sdk_version: "34",
|
||||
}
|
||||
|
||||
bootclasspath_fragment {
|
||||
name: "mybootclasspathfragment",
|
||||
contents: [
|
||||
"foo",
|
||||
"bar",
|
||||
],
|
||||
apex_available: [
|
||||
"myapex",
|
||||
],
|
||||
hidden_api: {
|
||||
split_packages: ["*"],
|
||||
},
|
||||
}
|
||||
`)
|
||||
|
||||
fragment := result.ModuleForTests("mybootclasspathfragment", "android_common_apex10000")
|
||||
classPathProtoContent := android.ContentFromFileRuleForTests(t, result.TestContext, fragment.Output("bootclasspath.pb.textproto"))
|
||||
// foo
|
||||
ensureContains(t, classPathProtoContent, `jars {
|
||||
path: "/apex/myapex/javalib/foo.jar"
|
||||
classpath: BOOTCLASSPATH
|
||||
min_sdk_version: "33"
|
||||
max_sdk_version: ""
|
||||
}
|
||||
`)
|
||||
// bar
|
||||
ensureContains(t, classPathProtoContent, `jars {
|
||||
path: "/apex/myapex/javalib/bar.jar"
|
||||
classpath: BOOTCLASSPATH
|
||||
min_sdk_version: "34"
|
||||
max_sdk_version: ""
|
||||
}
|
||||
`)
|
||||
}
|
||||
|
||||
// TODO(b/177892522) - add test for host apex.
|
||||
|
|
Loading…
Reference in a new issue