diff options
author | Adam Lesinski <adamlesinski@google.com> | 2016-07-08 15:00:32 -0700 |
---|---|---|
committer | Adam Lesinski <adamlesinski@google.com> | 2016-07-13 17:45:28 -0700 |
commit | d0f116b619feede0cfdb647157ce5ab4d50a1c46 (patch) | |
tree | 5b2a8663602ba2b267890ff85d3cf5618ac922b5 /tools/aapt2/ResourceTable_test.cpp | |
parent | aaac91f4a00a9968ef107ea143e6f2f669f762f1 (diff) |
AAPT2: Remove usage of u16string
For legacy reasons, we kept around the use of UTF-16 internally
in AAPT2. We don't need this and this CL removes all instances of
std::u16string and StringPiece16. The only places still needed
are when interacting with the ResTable APIs that only operate in
UTF16.
Change-Id: I492475b84bb9014fa13bf992cff447ee7a5fe588
Diffstat (limited to 'tools/aapt2/ResourceTable_test.cpp')
-rw-r--r-- | tools/aapt2/ResourceTable_test.cpp | 83 |
1 files changed, 40 insertions, 43 deletions
diff --git a/tools/aapt2/ResourceTable_test.cpp b/tools/aapt2/ResourceTable_test.cpp index d6c52ab83d93..cf6660cbff28 100644 --- a/tools/aapt2/ResourceTable_test.cpp +++ b/tools/aapt2/ResourceTable_test.cpp @@ -17,12 +17,10 @@ #include "Diagnostics.h" #include "ResourceTable.h" #include "ResourceValues.h" +#include "test/Test.h" #include "util/Util.h" -#include "test/Builders.h" - #include <algorithm> -#include <gtest/gtest.h> #include <ostream> #include <string> @@ -32,13 +30,13 @@ TEST(ResourceTableTest, FailToAddResourceWithBadName) { ResourceTable table; EXPECT_FALSE(table.addResource( - ResourceNameRef(u"android", ResourceType::kId, u"hey,there"), + test::parseNameOrDie("@android:id/hey,there"), ConfigDescription{}, "", test::ValueBuilder<Id>().setSource("test.xml", 21u).build(), test::getDiagnostics())); EXPECT_FALSE(table.addResource( - ResourceNameRef(u"android", ResourceType::kId, u"hey:there"), + test::parseNameOrDie("@android:id/hey:there"), ConfigDescription{}, "", test::ValueBuilder<Id>().setSource("test.xml", 21u).build(), test::getDiagnostics())); @@ -47,14 +45,13 @@ TEST(ResourceTableTest, FailToAddResourceWithBadName) { TEST(ResourceTableTest, AddOneResource) { ResourceTable table; - EXPECT_TRUE(table.addResource(test::parseNameOrDie(u"@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, u"@android:attr/id")); + ASSERT_NE(nullptr, test::getValue<Id>(&table, "@android:attr/id")); } TEST(ResourceTableTest, AddMultipleResources) { @@ -65,56 +62,58 @@ TEST(ResourceTableTest, AddMultipleResources) { memcpy(languageConfig.language, "pl", sizeof(languageConfig.language)); EXPECT_TRUE(table.addResource( - test::parseNameOrDie(u"@android:attr/layout_width"), - config, - "", + 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(u"@android:attr/id"), - config, - "", + test::parseNameOrDie("@android:attr/id"), + config, "", test::ValueBuilder<Id>().setSource("test/path/file.xml", 12u).build(), test::getDiagnostics())); EXPECT_TRUE(table.addResource( - test::parseNameOrDie(u"@android:string/ok"), - config, - "", + test::parseNameOrDie("@android:string/ok"), + config, "", test::ValueBuilder<Id>().setSource("test/path/file.xml", 14u).build(), test::getDiagnostics())); EXPECT_TRUE(table.addResource( - test::parseNameOrDie(u"@android:string/ok"), - languageConfig, - "", + 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, u"@android:attr/layout_width")); - ASSERT_NE(nullptr, test::getValue<Id>(&table, u"@android:attr/id")); - ASSERT_NE(nullptr, test::getValue<Id>(&table, u"@android:string/ok")); - ASSERT_NE(nullptr, test::getValueForConfig<BinaryPrimitive>(&table, u"@android:string/ok", + 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(u"@android:attr/foo"), ConfigDescription{}, - "", util::make_unique<Attribute>(true), test::getDiagnostics())); + ASSERT_TRUE(table.addResource( + test::parseNameOrDie("@android:attr/foo"), + ConfigDescription{}, "", + util::make_unique<Attribute>(true), + test::getDiagnostics())); - Attribute* attr = test::getValue<Attribute>(&table, u"@android:attr/foo"); + Attribute* attr = test::getValue<Attribute>(&table, "@android:attr/foo"); ASSERT_NE(nullptr, attr); EXPECT_TRUE(attr->isWeak()); - ASSERT_TRUE(table.addResource(test::parseNameOrDie(u"@android:attr/foo"), ConfigDescription{}, - "", util::make_unique<Attribute>(false), test::getDiagnostics())); + ASSERT_TRUE(table.addResource( + test::parseNameOrDie("@android:attr/foo"), + ConfigDescription{}, "", + util::make_unique<Attribute>(false), + test::getDiagnostics())); - attr = test::getValue<Attribute>(&table, u"@android:attr/foo"); + attr = test::getValue<Attribute>(&table, "@android:attr/foo"); ASSERT_NE(nullptr, attr); EXPECT_FALSE(attr->isWeak()); } @@ -122,26 +121,24 @@ TEST(ResourceTableTest, OverrideWeakResourceValue) { TEST(ResourceTableTest, ProductVaryingValues) { ResourceTable table; - EXPECT_TRUE(table.addResource(test::parseNameOrDie(u"@android:string/foo"), - test::parseConfigOrDie("land"), - "tablet", + 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(u"@android:string/foo"), - test::parseConfigOrDie("land"), - "phone", + 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, u"@android:string/foo", + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<Id>(&table, "@android:string/foo", test::parseConfigOrDie("land"), "tablet")); - EXPECT_NE(nullptr, test::getValueForConfigAndProduct<Id>(&table, u"@android:string/foo", + EXPECT_NE(nullptr, test::getValueForConfigAndProduct<Id>(&table, "@android:string/foo", test::parseConfigOrDie("land"), "phone")); Maybe<ResourceTable::SearchResult> sr = table.findResource( - test::parseNameOrDie(u"@android:string/foo")); + test::parseNameOrDie("@android:string/foo")); AAPT_ASSERT_TRUE(sr); std::vector<ResourceConfigValue*> values = sr.value().entry->findAllValues( test::parseConfigOrDie("land")); |