summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceValues_test.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-06-01 15:22:57 -0700
committerAdam Lesinski <adamlesinski@google.com>2017-06-02 16:48:38 -0700
commitbab4ef56d7803f3a50ccfaca2729509338fcbb23 (patch)
tree3d3c1ad103f88f6ca60c46fc31872dee40244b3e /tools/aapt2/ResourceValues_test.cpp
parentd6fb3081d9ddd6384d7e764308e2967ce672d3e5 (diff)
AAPT2: Allow undefined resources (placeholders)
A resource defined like so: <item type="drawable" name="foo" /> should be assigned the value @null. The only exception is for <string> resources, which are given the empty string value (since <string></string> is ambiguous). The decision to use "" is based off the fact that old AAPT used to assign "" to all undefined resources, even non-string ones. Bug: 38425050 Test: make aapt2_tests Change-Id: Ib3e0f6f83d16ddd8b279c9fd44a07a37867b85e9
Diffstat (limited to 'tools/aapt2/ResourceValues_test.cpp')
-rw-r--r--tools/aapt2/ResourceValues_test.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/aapt2/ResourceValues_test.cpp b/tools/aapt2/ResourceValues_test.cpp
index e154d93b6f85..69f8e67530f6 100644
--- a/tools/aapt2/ResourceValues_test.cpp
+++ b/tools/aapt2/ResourceValues_test.cpp
@@ -180,4 +180,14 @@ TEST(ResourceValuesTest, StyleMerges) {
EXPECT_TRUE(a->Equals(expected.get()));
}
+// TYPE_NULL is encoded as TYPE_REFERENCE with a value of 0. This is represented in AAPT2
+// by a default constructed Reference value.
+TEST(ResourcesValuesTest, EmptyReferenceFlattens) {
+ android::Res_value value = {};
+ ASSERT_TRUE(Reference().Flatten(&value));
+
+ EXPECT_EQ(android::Res_value::TYPE_REFERENCE, value.dataType);
+ EXPECT_EQ(0x0u, value.data);
+}
+
} // namespace aapt