diff options
author | 2019-02-22 16:28:40 -0800 | |
---|---|---|
committer | 2019-02-27 14:35:39 -0800 | |
commit | aa65e17016152d0d73cd10ab3987bc3bd5c2ef91 (patch) | |
tree | a5438418e791c46ff902a1f919fddce269342a45 /java/app_test.go | |
parent | 6bd446620c663de2aba60f1dde554e8ebca39f6a (diff) |
Add override_module.
This new module type replaces the inherit-package function in make by
allowing developers to override the name, the certificate, and the
manifest package name of an android_app module.
Bug: 122957760
Fixes: 123640028
Test: app_test.go + BrowserGoogle
Change-Id: Iefe447e7078b25039233221361ef95c83a29973a
Diffstat (limited to 'java/app_test.go')
-rw-r--r-- | java/app_test.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/java/app_test.go b/java/app_test.go index 317c75288..313844fa2 100644 --- a/java/app_test.go +++ b/java/app_test.go @@ -747,3 +747,57 @@ func TestPackageNameOverride(t *testing.T) { }) } } + +func TestOverrideModule(t *testing.T) { + ctx := testJava(t, ` + android_app { + name: "foo", + srcs: ["a.java"], + } + + override_module { + name: "bar", + base: "foo", + certificate: ":new_certificate", + manifest_package_name: "org.dandroid.bp", + } + + android_app_certificate { + name: "new_certificate", + certificate: "cert/new_cert", + } + `) + + // The base module still contains all the final outputs after overrides. + foo := ctx.ModuleForTests("foo", "android_common") + + // Check the final apk name + outputs := foo.AllOutputs() + e := buildDir + "/target/product/test_device/system/app/bar/bar.apk" + found := false + for _, o := range outputs { + if o == e { + found = true + break + } + } + if !found { + t.Errorf("Can't find %q in output files.\nAll outputs:%v", e, outputs) + } + + // Check the certificate paths + signapk := foo.Output("foo.apk") + signFlags := signapk.Args["certificates"] + e = "cert/new_cert.x509.pem cert/new_cert.pk8" + if e != signFlags { + t.Errorf("Incorrect signing flags, expected: %q, got: %q", e, signFlags) + } + + // Check the manifest package name + res := foo.Output("package-res.apk") + aapt2Flags := res.Args["flags"] + e = "--rename-manifest-package org.dandroid.bp" + if !strings.Contains(aapt2Flags, e) { + t.Errorf("package renaming flag, %q is missing in aapt2 link flags, %q", e, aapt2Flags) + } +} |