summaryrefslogtreecommitdiff
path: root/tools/aapt2/ResourceTable_test.cpp
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2017-05-30 15:19:02 -0700
committerAdam Lesinski <adamlesinski@google.com>2017-06-09 14:57:07 -0700
commita45893a5c51cc26f1fd63ec1aa4c39f55911c85b (patch)
tree7e54a8f6e5d328c642309b18c7dfffb083527ccc /tools/aapt2/ResourceTable_test.cpp
parent594fda3161e492fb825d6bb47a8973344cc8e72e (diff)
AAPT2: Clean up tests a bit
Since the latest gtest has fixed support for explicit bool operators, remvoe AAPT_ASSERT_* and AAPT_EXPECT_*. Also switch to use NotNull() matchers, which are more legible. Test: make aapt2_tests Change-Id: Idce199ca9d567d70f7aae275fee15e04bb914c9e
Diffstat (limited to 'tools/aapt2/ResourceTable_test.cpp')
-rw-r--r--tools/aapt2/ResourceTable_test.cpp27
1 files changed, 12 insertions, 15 deletions
diff --git a/tools/aapt2/ResourceTable_test.cpp b/tools/aapt2/ResourceTable_test.cpp
index e2b37be994ff..2a3c131f7b4b 100644
--- a/tools/aapt2/ResourceTable_test.cpp
+++ b/tools/aapt2/ResourceTable_test.cpp
@@ -24,6 +24,8 @@
#include <ostream>
#include <string>
+using ::testing::NotNull;
+
namespace aapt {
TEST(ResourceTableTest, FailToAddResourceWithBadName) {
@@ -56,7 +58,7 @@ TEST(ResourceTableTest, AddOneResource) {
test::ValueBuilder<Id>().SetSource("test/path/file.xml", 23u).Build(),
test::GetDiagnostics()));
- ASSERT_NE(nullptr, test::GetValue<Id>(&table, "android:attr/id"));
+ EXPECT_THAT(test::GetValue<Id>(&table, "android:attr/id"), NotNull());
}
TEST(ResourceTableTest, AddMultipleResources) {
@@ -88,11 +90,10 @@ TEST(ResourceTableTest, AddMultipleResources) {
.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", language_config));
+ EXPECT_THAT(test::GetValue<Id>(&table, "android:attr/layout_width"), NotNull());
+ EXPECT_THAT(test::GetValue<Id>(&table, "android:attr/id"), NotNull());
+ EXPECT_THAT(test::GetValue<Id>(&table, "android:string/ok"), NotNull());
+ EXPECT_THAT(test::GetValueForConfig<BinaryPrimitive>(&table, "android:string/ok", language_config), NotNull());
}
TEST(ResourceTableTest, OverrideWeakResourceValue) {
@@ -103,7 +104,7 @@ TEST(ResourceTableTest, OverrideWeakResourceValue) {
util::make_unique<Attribute>(true), test::GetDiagnostics()));
Attribute* attr = test::GetValue<Attribute>(&table, "android:attr/foo");
- ASSERT_NE(nullptr, attr);
+ ASSERT_THAT(attr, NotNull());
EXPECT_TRUE(attr->IsWeak());
ASSERT_TRUE(table.AddResource(
@@ -111,7 +112,7 @@ TEST(ResourceTableTest, OverrideWeakResourceValue) {
util::make_unique<Attribute>(false), test::GetDiagnostics()));
attr = test::GetValue<Attribute>(&table, "android:attr/foo");
- ASSERT_NE(nullptr, attr);
+ ASSERT_THAT(attr, NotNull());
EXPECT_FALSE(attr->IsWeak());
}
@@ -127,16 +128,12 @@ TEST(ResourceTableTest, ProductVaryingValues) {
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"));
+ EXPECT_THAT(test::GetValueForConfigAndProduct<Id>(&table, "android:string/foo",test::ParseConfigOrDie("land"), "tablet"), NotNull());
+ EXPECT_THAT(test::GetValueForConfigAndProduct<Id>(&table, "android:string/foo",test::ParseConfigOrDie("land"), "phone"), NotNull());
Maybe<ResourceTable::SearchResult> sr =
table.FindResource(test::ParseNameOrDie("android:string/foo"));
- AAPT_ASSERT_TRUE(sr);
+ ASSERT_TRUE(sr);
std::vector<ResourceConfigValue*> values =
sr.value().entry->FindAllValues(test::ParseConfigOrDie("land"));
ASSERT_EQ(2u, values.size());