Accept @Enforce on interface definition
The @Enforce annotation may be used on interfaces in combination with
annotations at the method level. If both are present, both are verified.
For now, this is only implemented for the Java backend.
Move permission-related golden tests to its own directory.
Bug: 197828948
Test: atest --host aidl_unittests
Change-Id: I57fe072c616ddc2652bff911adbda1a79841742a
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index fd3c3e3..e8e852d 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -3792,6 +3792,29 @@
HasSubstr("ERROR: a/IFoo.aidl:3.1-38: Unable to parse @Enforce annotation"));
}
+TEST_F(AidlTest, InterfaceEnforceCondition) {
+ io_delegate_.SetFileContents("a/IFoo.aidl", R"(package a;
+ @Enforce(condition="permission = INTERNET")
+ interface IFoo {
+ void Protected();
+ })");
+
+ Options options = Options::From("aidl --lang=java -o out a/IFoo.aidl");
+ EXPECT_TRUE(compile_aidl(options, io_delegate_));
+}
+
+TEST_F(AidlTest, InterfaceAndMethodEnforceCondition) {
+ io_delegate_.SetFileContents("a/IFoo.aidl", R"(package a;
+ @Enforce(condition="permission = INTERNET")
+ interface IFoo {
+ @Enforce(condition="uid = SYSTEM_UID")
+ void Protected();
+ })");
+
+ Options options = Options::From("aidl --lang=java -o out a/IFoo.aidl");
+ EXPECT_TRUE(compile_aidl(options, io_delegate_));
+}
+
class AidlOutputPathTest : public AidlTest {
protected:
void SetUp() override {