diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-03-03 15:39:50 -0800 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2016-03-04 20:06:05 -0800 |
commit | 74605cd40256ca75b44cc3182eeeb886c92d737c (patch) | |
tree | aeaba146e014328caa3eafc257b3c6bad73bb53e /tools/aapt2/java/JavaClassGenerator_test.cpp | |
parent | 626a69f34536d01db0847df0051199beaecce060 (diff) |
AAPT2: Emit proper doclava comments in R.java
Bug:25958912
Change-Id: I663f2eb5bd54e3c3288ce9bc186c928f0a014f93
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 |