diff options
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 |