diff options
author | Adam Lesinski <adamlesinski@google.com> | 2015-05-14 14:25:36 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2015-05-15 15:10:58 -0700 |
commit | 2738c96d998dedfae5b4670d588d0cd299c4ca0f (patch) | |
tree | 76b8571676d42a9c0b3bfa00f1937eebf2c05698 /libs/androidfw/tests | |
parent | 038959e851603500eb39b52fef33cbe75dbd73e3 (diff) | |
download | frameworks_base-2738c96d998dedfae5b4670d588d0cd299c4ca0f.zip frameworks_base-2738c96d998dedfae5b4670d588d0cd299c4ca0f.tar.gz frameworks_base-2738c96d998dedfae5b4670d588d0cd299c4ca0f.tar.bz2 |
Add -round and -notround qualifier to android runtime/aapt
The round qualifier denotes a device with a screen shape that
is round. The qualifier shows up after the 'long/notlong' qualifier
and before the orientation 'port/land/square' qualifiers.
Change-Id: I3044258b2703a9165694b79725bade770fa6cea1
Diffstat (limited to 'libs/androidfw/tests')
-rw-r--r-- | libs/androidfw/tests/Config_test.cpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/libs/androidfw/tests/Config_test.cpp b/libs/androidfw/tests/Config_test.cpp index ef30df4..738947a 100644 --- a/libs/androidfw/tests/Config_test.cpp +++ b/libs/androidfw/tests/Config_test.cpp @@ -100,4 +100,82 @@ TEST(ConfigTest, shouldSelectBestDensityWhenNoneSpecified) { ASSERT_EQ(expectedBest, selectBest(deviceConfig, configs)); } +TEST(ConfigTest, shouldMatchRoundQualifier) { + ResTable_config deviceConfig; + memset(&deviceConfig, 0, sizeof(deviceConfig)); + + ResTable_config roundConfig; + memset(&roundConfig, 0, sizeof(roundConfig)); + roundConfig.screenLayout2 = ResTable_config::SCREENROUND_YES; + + EXPECT_FALSE(roundConfig.match(deviceConfig)); + + deviceConfig.screenLayout2 = ResTable_config::SCREENROUND_YES; + + EXPECT_TRUE(roundConfig.match(deviceConfig)); + + deviceConfig.screenLayout2 = ResTable_config::SCREENROUND_NO; + + EXPECT_FALSE(roundConfig.match(deviceConfig)); + + ResTable_config notRoundConfig; + memset(¬RoundConfig, 0, sizeof(notRoundConfig)); + notRoundConfig.screenLayout2 = ResTable_config::SCREENROUND_NO; + + EXPECT_TRUE(notRoundConfig.match(deviceConfig)); +} + +TEST(ConfigTest, RoundQualifierShouldHaveStableSortOrder) { + ResTable_config defaultConfig; + memset(&defaultConfig, 0, sizeof(defaultConfig)); + + ResTable_config longConfig = defaultConfig; + longConfig.screenLayout = ResTable_config::SCREENLONG_YES; + + ResTable_config longRoundConfig = longConfig; + longRoundConfig.screenLayout2 = ResTable_config::SCREENROUND_YES; + + ResTable_config longRoundPortConfig = longConfig; + longRoundPortConfig.orientation = ResTable_config::ORIENTATION_PORT; + + EXPECT_TRUE(longConfig.compare(longRoundConfig) < 0); + EXPECT_TRUE(longConfig.compareLogical(longRoundConfig) < 0); + EXPECT_TRUE(longRoundConfig.compare(longConfig) > 0); + EXPECT_TRUE(longRoundConfig.compareLogical(longConfig) > 0); + + EXPECT_TRUE(longRoundConfig.compare(longRoundPortConfig) < 0); + EXPECT_TRUE(longRoundConfig.compareLogical(longRoundPortConfig) < 0); + EXPECT_TRUE(longRoundPortConfig.compare(longRoundConfig) > 0); + EXPECT_TRUE(longRoundPortConfig.compareLogical(longRoundConfig) > 0); +} + +TEST(ConfigTest, ScreenShapeHasCorrectDiff) { + ResTable_config defaultConfig; + memset(&defaultConfig, 0, sizeof(defaultConfig)); + + ResTable_config roundConfig = defaultConfig; + roundConfig.screenLayout2 = ResTable_config::SCREENROUND_YES; + + EXPECT_EQ(defaultConfig.diff(roundConfig), ResTable_config::CONFIG_SCREEN_ROUND); +} + +TEST(ConfigTest, RoundIsMoreSpecific) { + ResTable_config deviceConfig; + memset(&deviceConfig, 0, sizeof(deviceConfig)); + deviceConfig.screenLayout2 = ResTable_config::SCREENROUND_YES; + deviceConfig.screenLayout = ResTable_config::SCREENLONG_YES; + + ResTable_config targetConfigA; + memset(&targetConfigA, 0, sizeof(targetConfigA)); + + ResTable_config targetConfigB = targetConfigA; + targetConfigB.screenLayout = ResTable_config::SCREENLONG_YES; + + ResTable_config targetConfigC = targetConfigB; + targetConfigC.screenLayout2 = ResTable_config::SCREENROUND_YES; + + EXPECT_TRUE(targetConfigB.isBetterThan(targetConfigA, &deviceConfig)); + EXPECT_TRUE(targetConfigC.isBetterThan(targetConfigB, &deviceConfig)); +} + } // namespace android. |