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

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

Issue 1968993002: Compressing .pak resources with new option: "type=GZIPPABLE_BINDATA" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating comments Created 4 years, 7 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
« ui/base/resource/resource_bundle.cc ('K') | « ui/base/resource/resource_bundle.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/resource/resource_bundle_unittest.cc
diff --git a/ui/base/resource/resource_bundle_unittest.cc b/ui/base/resource/resource_bundle_unittest.cc
index 1dcee7a17d9f82ac4b3cb5dad2d6df046f24c37e..71a5d395001a98517d752552d8be0a8a02fdb812 100644
--- a/ui/base/resource/resource_bundle_unittest.cc
+++ b/ui/base/resource/resource_bundle_unittest.cc
@@ -270,6 +270,40 @@ TEST_F(ResourceBundleTest, DelegateLoadDataResourceBytes) {
EXPECT_EQ(static_memory, result);
}
+TEST_F(ResourceBundleTest, LoadDataResourceBytesGzip) {
+ base::ScopedTempDir dir;
+ ASSERT_TRUE(dir.CreateUniqueTempDir());
+ base::FilePath data_path = dir.path().Append(FILE_PATH_LITERAL("sample.pak"));
+
+ char compressedEntryPakContents[] = {
+ 0x04, 0x00, 0x00, 0x00, // header(version
+ 0x01, 0x00, 0x00, 0x00, // no. entries
+ 0x01, // encoding)
+ 0x04, 0x00, 0x15, 0x00, 0x00, 0x00, // index entry 4
+ 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, // extra entry for the size of last
+ // Entry 4 is a compressed gzip file (with custom leading byte) saying:
+ // "This is compressed\n"
+ ResourceBundle::CUSTOM_GZIP_HEADER[0], 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x03, 0x0b, 0xc9, 0xc8, 0x2c, 0x56, 0x00, 0xa2, 0xe4,
+ 0xfc, 0xdc, 0x82, 0xa2, 0xd4, 0xe2, 0xe2, 0xd4, 0x14, 0x2e, 0x00, 0xd9,
+ 0xf8, 0xc4, 0x6f, 0x13, 0x00, 0x00, 0x00};
+
+ size_t compressedEntryPakSize = sizeof(compressedEntryPakContents);
+
+ // Dump contents into the pak file.
+ ASSERT_EQ(base::WriteFile(data_path, compressedEntryPakContents,
+ compressedEntryPakSize), static_cast<int>(compressedEntryPakSize));
+
+ ResourceBundle* resource_bundle = CreateResourceBundle(nullptr);
+ resource_bundle->AddDataPackFromPath(data_path, SCALE_FACTOR_NONE);
+
+ // Load the compressed resource.
+ scoped_refptr<base::RefCountedMemory> result =
+ resource_bundle->LoadDataResourceBytes(4);
+ EXPECT_STREQ("This is compressed\n",
+ reinterpret_cast<const char*>(result->front()));
+}
+
TEST_F(ResourceBundleTest, DelegateGetRawDataResource) {
MockResourceBundleDelegate delegate;
ResourceBundle* resource_bundle = CreateResourceBundle(&delegate);
« ui/base/resource/resource_bundle.cc ('K') | « ui/base/resource/resource_bundle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698