From feaf99fa1b7563f15dbd4211718a6cfb7a3cc3c8 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Fri, 6 May 2016 17:16:06 +0100 Subject: Stop emitting javadoc for @removed attributes. We need the attributes to remain public because people might still be linking against them, but we don't want them showing up in the documentation any more. Them showing up in the documentation also had the side effect that it would accidentally mark the parent class of attributes as @removed, which was not intended. Bug: 28663748 Change-Id: I2f6eb09455fddf1086e6b24bc3bea5292e8e32b7 --- tools/aapt2/java/JavaClassGenerator_test.cpp | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 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 7d0aa83a0fb8..46266b3f3e89 100644 --- a/tools/aapt2/java/JavaClassGenerator_test.cpp +++ b/tools/aapt2/java/JavaClassGenerator_test.cpp @@ -289,4 +289,37 @@ TEST(JavaClassGeneratorTest, CommentsForStyleablesAndNestedAttributesArePresent) EXPECT_NE(std::string::npos, actual.find(util::utf16ToUtf8(styleable.getComment()))); } +TEST(JavaClassGeneratorTest, CommentsForRemovedAttributesAreNotPresentInClass) { + Attribute attr(false); + attr.setComment(StringPiece16(u"@removed")); + + + std::unique_ptr table = test::ResourceTableBuilder() + .setPackageId(u"android", 0x01) + .addValue(u"@android:attr/one", util::make_unique(attr)) + .build(); + + std::unique_ptr context = test::ContextBuilder() + .addSymbolSource(util::make_unique(table.get())) + .setNameManglerPolicy(NameManglerPolicy{ u"android" }) + .build(); + JavaClassGeneratorOptions options; + options.useFinal = false; + JavaClassGenerator generator(context.get(), table.get(), options); + std::stringstream out; + ASSERT_TRUE(generator.generate(u"android", &out)); + std::string actual = out.str(); + + std::cout << actual << std::endl; + + EXPECT_EQ(std::string::npos, actual.find("@attr name android:one")); + EXPECT_EQ(std::string::npos, actual.find("@attr description")); + + // We should find @removed only in the attribute javadoc and not anywhere else (i.e. the class + // javadoc). + const size_t pos = actual.find("@removed"); + EXPECT_NE(std::string::npos, pos); + EXPECT_EQ(std::string::npos, actual.find("@removed", pos + 1)); +} + } // namespace aapt -- cgit v1.2.3