diff options
author | Adam Lesinski <adamlesinski@google.com> | 2017-02-16 12:05:42 -0800 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2017-02-22 11:16:13 -0800 |
commit | ceb9b2f80f853059233cdd29057f39a5960a74ae (patch) | |
tree | 9093e8537319a97d8a2cbd8d4f0042c81de5ff8e /tools/aapt2/java/JavaClassGenerator_test.cpp | |
parent | f9bd2944694539f1dce74d420156cc50bbb4af14 (diff) |
AAPT2: Shared library support
Test: make aapt2_tests
Change-Id: I98dddf1367e6c0ac425bb20be46e6ff05f4f2f45
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 |