diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-04-11 20:03:01 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2016-04-13 13:25:09 -0700 |
commit | 5520581b5f043fb858b5b2044ff33ad8545a6d38 (patch) | |
tree | ae32bf44e2c1bd7b12fbb5136399c72c8d30dc7d /libs/androidfw/tests/ResTable_test.cpp | |
parent | 1ee2dd2f5fb10cd0e6a4d3d368c1e24d3ec417a2 (diff) |
Optimize ResTable::getLocales() to improve bindApplication performance
Change from linear searching for uniqueness to binary search.
Bug:27198799
Change-Id: Ifa4672929df286c4693ab1f77716f08945941b0c
Diffstat (limited to 'libs/androidfw/tests/ResTable_test.cpp')
-rw-r--r-- | libs/androidfw/tests/ResTable_test.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libs/androidfw/tests/ResTable_test.cpp b/libs/androidfw/tests/ResTable_test.cpp index 7cd7fb5cd711..b8b46259f0d1 100644 --- a/libs/androidfw/tests/ResTable_test.cpp +++ b/libs/androidfw/tests/ResTable_test.cpp @@ -39,8 +39,20 @@ namespace { */ #include "data/basic/basic_arsc.h" +/** + * Include a binary library resource table. + * + * Package: com.android.test.basic + */ #include "data/lib/lib_arsc.h" +/** + * Include a system resource table. + * + * Package: android + */ +#include "data/system/system_arsc.h" + TEST(ResTableTest, shouldLoadSuccessfully) { ResTable table; ASSERT_EQ(NO_ERROR, table.add(basic_arsc, basic_arsc_len)); @@ -324,4 +336,25 @@ TEST(ResTableTest, ShareButDontModifyResTable) { ASSERT_EQ(uint32_t(600), val.data); } +TEST(ResTableTest, GetConfigurationsReturnsUniqueList) { + ResTable table; + ASSERT_EQ(NO_ERROR, table.add(system_arsc, system_arsc_len)); + ASSERT_EQ(NO_ERROR, table.add(basic_arsc, basic_arsc_len)); + + ResTable_config configSv; + memset(&configSv, 0, sizeof(configSv)); + configSv.language[0] = 's'; + configSv.language[1] = 'v'; + + Vector<ResTable_config> configs; + table.getConfigurations(&configs); + + EXPECT_EQ(1, std::count(configs.begin(), configs.end(), configSv)); + + Vector<String8> locales; + table.getLocales(&locales); + + EXPECT_EQ(1, std::count(locales.begin(), locales.end(), String8("sv"))); +} + } // namespace |