Index: ui/base/resource/data_pack_unittest.cc |
diff --git a/ui/base/resource/data_pack_unittest.cc b/ui/base/resource/data_pack_unittest.cc |
index 11b7f7a31a891ba95d37d84dc29d11ca61b12535..4d5319637bcabad7f3a1517ef8cbaa1321aeeac6 100644 |
--- a/ui/base/resource/data_pack_unittest.cc |
+++ b/ui/base/resource/data_pack_unittest.cc |
@@ -142,6 +142,31 @@ TEST(DataPackTest, LoadFromFileRegion) { |
ASSERT_FALSE(pack.GetStringPiece(140, &data)); |
} |
+TEST(DataPackTest, LoadFromBuffer) { |
+ DataPack pack(SCALE_FACTOR_100P); |
+ |
+ ASSERT_TRUE(pack.LoadFromBuffer( |
+ base::StringPiece(kSamplePakContents, kSamplePakSize))); |
+ |
+ base::StringPiece data; |
+ ASSERT_TRUE(pack.HasResource(4)); |
+ ASSERT_TRUE(pack.GetStringPiece(4, &data)); |
+ EXPECT_EQ("this is id 4", data); |
+ ASSERT_TRUE(pack.HasResource(6)); |
+ ASSERT_TRUE(pack.GetStringPiece(6, &data)); |
+ EXPECT_EQ("this is id 6", data); |
+ |
+ // Try reading zero-length data blobs, just in case. |
+ ASSERT_TRUE(pack.GetStringPiece(1, &data)); |
+ EXPECT_EQ(0U, data.length()); |
+ ASSERT_TRUE(pack.GetStringPiece(10, &data)); |
+ EXPECT_EQ(0U, data.length()); |
+ |
+ // Try looking up an invalid key. |
+ ASSERT_FALSE(pack.HasResource(140)); |
+ ASSERT_FALSE(pack.GetStringPiece(140, &data)); |
+} |
+ |
INSTANTIATE_TEST_CASE_P(WriteBINARY, DataPackTest, ::testing::Values( |
DataPack::BINARY)); |
INSTANTIATE_TEST_CASE_P(WriteUTF8, DataPackTest, ::testing::Values( |