Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Unified Diff: ui/base/resource/data_pack_unittest.cc

Issue 1969313005: [headless] Embed pak file into binary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated years in copyright Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/resource/data_pack.cc ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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(
« no previous file with comments | « ui/base/resource/data_pack.cc ('k') | ui/base/resource/resource_bundle.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698