summaryrefslogtreecommitdiff
path: root/tools/aapt2/DominatorTree_test.cpp
diff options
context:
space:
mode:
authorRyan Mitchell <rtmitchell@google.com>2020-09-14 13:11:22 -0700
committerRyan Mitchell <rtmitchell@google.com>2020-09-17 08:18:27 -0700
commit0a0bf365553c614a7ca1ab96a1aa71047fc48081 (patch)
tree22060764946404390d7f3c6937d84537f98234f9 /tools/aapt2/DominatorTree_test.cpp
parent4cb1ece9d1f0dfc61f15ad0e568748604846ccd3 (diff)
Make configs differing only in density siblings
Configurations differing only in density value will match the same device configuration at runtime; therefore, they should be considered sibling configurations in the dominator tree. So, given configurations A and B: 1) If A has a density defined and B does not, A must never dominate B. 2) If A and B both have densities defined, neither must dominate the other. Previous behavior: <default> sw600dp-v13 sw600dp-hdpi-v13 sw800dp-hdpi-v13 sw800dp-xxhdpi-v13 New behavior: <default> sw600dp-v13 sw600dp-hdpi-v13 sw800dp-hdpi-v13 sw800dp-xxhdpi-v13 Bug: 167944889 Test: aapt2_tests Merged-In: Ie9fba4c4b74af2b3bbf8fc6432539a99f8647634 Change-Id: Ie9fba4c4b74af2b3bbf8fc6432539a99f8647634
Diffstat (limited to 'tools/aapt2/DominatorTree_test.cpp')
-rw-r--r--tools/aapt2/DominatorTree_test.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/aapt2/DominatorTree_test.cpp b/tools/aapt2/DominatorTree_test.cpp
index fe4f951a5cd0..3e49034310c3 100644
--- a/tools/aapt2/DominatorTree_test.cpp
+++ b/tools/aapt2/DominatorTree_test.cpp
@@ -173,4 +173,30 @@ TEST(DominatorTreeTest, LocalesAreNeverDominated) {
EXPECT_EQ(expected, printer.ToString(&tree));
}
+TEST(DominatorTreeTest, NonZeroDensitiesMatch) {
+ const ConfigDescription sw600_config = test::ParseConfigOrDie("sw600dp");
+ const ConfigDescription sw600_hdpi_config = test::ParseConfigOrDie("sw600dp-hdpi");
+ const ConfigDescription sw800_hdpi_config = test::ParseConfigOrDie("sw800dp-hdpi");
+ const ConfigDescription sw800_xxhdpi_config = test::ParseConfigOrDie("sw800dp-xxhdpi");
+
+ std::vector<std::unique_ptr<ResourceConfigValue>> configs;
+ configs.push_back(util::make_unique<ResourceConfigValue>(ConfigDescription::DefaultConfig(), ""));
+ configs.push_back(util::make_unique<ResourceConfigValue>(sw600_config, ""));
+ configs.push_back(util::make_unique<ResourceConfigValue>(sw600_hdpi_config, ""));
+ configs.push_back(util::make_unique<ResourceConfigValue>(sw800_hdpi_config, ""));
+ configs.push_back(util::make_unique<ResourceConfigValue>(sw800_xxhdpi_config, ""));
+
+ DominatorTree tree(configs);
+ PrettyPrinter printer;
+
+ std::string expected =
+ "<default>\n"
+ " sw600dp-v13\n"
+ " sw600dp-hdpi-v13\n"
+ " sw800dp-hdpi-v13\n"
+ " sw800dp-xxhdpi-v13\n";
+ EXPECT_EQ(expected, printer.ToString(&tree));
+}
+
+
} // namespace aapt