diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-04-15 09:15:39 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-04-15 09:15:39 +0000 |
commit | 13824f236b906d5cc1d718002c173e4356f0dbe2 (patch) | |
tree | 7e373adb4d9acc23635c3158a6aaaea121bd7418 | |
parent | 4c0d565393519cfbc776dd59069d5255109495ee (diff) | |
parent | 70824a3d4313f4e83fbc8bd18b42c61743fd59a5 (diff) | |
download | aidl-13824f236b906d5cc1d718002c173e4356f0dbe2.tar.gz |
Merge "fix: can't assign method IDs when built with --version" into qt-dev
-rw-r--r-- | aidl.cpp | 5 | ||||
-rw-r--r-- | aidl_unittest.cpp | 51 |
2 files changed, 55 insertions, 1 deletions
@@ -312,7 +312,10 @@ bool check_and_assign_method_ids(const std::vector<std::unique_ptr<AidlMethod>>& // transactions must be stable during the entire lifetime of an interface. // In other words, their IDs must be the same even when new user-defined // methods are added. - if (item->HasId() && item->IsUserDefined()) { + if (!item->IsUserDefined()) { + continue; + } + if (item->HasId()) { hasAssignedIds = true; // Ensure that the user set id is not duplicated. if (usedIds.find(item->GetId()) != usedIds.end()) { diff --git a/aidl_unittest.cpp b/aidl_unittest.cpp index 23bc5200..8c4d7965 100644 --- a/aidl_unittest.cpp +++ b/aidl_unittest.cpp @@ -1272,5 +1272,56 @@ TEST_F(AidlTest, ParcelFileDescriptorIsBuiltinType) { EXPECT_EQ(0, ::android::aidl::compile_aidl(cppOptions, io_delegate_)); } +TEST_F(AidlTest, ManualIds) { + Options options = Options::From("aidl --lang=java -o out IFoo.aidl"); + io_delegate_.SetFileContents("IFoo.aidl", + "interface IFoo {\n" + " void foo() = 0;\n" + " void bar() = 1;\n" + "}"); + EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_)); +} + +TEST_F(AidlTest, ManualIdsWithMetaTransactions) { + Options options = Options::From("aidl --lang=java --version 10 -o out IFoo.aidl"); + io_delegate_.SetFileContents("IFoo.aidl", + "interface IFoo {\n" + " void foo() = 0;\n" + " void bar() = 1;\n" + "}"); + EXPECT_EQ(0, ::android::aidl::compile_aidl(options, io_delegate_)); +} + +TEST_F(AidlTest, FailOnDuplicatedIds) { + Options options = Options::From("aidl --lang=java --version 10 -o out IFoo.aidl"); + io_delegate_.SetFileContents("IFoo.aidl", + "interface IFoo {\n" + " void foo() = 3;\n" + " void bar() = 3;\n" + "}"); + EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_)); +} + +TEST_F(AidlTest, FailOnOutOfRangeIds) { + // 16777115 is kLastMetaMethodId + 1 + Options options = Options::From("aidl --lang=java --version 10 -o out IFoo.aidl"); + io_delegate_.SetFileContents("IFoo.aidl", + "interface IFoo {\n" + " void foo() = 3;\n" + " void bar() = 16777115;\n" + "}"); + EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_)); +} + +TEST_F(AidlTest, FailOnPartiallyAssignedIds) { + Options options = Options::From("aidl --lang=java --version 10 -o out IFoo.aidl"); + io_delegate_.SetFileContents("IFoo.aidl", + "interface IFoo {\n" + " void foo() = 3;\n" + " void bar();\n" + "}"); + EXPECT_NE(0, ::android::aidl::compile_aidl(options, io_delegate_)); +} + } // namespace aidl } // namespace android |