Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 086241ec authored by Paul Duffin's avatar Paul Duffin Committed by Automerger Merge Worker
Browse files

Merge "Test dex jar paths provided to apex by bootclasspath_fragment" am:...

Merge "Test dex jar paths provided to apex by bootclasspath_fragment" am: 4483ec11 am: 5f12386d am: 32669567 am: ce6fbb70

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1710508

Change-Id: Ie4ace74e650df84040e58ce64eafa2804c7189b8
parents 61e1b716 ce6fbb70
Loading
Loading
Loading
Loading
+32 −2
Original line number Diff line number Diff line
@@ -433,6 +433,14 @@ func TestBootclasspathFragmentContentsNoName(t *testing.T) {
	result := android.GroupFixturePreparers(
		prepareForTestWithBootclasspathFragment,
		prepareForTestWithMyapex,
		// Configure bootclasspath jars to ensure that hidden API encoding is performed on them.
		java.FixtureConfigureBootJars("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"),
	).RunTestWithBp(t, `
		apex {
			name: "myapex",
@@ -449,10 +457,11 @@ func TestBootclasspathFragmentContentsNoName(t *testing.T) {
			private_key: "testkey.pem",
		}

		java_library {
		java_sdk_library {
			name: "foo",
			srcs: ["b.java"],
			installable: true,
			shared_library: false,
			public: {enabled: true},
			apex_available: [
				"myapex",
			],
@@ -491,6 +500,27 @@ func TestBootclasspathFragmentContentsNoName(t *testing.T) {
		`myapex.key`,
		`mybootclasspathfragment`,
	})

	apex := result.ModuleForTests("myapex", "android_common_myapex_image")
	apexRule := apex.Rule("apexRule")
	copyCommands := apexRule.Args["copy_commands"]

	// Make sure that the fragment provides the hidden API encoded dex jars to the APEX.
	fragment := result.Module("mybootclasspathfragment", "android_common_apex10000")

	info := result.ModuleProvider(fragment, java.BootclasspathFragmentApexContentInfoProvider).(java.BootclasspathFragmentApexContentInfo)

	checkFragmentExportedDexJar := func(name string, expectedDexJar string) {
		module := result.Module(name, "android_common_apex10000")
		dexJar := info.DexBootJarPathForContentModule(module)
		android.AssertPathRelativeToTopEquals(t, name+" dex", expectedDexJar, dexJar)

		expectedCopyCommand := fmt.Sprintf("&& cp -f %s out/soong/.intermediates/myapex/android_common_myapex_image/image.apex/javalib/%s.jar", expectedDexJar, name)
		android.AssertStringDoesContain(t, name+" apex copy command", copyCommands, expectedCopyCommand)
	}

	checkFragmentExportedDexJar("foo", "out/soong/.intermediates/foo/android_common_apex10000/hiddenapi/foo.jar")
	checkFragmentExportedDexJar("bar", "out/soong/.intermediates/bar/android_common_apex10000/hiddenapi/bar.jar")
}

// TODO(b/177892522) - add test for host apex.