diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-10-19 12:18:14 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2016-10-19 12:18:14 -0700 |
commit | cacb28f2d60858106e2819cc7d95a65e8bda890b (patch) | |
tree | c8ac4af72b0a9599983567029e5680c40f9883a3 /tools/aapt2/ResourceTable_test.cpp | |
parent | 733f0bc08ea0c93d095016a791c2914658d0cdde (diff) |
Use Google3 style guide with .clang-format
Test: style change only, builds ok
Change-Id: I885180e24cb2e7b58cfb4967c3bcb40058ce4078
Diffstat (limited to 'tools/aapt2/ResourceTable_test.cpp')
-rw-r--r-- | tools/aapt2/ResourceTable_test.cpp | 201 |
1 files changed, 95 insertions, 106 deletions
diff --git a/tools/aapt2/ResourceTable_test.cpp b/tools/aapt2/ResourceTable_test.cpp index 4db40a6f4008..a64ad3eb639a 100644 --- a/tools/aapt2/ResourceTable_test.cpp +++ b/tools/aapt2/ResourceTable_test.cpp @@ -14,8 +14,8 @@ * limitations under the License. */ -#include "Diagnostics.h" #include "ResourceTable.h" +#include "Diagnostics.h" #include "ResourceValues.h" #include "test/Test.h" #include "util/Util.h" @@ -27,124 +27,113 @@ namespace aapt { TEST(ResourceTableTest, FailToAddResourceWithBadName) { - ResourceTable table; - - EXPECT_FALSE(table.addResource( - test::parseNameOrDie("android:id/hey,there"), - ConfigDescription{}, "", - test::ValueBuilder<Id>().setSource("test.xml", 21u).build(), - test::getDiagnostics())); - - EXPECT_FALSE(table.addResource( - test::parseNameOrDie("android:id/hey:there"), - ConfigDescription{}, "", - test::ValueBuilder<Id>().setSource("test.xml", 21u).build(), - test::getDiagnostics())); + ResourceTable table; + + EXPECT_FALSE(table.addResource( + test::parseNameOrDie("android:id/hey,there"), ConfigDescription{}, "", + test::ValueBuilder<Id>().setSource("test.xml", 21u).build(), + test::getDiagnostics())); + + EXPECT_FALSE(table.addResource( + test::parseNameOrDie("android:id/hey:there"), ConfigDescription{}, "", + test::ValueBuilder<Id>().setSource("test.xml", 21u).build(), + test::getDiagnostics())); } TEST(ResourceTableTest, AddOneResource) { - ResourceTable table; + ResourceTable table; - EXPECT_TRUE(table.addResource( - test::parseNameOrDie("android:attr/id"), - ConfigDescription{}, "", - test::ValueBuilder<Id>().setSource("test/path/file.xml", 23u).build(), - test::getDiagnostics())); + EXPECT_TRUE(table.addResource( + test::parseNameOrDie("android:attr/id"), ConfigDescription{}, "", + test::ValueBuilder<Id>().setSource("test/path/file.xml", 23u).build(), + test::getDiagnostics())); - ASSERT_NE(nullptr, test::getValue<Id>(&table, "android:attr/id")); + ASSERT_NE(nullptr, test::getValue<Id>(&table, "android:attr/id")); } TEST(ResourceTableTest, AddMultipleResources) { - ResourceTable table; - - ConfigDescription config; - ConfigDescription languageConfig; - memcpy(languageConfig.language, "pl", sizeof(languageConfig.language)); - - EXPECT_TRUE(table.addResource( - test::parseNameOrDie("android:attr/layout_width"), - config, "", - test::ValueBuilder<Id>().setSource("test/path/file.xml", 10u).build(), - test::getDiagnostics())); - - EXPECT_TRUE(table.addResource( - test::parseNameOrDie("android:attr/id"), - config, "", - test::ValueBuilder<Id>().setSource("test/path/file.xml", 12u).build(), - test::getDiagnostics())); - - EXPECT_TRUE(table.addResource( - test::parseNameOrDie("android:string/ok"), - config, "", - test::ValueBuilder<Id>().setSource("test/path/file.xml", 14u).build(), - test::getDiagnostics())); - - EXPECT_TRUE(table.addResource( - test::parseNameOrDie("android:string/ok"), - languageConfig, "", - test::ValueBuilder<BinaryPrimitive>(android::Res_value{}) - .setSource("test/path/file.xml", 20u) - .build(), - test::getDiagnostics())); - - ASSERT_NE(nullptr, test::getValue<Id>(&table, "android:attr/layout_width")); - ASSERT_NE(nullptr, test::getValue<Id>(&table, "android:attr/id")); - ASSERT_NE(nullptr, test::getValue<Id>(&table, "android:string/ok")); - ASSERT_NE(nullptr, test::getValueForConfig<BinaryPrimitive>(&table, "android:string/ok", - languageConfig)); + ResourceTable table; + + ConfigDescription config; + ConfigDescription languageConfig; + memcpy(languageConfig.language, "pl", sizeof(languageConfig.language)); + + EXPECT_TRUE(table.addResource( + test::parseNameOrDie("android:attr/layout_width"), config, "", + test::ValueBuilder<Id>().setSource("test/path/file.xml", 10u).build(), + test::getDiagnostics())); + + EXPECT_TRUE(table.addResource( + test::parseNameOrDie("android:attr/id"), config, "", + test::ValueBuilder<Id>().setSource("test/path/file.xml", 12u).build(), + test::getDiagnostics())); + + EXPECT_TRUE(table.addResource( + test::parseNameOrDie("android:string/ok"), config, "", + test::ValueBuilder<Id>().setSource("test/path/file.xml", 14u).build(), + test::getDiagnostics())); + + EXPECT_TRUE(table.addResource( + test::parseNameOrDie("android:string/ok"), languageConfig, "", + test::ValueBuilder<BinaryPrimitive>(android::Res_value{}) + .setSource("test/path/file.xml", 20u) + .build(), + test::getDiagnostics())); + + ASSERT_NE(nullptr, test::getValue<Id>(&table, "android:attr/layout_width")); + ASSERT_NE(nullptr, test::getValue<Id>(&table, "android:attr/id")); + ASSERT_NE(nullptr, test::getValue<Id>(&table, "android:string/ok")); + ASSERT_NE(nullptr, test::getValueForConfig<BinaryPrimitive>( + &table, "android:string/ok", languageConfig)); } TEST(ResourceTableTest, OverrideWeakResourceValue) { - ResourceTable table; - - ASSERT_TRUE(table.addResource( - test::parseNameOrDie("android:attr/foo"), - ConfigDescription{}, "", - util::make_unique<Attribute>(true), - test::getDiagnostics())); - - Attribute* attr = test::getValue<Attribute>(&table, "android:attr/foo"); - ASSERT_NE(nullptr, attr); - EXPECT_TRUE(attr->isWeak()); - - ASSERT_TRUE(table.addResource( - test::parseNameOrDie("android:attr/foo"), - ConfigDescription{}, "", - util::make_unique<Attribute>(false), - test::getDiagnostics())); - - attr = test::getValue<Attribute>(&table, "android:attr/foo"); - ASSERT_NE(nullptr, attr); - EXPECT_FALSE(attr->isWeak()); + ResourceTable table; + + ASSERT_TRUE(table.addResource( + test::parseNameOrDie("android:attr/foo"), ConfigDescription{}, "", + util::make_unique<Attribute>(true), test::getDiagnostics())); + + Attribute* attr = test::getValue<Attribute>(&table, "android:attr/foo"); + ASSERT_NE(nullptr, attr); + EXPECT_TRUE(attr->isWeak()); + + ASSERT_TRUE(table.addResource( + test::parseNameOrDie("android:attr/foo"), ConfigDescription{}, "", + util::make_unique<Attribute>(false), test::getDiagnostics())); + + attr = test::getValue<Attribute>(&table, "android:attr/foo"); + ASSERT_NE(nullptr, attr); + EXPECT_FALSE(attr->isWeak()); } TEST(ResourceTableTest, ProductVaryingValues) { - ResourceTable table; - - EXPECT_TRUE(table.addResource(test::parseNameOrDie("android:string/foo"), - test::parseConfigOrDie("land"), "tablet", - util::make_unique<Id>(), - test::getDiagnostics())); - EXPECT_TRUE(table.addResource(test::parseNameOrDie("android:string/foo"), - test::parseConfigOrDie("land"), "phone", - util::make_unique<Id>(), - test::getDiagnostics())); - - EXPECT_NE(nullptr, test::getValueForConfigAndProduct<Id>(&table, "android:string/foo", - test::parseConfigOrDie("land"), - "tablet")); - EXPECT_NE(nullptr, test::getValueForConfigAndProduct<Id>(&table, "android:string/foo", - test::parseConfigOrDie("land"), - "phone")); - - Maybe<ResourceTable::SearchResult> sr = table.findResource( - test::parseNameOrDie("android:string/foo")); - AAPT_ASSERT_TRUE(sr); - std::vector<ResourceConfigValue*> values = sr.value().entry->findAllValues( - test::parseConfigOrDie("land")); - ASSERT_EQ(2u, values.size()); - EXPECT_EQ(std::string("phone"), values[0]->product); - EXPECT_EQ(std::string("tablet"), values[1]->product); + ResourceTable table; + + EXPECT_TRUE(table.addResource(test::parseNameOrDie("android:string/foo"), + test::parseConfigOrDie("land"), "tablet", + util::make_unique<Id>(), + test::getDiagnostics())); + EXPECT_TRUE(table.addResource(test::parseNameOrDie("android:string/foo"), + test::parseConfigOrDie("land"), "phone", + util::make_unique<Id>(), + test::getDiagnostics())); + + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<Id>( + &table, "android:string/foo", + test::parseConfigOrDie("land"), "tablet")); + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<Id>( + &table, "android:string/foo", + test::parseConfigOrDie("land"), "phone")); + + Maybe<ResourceTable::SearchResult> sr = + table.findResource(test::parseNameOrDie("android:string/foo")); + AAPT_ASSERT_TRUE(sr); + std::vector<ResourceConfigValue*> values = + sr.value().entry->findAllValues(test::parseConfigOrDie("land")); + ASSERT_EQ(2u, values.size()); + EXPECT_EQ(std::string("phone"), values[0]->product); + EXPECT_EQ(std::string("tablet"), values[1]->product); } -} // namespace aapt +} // namespace aapt |