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

Commit 40eb3b3e authored by Jiakai Zhang's avatar Jiakai Zhang Committed by Gerrit Code Review
Browse files

Merge "Add more tests for dexpreopting."

parents e466cc7e 470b7e22
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
@@ -8289,6 +8289,75 @@ func TestProhibitStaticExecutable(t *testing.T) {
	`)
}

func TestAndroidMk_DexpreoptBuiltInstalledForApex(t *testing.T) {
	ctx := testApex(t, `
		apex {
			name: "myapex",
			key: "myapex.key",
			updatable: false,
			java_libs: ["foo"],
		}

		apex_key {
			name: "myapex.key",
			public_key: "testkey.avbpubkey",
			private_key: "testkey.pem",
		}

		java_library {
			name: "foo",
			srcs: ["foo.java"],
			apex_available: ["myapex"],
			installable: true,
		}
	`,
		dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
	)

	apexBundle := ctx.ModuleForTests("myapex", "android_common_myapex_image").Module().(*apexBundle)
	data := android.AndroidMkDataForTest(t, ctx, apexBundle)
	var builder strings.Builder
	data.Custom(&builder, apexBundle.BaseModuleName(), "TARGET_", "", data)
	androidMk := builder.String()
	ensureContains(t, androidMk, "LOCAL_REQUIRED_MODULES += foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex")
}

func TestAndroidMk_DexpreoptBuiltInstalledForApex_Prebuilt(t *testing.T) {
	ctx := testApex(t, `
		prebuilt_apex {
			name: "myapex",
			arch: {
				arm64: {
					src: "myapex-arm64.apex",
				},
				arm: {
					src: "myapex-arm.apex",
				},
			},
			exported_java_libs: ["foo"],
		}

		java_import {
			name: "foo",
			jars: ["foo.jar"],
			installable: true,
		}
	`,
		dexpreopt.FixtureSetApexSystemServerJars("myapex:foo"),
	)

	prebuilt := ctx.ModuleForTests("myapex", "android_common_myapex").Module().(*Prebuilt)
	entriesList := android.AndroidMkEntriesForTest(t, ctx, prebuilt)
	mainModuleEntries := entriesList[0]
	android.AssertArrayString(t,
		"LOCAL_REQUIRED_MODULES",
		mainModuleEntries.EntryMap["LOCAL_REQUIRED_MODULES"],
		[]string{
			"foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.odex",
			"foo-dexpreopt-arm64-apex@myapex@javalib@foo.jar@classes.vdex",
		})
}

func TestMain(m *testing.M) {
	os.Exit(m.Run())
}