From 74605cd40256ca75b44cc3182eeeb886c92d737c Mon Sep 17 00:00:00 2001 From: Adam Lesinski Date: Thu, 3 Mar 2016 15:39:50 -0800 Subject: AAPT2: Emit proper doclava comments in R.java Bug:25958912 Change-Id: I663f2eb5bd54e3c3288ce9bc186c928f0a014f93 --- tools/aapt2/java/JavaClassGenerator_test.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'tools/aapt2/java/JavaClassGenerator_test.cpp') 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 table = test::ResourceTableBuilder() + .setPackageId(u"android", 0x01) + .addValue(u"@android:attr/one", util::make_unique(attr)) + .addValue(u"@android:styleable/Container", + std::unique_ptr(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 -- cgit v1.2.3