summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceValues_test.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-05-30 15:15:58 -0700
committerAdam Lesinski <adamlesinski@google.com>2017-05-31 10:09:06 -0700
commit5924d8c9ab7bd8614e8bd99864903ce9d50f3bf7 (patch)
treef094afb0142ab4a81faff62f37be306ca0587c33 /tools/aapt2/ResourceValues_test.cpp
parentbacaffa497de1877657f9cb3f59a82e3955f0f75 (diff)
AAPT2: Allow merging of Style attributes from overlays
Previously style overlays would completely override an existing style. To be compatible with AAPT, styles now merge with the overlay, allowing the overlay's attributes and parent to take precedence. Bug: 38355988 Test: make aapt2_tests Change-Id: Id25c7240050a43e6a4a177c6e3d51e048d0cceb5
Diffstat (limited to 'tools/aapt2/ResourceValues_test.cpp')
-rw-r--r--tools/aapt2/ResourceValues_test.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/aapt2/ResourceValues_test.cpp b/tools/aapt2/ResourceValues_test.cpp
index 692258003471..e154d93b6f85 100644
--- a/tools/aapt2/ResourceValues_test.cpp
+++ b/tools/aapt2/ResourceValues_test.cpp
@@ -148,4 +148,36 @@ TEST(ResourceValuesTest, StyleClone) {
EXPECT_TRUE(a->Equals(b.get()));
}
+TEST(ResourceValuesTest, StyleMerges) {
+ StringPool pool_a;
+ StringPool pool_b;
+
+ std::unique_ptr<Style> a =
+ test::StyleBuilder()
+ .SetParent("android:style/Parent")
+ .AddItem("android:attr/a", util::make_unique<String>(pool_a.MakeRef("FooA")))
+ .AddItem("android:attr/b", util::make_unique<String>(pool_a.MakeRef("FooB")))
+ .Build();
+
+ std::unique_ptr<Style> b =
+ test::StyleBuilder()
+ .SetParent("android:style/OverlayParent")
+ .AddItem("android:attr/c", util::make_unique<String>(pool_b.MakeRef("OverlayFooC")))
+ .AddItem("android:attr/a", util::make_unique<String>(pool_b.MakeRef("OverlayFooA")))
+ .Build();
+
+ a->MergeWith(b.get(), &pool_a);
+
+ StringPool pool;
+ std::unique_ptr<Style> expected =
+ test::StyleBuilder()
+ .SetParent("android:style/OverlayParent")
+ .AddItem("android:attr/a", util::make_unique<String>(pool.MakeRef("OverlayFooA")))
+ .AddItem("android:attr/b", util::make_unique<String>(pool.MakeRef("FooB")))
+ .AddItem("android:attr/c", util::make_unique<String>(pool.MakeRef("OverlayFooC")))
+ .Build();
+
+ EXPECT_TRUE(a->Equals(expected.get()));
+}
+
} // namespace aapt