diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-03-05 05:39:00 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-03-05 05:39:01 +0000 |
commit | 5b37ef489a4090da3643041c8d0e6efa282ad8b6 (patch) | |
tree | 20968dc68cfd1f12d8fe30a3ed9993b75057830c /tools/aapt2/java/JavaClassGenerator_test.cpp | |
parent | c7f8f45c69323228cc2ebf6a02028c0397f512ca (diff) | |
parent | 74605cd40256ca75b44cc3182eeeb886c92d737c (diff) |
Merge "AAPT2: Emit proper doclava comments in R.java" into nyc-dev
Diffstat (limited to 'tools/aapt2/java/JavaClassGenerator_test.cpp')
-rw-r--r-- | tools/aapt2/java/JavaClassGenerator_test.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tools/aapt2/java/JavaClassGenerator_test.cpp b/tools/aapt2/java/JavaClassGenerator_test.cpp index e9e788167966..63d38a8981f4 100644 --- a/tools/aapt2/java/JavaClassGenerator_test.cpp +++ b/tools/aapt2/java/JavaClassGenerator_test.cpp @@ -227,7 +227,32 @@ TEST(JavaClassGeneratorTest, CommentsForEnumAndFlagAttributesArePresent) { } TEST(JavaClassGeneratorTest, CommentsForStyleablesAndNestedAttributesArePresent) { + Attribute attr(false); + attr.setComment(StringPiece16(u"This is an attribute")); + Styleable styleable; + styleable.entries.push_back(Reference(test::parseNameOrDie(u"@android:attr/one"))); + styleable.setComment(StringPiece16(u"This is a styleable")); + + std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder() + .setPackageId(u"android", 0x01) + .addValue(u"@android:attr/one", util::make_unique<Attribute>(attr)) + .addValue(u"@android:styleable/Container", + std::unique_ptr<Styleable>(styleable.clone(nullptr))) + .build(); + + JavaClassGeneratorOptions options; + options.useFinal = false; + JavaClassGenerator generator(table.get(), options); + + std::stringstream out; + ASSERT_TRUE(generator.generate(u"android", &out)); + std::string actual = out.str(); + + EXPECT_NE(std::string::npos, actual.find("@attr name android:one")); + EXPECT_NE(std::string::npos, actual.find("@attr description")); + EXPECT_NE(std::string::npos, actual.find(util::utf16ToUtf8(attr.getComment()))); + EXPECT_NE(std::string::npos, actual.find(util::utf16ToUtf8(styleable.getComment()))); } } // namespace aapt |