diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2017-02-22 21:03:09 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-02-22 21:03:14 +0000 |
commit | d43b676fccbbf1d5fc102054b5a4797217d70f2d (patch) | |
tree | 4371ccd820599f9c54f50bd430d40a9dffcc6742 /tools/aapt2/java/JavaClassGenerator_test.cpp | |
parent | ab7bc7afd7a5f9a994e55402795590df57fcb0bf (diff) | |
parent | ceb9b2f80f853059233cdd29057f39a5960a74ae (diff) |
Merge "AAPT2: Shared library support"
Diffstat (limited to 'tools/aapt2/java/JavaClassGenerator_test.cpp')
-rw-r--r-- | tools/aapt2/java/JavaClassGenerator_test.cpp | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/tools/aapt2/java/JavaClassGenerator_test.cpp b/tools/aapt2/java/JavaClassGenerator_test.cpp index 55c5cb26892f..bcb2d4f42eda 100644 --- a/tools/aapt2/java/JavaClassGenerator_test.cpp +++ b/tools/aapt2/java/JavaClassGenerator_test.cpp @@ -293,8 +293,7 @@ TEST(JavaClassGeneratorTest, CommentsForSimpleResourcesArePresent) { TEST(JavaClassGeneratorTest, CommentsForEnumAndFlagAttributesArePresent) {} -TEST(JavaClassGeneratorTest, - CommentsForStyleablesAndNestedAttributesArePresent) { +TEST(JavaClassGeneratorTest, CommentsForStyleablesAndNestedAttributesArePresent) { Attribute attr(false); attr.SetComment(StringPiece("This is an attribute")); @@ -364,4 +363,33 @@ TEST(JavaClassGeneratorTest, CommentsForRemovedAttributesAreNotPresentInClass) { EXPECT_EQ(std::string::npos, actual.find("removed", pos + 1)); } +TEST(JavaClassGeneratorTest, GenerateOnResourcesLoadedCallbackForSharedLibrary) { + std::unique_ptr<ResourceTable> table = + test::ResourceTableBuilder() + .SetPackageId("android", 0x00) + .AddValue("android:attr/foo", ResourceId(0x00010000), util::make_unique<Attribute>(false)) + .AddValue("android:id/foo", ResourceId(0x00020000), util::make_unique<Id>()) + .AddValue( + "android:style/foo", ResourceId(0x00030000), + test::StyleBuilder() + .AddItem("android:attr/foo", ResourceId(0x00010000), util::make_unique<Id>()) + .Build()) + .Build(); + + std::unique_ptr<IAaptContext> context = + test::ContextBuilder().SetPackageId(0x00).SetCompilationPackage("android").Build(); + + JavaClassGeneratorOptions options; + options.use_final = false; + options.generate_rewrite_callback = true; + JavaClassGenerator generator(context.get(), table.get(), options); + + std::stringstream out; + ASSERT_TRUE(generator.Generate("android", &out)); + + std::string actual = out.str(); + + EXPECT_NE(std::string::npos, actual.find("onResourcesLoaded")); +} + } // namespace aapt |