diff options
Diffstat (limited to 'apex/apex_test.go')
-rw-r--r-- | apex/apex_test.go | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/apex/apex_test.go b/apex/apex_test.go index 7b01b9481..360c9fe3f 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -4282,16 +4282,26 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) { p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency) dexJarBuildPath := p.DexJarBuildPath() stem := android.RemoveOptionalPrebuiltPrefix(name) - if expected, actual := ".intermediates/myapex.deapexer/android_common/deapexer/javalib/"+stem+".jar", android.NormalizePathForTesting(dexJarBuildPath); actual != expected { - t.Errorf("Incorrect DexJarBuildPath value '%s', expected '%s'", actual, expected) - } + android.AssertStringEquals(t, "DexJarBuildPath should be apex-related path.", + ".intermediates/myapex.deapexer/android_common/deapexer/javalib/"+stem+".jar", + android.NormalizePathForTesting(dexJarBuildPath)) + } + + checkDexJarInstallPath := func(t *testing.T, ctx *android.TestContext, name string) { + // Make sure the import has been given the correct path to the dex jar. + p := ctx.ModuleForTests(name, "android_common_myapex").Module().(java.UsesLibraryDependency) + dexJarBuildPath := p.DexJarInstallPath() + stem := android.RemoveOptionalPrebuiltPrefix(name) + android.AssertStringEquals(t, "DexJarInstallPath should be apex-related path.", + "target/product/test_device/apex/myapex/javalib/"+stem+".jar", + android.NormalizePathForTesting(dexJarBuildPath)) } ensureNoSourceVariant := func(t *testing.T, ctx *android.TestContext, name string) { // Make sure that an apex variant is not created for the source module. - if expected, actual := []string{"android_common"}, ctx.ModuleVariantsForTests(name); !reflect.DeepEqual(expected, actual) { - t.Errorf("invalid set of variants for %q: expected %q, found %q", "libfoo", expected, actual) - } + android.AssertArrayString(t, "Check if there is no source variant", + []string{"android_common"}, + ctx.ModuleVariantsForTests(name)) } t.Run("prebuilt only", func(t *testing.T) { @@ -4340,8 +4350,10 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) { } checkDexJarBuildPath(t, ctx, "libfoo") + checkDexJarInstallPath(t, ctx, "libfoo") checkDexJarBuildPath(t, ctx, "libbar") + checkDexJarInstallPath(t, ctx, "libbar") }) t.Run("prebuilt with source preferred", func(t *testing.T) { @@ -4387,9 +4399,11 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) { ctx := testDexpreoptWithApexes(t, bp, "", transform) checkDexJarBuildPath(t, ctx, "prebuilt_libfoo") + checkDexJarInstallPath(t, ctx, "prebuilt_libfoo") ensureNoSourceVariant(t, ctx, "libfoo") checkDexJarBuildPath(t, ctx, "prebuilt_libbar") + checkDexJarInstallPath(t, ctx, "prebuilt_libbar") ensureNoSourceVariant(t, ctx, "libbar") }) @@ -4437,9 +4451,11 @@ func TestPrebuiltExportDexImplementationJars(t *testing.T) { ctx := testDexpreoptWithApexes(t, bp, "", transform) checkDexJarBuildPath(t, ctx, "prebuilt_libfoo") + checkDexJarInstallPath(t, ctx, "prebuilt_libfoo") ensureNoSourceVariant(t, ctx, "libfoo") checkDexJarBuildPath(t, ctx, "prebuilt_libbar") + checkDexJarInstallPath(t, ctx, "prebuilt_libbar") ensureNoSourceVariant(t, ctx, "libbar") }) } @@ -4628,6 +4644,12 @@ func TestBootDexJarsFromSourcesAndPrebuilts(t *testing.T) { // find the dex boot jar in it. We either need to disable the source libfoo // or make the prebuilt libfoo preferred. testDexpreoptWithApexes(t, bp, "module libfoo does not provide a dex boot jar", preparer, fragment) + // dexbootjar check is skipped if AllowMissingDependencies is true + preparerAllowMissingDeps := android.GroupFixturePreparers( + preparer, + android.PrepareForTestWithAllowMissingDependencies, + ) + testDexpreoptWithApexes(t, bp, "", preparerAllowMissingDeps, fragment) }) t.Run("prebuilt library preferred with source", func(t *testing.T) { |