--checkapi checks nested types as well
--checkapi should check nested types just like root-level types.
Bug: 182508839
Test: aidl_unittests
Change-Id: I66584dd7bc8095e97002da7cd6a874ce1651678e
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index d35e419..4e87ecb 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -2910,6 +2910,22 @@
EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
}
+TEST_F(AidlTestCompatibleChanges, NewNestedTypes) {
+ io_delegate_.SetFileContents("old/p/Data.aidl",
+ "package p;\n"
+ "parcelable Data {\n"
+ " int n;\n"
+ "}");
+ io_delegate_.SetFileContents("new/p/Data.aidl",
+ "package p;\n"
+ "parcelable Data {\n"
+ " enum NewEnum { N = 3 }\n"
+ " int n;\n"
+ " NewEnum e = NewEnum.N;\n"
+ "}");
+ EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
+}
+
class AidlTestIncompatibleChanges : public AidlTest {
protected:
Options options_ = Options::From("aidl --checkapi old new");
@@ -3418,6 +3434,28 @@
EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
+TEST_F(AidlTestIncompatibleChanges, IncompatibleChangesInNestedType) {
+ const string expected_stderr =
+ "ERROR: new/p/Foo.aidl:1.33-37: Number of fields in p.Foo is reduced from 2 to 1.\n";
+ io_delegate_.SetFileContents("old/p/Foo.aidl",
+ "package p;\n"
+ "parcelable Foo {\n"
+ " interface IBar {\n"
+ " void foo();"
+ " }\n"
+ "}");
+ io_delegate_.SetFileContents("new/p/Foo.aidl",
+ "package p;\n"
+ "parcelable Foo {\n"
+ " interface IBar {\n"
+ " void foo(int n);" // incompatible: signature changed
+ " }\n"
+ "}");
+ CaptureStderr();
+ EXPECT_FALSE(::android::aidl::check_api(options_, io_delegate_));
+ EXPECT_THAT(GetCapturedStderr(), HasSubstr("Removed or changed method: p.Foo.IBar.foo()"));
+}
+
TEST_P(AidlTest, RejectNonFixedSizeFromFixedSize) {
const string expected_stderr =
"ERROR: Foo.aidl:2.8-10: The @FixedSize parcelable 'Foo' has a non-fixed size field named "