diff options
| author | 2022-02-24 02:25:20 +0000 | |
|---|---|---|
| committer | 2022-02-24 02:25:20 +0000 | |
| commit | 315352e71c04e19a1350d7fcc0f7670743d1ec7b (patch) | |
| tree | 973cb34fc2c7d9503e1df033033f50aee85d069c /java/java_test.go | |
| parent | 8b99da5f37d8e65783dfd2726a886555ff0ee5e9 (diff) | |
| parent | de8417c7076949606bd3767e6112d1e2390d9678 (diff) | |
Merge "Add AIDL enforce_permissions attribute"
Diffstat (limited to 'java/java_test.go')
| -rw-r--r-- | java/java_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go index 21c76b6c1..f095c5e48 100644 --- a/java/java_test.go +++ b/java/java_test.go @@ -1333,6 +1333,42 @@ func TestAidlFlagsWithMinSdkVersion(t *testing.T) { } } +func TestAidlEnforcePermissions(t *testing.T) { + ctx, _ := testJava(t, ` + java_library { + name: "foo", + srcs: ["aidl/foo/IFoo.aidl"], + aidl: { enforce_permissions: true }, + } + `) + + aidlCommand := ctx.ModuleForTests("foo", "android_common").Rule("aidl").RuleParams.Command + expectedAidlFlag := "-Wmissing-permission-annotation -Werror" + if !strings.Contains(aidlCommand, expectedAidlFlag) { + t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag) + } +} + +func TestAidlEnforcePermissionsException(t *testing.T) { + ctx, _ := testJava(t, ` + java_library { + name: "foo", + srcs: ["aidl/foo/IFoo.aidl", "aidl/foo/IFoo2.aidl"], + aidl: { enforce_permissions: true, enforce_permissions_exceptions: ["aidl/foo/IFoo2.aidl"] }, + } + `) + + aidlCommand := ctx.ModuleForTests("foo", "android_common").Rule("aidl").RuleParams.Command + expectedAidlFlag := "$$FLAGS -Wmissing-permission-annotation -Werror aidl/foo/IFoo.aidl" + if !strings.Contains(aidlCommand, expectedAidlFlag) { + t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag) + } + expectedAidlFlag = "$$FLAGS aidl/foo/IFoo2.aidl" + if !strings.Contains(aidlCommand, expectedAidlFlag) { + t.Errorf("aidl command %q does not contain %q", aidlCommand, expectedAidlFlag) + } +} + func TestDataNativeBinaries(t *testing.T) { ctx, _ := testJava(t, ` java_test_host { |