Add a structured parcelable to a versioned test
This is a preparation to add a meaningful test to reveal the bug.
The parcelable Foo is empty in V1 and has a member in V2, which we need
to support as a compatible change.
Bug: 186632725
Test: aidl_unittests
Test: aidl_integration_test
Change-Id: I053906132c7266484d43c44df57460b357c4fc2e
diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp
index f1dce8d..0e3a235 100644
--- a/aidl_unittest.cpp
+++ b/aidl_unittest.cpp
@@ -283,6 +283,12 @@
EXPECT_EQ(expected_stderr, GetCapturedStderr());
}
+TEST_P(AidlTest, AcceptsEmptyParcelable) {
+ CaptureStderr();
+ EXPECT_NE(nullptr, Parse("Foo.aidl", "parcelable Foo {}", typenames_, GetLanguage()));
+ EXPECT_EQ("", GetCapturedStderr());
+}
+
TEST_P(AidlTest, RejectsDuplicatedAnnotationParams) {
const string method = "package a; interface IFoo { @UnsupportedAppUsage(foo=1, foo=2)void f(); }";
const string expected_stderr = "ERROR: a/IFoo.aidl:1.56-62: Trying to redefine parameter foo.\n";
@@ -2004,6 +2010,19 @@
EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
}
+TEST_F(AidlTestCompatibleChanges, NewField2) {
+ io_delegate_.SetFileContents("old/p/Data.aidl",
+ "package p;"
+ "parcelable Data {"
+ "}");
+ io_delegate_.SetFileContents("new/p/Data.aidl",
+ "package p;"
+ "parcelable Data {"
+ " int foo = 0;"
+ "}");
+ EXPECT_TRUE(::android::aidl::check_api(options_, io_delegate_));
+}
+
TEST_F(AidlTestCompatibleChanges, NewEnumerator) {
io_delegate_.SetFileContents("old/p/Enum.aidl",
"package p;"