diff options
author | Treehugger Robot <treehugger-gerrit@google.com> | 2020-09-17 20:48:17 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-09-17 20:48:17 +0000 |
commit | 26d31a447a3e6fa7bc706d9e1564661156862206 (patch) | |
tree | 34244aa2d9c8cfcdd5a1a5fde177f52f8a42c4db | |
parent | b145311a8d9e37e79e858892c235b6a748adeed0 (diff) | |
parent | 93cd93c3b15209e3dda86712b720fccdf9143e56 (diff) |
Merge "Make configs differing only in density siblings" am: db0a92a881 am: 93cd93c3b1
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1430088
Change-Id: I9578e7ae692b428c1c50caae2de7118a6eae498a
-rw-r--r-- | libs/androidfw/include/androidfw/ConfigDescription.h | 5 | ||||
-rw-r--r-- | tools/aapt2/DominatorTree_test.cpp | 26 |
2 files changed, 28 insertions, 3 deletions
diff --git a/libs/androidfw/include/androidfw/ConfigDescription.h b/libs/androidfw/include/androidfw/ConfigDescription.h index acf413aeaf91..61d10cd4e55b 100644 --- a/libs/androidfw/include/androidfw/ConfigDescription.h +++ b/libs/androidfw/include/androidfw/ConfigDescription.h @@ -177,9 +177,8 @@ inline ConfigDescription& ConfigDescription::operator=(ConfigDescription&& o) no return *this; } -inline bool ConfigDescription::MatchWithDensity( - const ConfigDescription& o) const { - return match(o) && (density == 0 || density == o.density); +inline bool ConfigDescription::MatchWithDensity(const ConfigDescription& o) const { + return match(o) && (density == 0 || o.density != 0); } inline bool ConfigDescription::operator<(const ConfigDescription& o) const { 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 |