diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-04-07 13:24:59 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2016-04-07 16:26:14 -0700 |
commit | 626b3dbf74f02ae630ae0089632f5962340694dc (patch) | |
tree | 21fda93c61d624b598b05cb0bd54a377a8975487 /tools/aapt2/java/AnnotationProcessor_test.cpp | |
parent | 41c1bb8f4a5a1f2f0a23d6cece525eaea50f57b3 (diff) |
AAPT2: Clean up R JavaDoc generation
- Don't generate private attributes in public R.java
- Strip out @SystemApi from comment when generating @android.annotation.SystemApi
- Only emit a single line (up to the first period) of an attribute's comment within
a styleable's attribute table.
Change-Id: Id6316a6861540325934133958939a12074ad4428
Diffstat (limited to 'tools/aapt2/java/AnnotationProcessor_test.cpp')
-rw-r--r-- | tools/aapt2/java/AnnotationProcessor_test.cpp | 62 |
1 files changed, 17 insertions, 45 deletions
diff --git a/tools/aapt2/java/AnnotationProcessor_test.cpp b/tools/aapt2/java/AnnotationProcessor_test.cpp index d3860a5825b2..5a39add48fbd 100644 --- a/tools/aapt2/java/AnnotationProcessor_test.cpp +++ b/tools/aapt2/java/AnnotationProcessor_test.cpp @@ -14,65 +14,37 @@ * limitations under the License. */ -#include "ResourceParser.h" -#include "ResourceTable.h" -#include "ResourceValues.h" #include "java/AnnotationProcessor.h" -#include "test/Builders.h" -#include "test/Context.h" -#include "xml/XmlPullParser.h" - -#include <gtest/gtest.h> +#include "test/Test.h" namespace aapt { -struct AnnotationProcessorTest : public ::testing::Test { - std::unique_ptr<IAaptContext> mContext; - ResourceTable mTable; - - void SetUp() override { - mContext = test::ContextBuilder().build(); - } - - ::testing::AssertionResult parse(const StringPiece& str) { - ResourceParserOptions options; - ResourceParser parser(mContext->getDiagnostics(), &mTable, Source{}, ConfigDescription{}, - options); - std::stringstream in; - in << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" << str; - xml::XmlPullParser xmlParser(in); - if (parser.parse(&xmlParser)) { - return ::testing::AssertionSuccess(); - } - return ::testing::AssertionFailure(); - } -}; +TEST(AnnotationProcessorTest, EmitsDeprecated) { + const char* comment = "Some comment, and it should contain a marker word, " + "something that marks this resource as nor needed. " + "{@deprecated That's the marker! }"; -TEST_F(AnnotationProcessorTest, EmitsDeprecated) { - const char* xmlInput = R"EOF( - <resources> - <declare-styleable name="foo"> - <!-- Some comment, and it should contain - a marker word, something that marks - this resource as nor needed. - {@deprecated That's the marker! } --> - <attr name="autoText" format="boolean" /> - </declare-styleable> - </resources>)EOF"; + AnnotationProcessor processor; + processor.appendComment(comment); - ASSERT_TRUE(parse(xmlInput)); + std::stringstream result; + processor.writeToStream(&result, ""); + std::string annotations = result.str(); - Attribute* attr = test::getValue<Attribute>(&mTable, u"@attr/autoText"); - ASSERT_NE(nullptr, attr); + EXPECT_NE(std::string::npos, annotations.find("@Deprecated")); +} +TEST(AnnotationProcessorTest, EmitsSystemApiAnnotationAndRemovesFromComment) { AnnotationProcessor processor; - processor.appendComment(attr->getComment()); + processor.appendComment("@SystemApi This is a system API"); std::stringstream result; processor.writeToStream(&result, ""); std::string annotations = result.str(); - EXPECT_NE(std::string::npos, annotations.find("@Deprecated")); + EXPECT_NE(std::string::npos, annotations.find("@android.annotation.SystemApi")); + EXPECT_EQ(std::string::npos, annotations.find("@SystemApi")); + EXPECT_NE(std::string::npos, annotations.find("This is a system API")); } } // namespace aapt |