From 0a0bf365553c614a7ca1ab96a1aa71047fc48081 Mon Sep 17 00:00:00 2001 From: Ryan Mitchell Date: Mon, 14 Sep 2020 13:11:22 -0700 Subject: 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: sw600dp-v13 sw600dp-hdpi-v13 sw800dp-hdpi-v13 sw800dp-xxhdpi-v13 New behavior: sw600dp-v13 sw600dp-hdpi-v13 sw800dp-hdpi-v13 sw800dp-xxhdpi-v13 Bug: 167944889 Test: aapt2_tests Merged-In: Ie9fba4c4b74af2b3bbf8fc6432539a99f8647634 Change-Id: Ie9fba4c4b74af2b3bbf8fc6432539a99f8647634 --- tools/aapt2/DominatorTree_test.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tools') 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> configs; + configs.push_back(util::make_unique(ConfigDescription::DefaultConfig(), "")); + configs.push_back(util::make_unique(sw600_config, "")); + configs.push_back(util::make_unique(sw600_hdpi_config, "")); + configs.push_back(util::make_unique(sw800_hdpi_config, "")); + configs.push_back(util::make_unique(sw800_xxhdpi_config, "")); + + DominatorTree tree(configs); + PrettyPrinter printer; + + std::string expected = + "\n" + " sw600dp-v13\n" + " sw600dp-hdpi-v13\n" + " sw800dp-hdpi-v13\n" + " sw800dp-xxhdpi-v13\n"; + EXPECT_EQ(expected, printer.ToString(&tree)); +} + + } // namespace aapt -- cgit v1.2.3