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

Unified Diff: tools/grit/grit/format/data_pack_unittest.py

Issue 2969123002: Add deduplication logic to .pak files (Closed)
Patch Set: sizeof() Created 3 years, 5 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 | « tools/grit/grit/format/data_pack.py ('k') | tools/grit/pak_util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/format/data_pack_unittest.py
diff --git a/tools/grit/grit/format/data_pack_unittest.py b/tools/grit/grit/format/data_pack_unittest.py
index f6e9edcfcb6c99799e76d8c4230c3fddb66793aa..28a7b298fb5c2bf7fd3d6234609a963e090d1fcb 100755
--- a/tools/grit/grit/format/data_pack_unittest.py
+++ b/tools/grit/grit/format/data_pack_unittest.py
@@ -17,8 +17,8 @@ from grit.format import data_pack
class FormatDataPackUnittest(unittest.TestCase):
- def testWriteDataPack(self):
- expected = (
+ def testReadDataPackV4(self):
+ expected_data = (
'\x04\x00\x00\x00' # header(version
'\x04\x00\x00\x00' # no. entries,
'\x01' # encoding)
@@ -28,9 +28,42 @@ class FormatDataPackUnittest(unittest.TestCase):
'\x0a\x00\x3f\x00\x00\x00' # index entry 10
'\x00\x00\x3f\x00\x00\x00' # extra entry for the size of last
'this is id 4this is id 6') # data
- input = {1: '', 4: 'this is id 4', 6: 'this is id 6', 10: ''}
- output = data_pack.WriteDataPackToString(input, data_pack.UTF8)
- self.failUnless(output == expected)
+ expected_resources = {
+ 1: '',
+ 4: 'this is id 4',
+ 6: 'this is id 6',
+ 10: '',
+ }
+ expected_data_pack = data_pack.DataPackContents(
+ expected_resources, data_pack.UTF8)
+ loaded = data_pack.ReadDataPackFromString(expected_data)
+ self.assertEquals(loaded, expected_data_pack)
+
+ def testReadWriteDataPackV5(self):
+ expected_data = (
+ '\x05\x00\x00\x00' # version
+ '\x01\x00\x00\x00' # encoding & padding
+ '\x03\x00' # resource_count
+ '\x01\x00' # alias_count
+ '\x01\x00\x28\x00\x00\x00' # index entry 1
+ '\x04\x00\x28\x00\x00\x00' # index entry 4
+ '\x06\x00\x34\x00\x00\x00' # index entry 6
+ '\x00\x00\x40\x00\x00\x00' # extra entry for the size of last
+ '\x0a\x00\x01\x00' # alias table
+ 'this is id 4this is id 6') # data
+ expected_resources = {
+ 1: '',
+ 4: 'this is id 4',
+ 6: 'this is id 6',
+ 10: 'this is id 4',
+ }
+ data = data_pack.WriteDataPackToString(expected_resources, data_pack.UTF8)
+ self.assertEquals(data, expected_data)
+
+ expected_data_pack = data_pack.DataPackContents(
+ expected_resources, data_pack.UTF8)
+ loaded = data_pack.ReadDataPackFromString(expected_data)
+ self.assertEquals(loaded, expected_data_pack)
def testRePackUnittest(self):
expected_with_whitelist = {
@@ -50,12 +83,14 @@ class FormatDataPackUnittest(unittest.TestCase):
in inputs]
# RePack using whitelist
- output, _ = data_pack.RePackFromDataPackStrings(inputs, whitelist)
+ output, _ = data_pack.RePackFromDataPackStrings(
+ inputs, whitelist, suppress_removed_key_output=True)
self.assertDictEqual(expected_with_whitelist, output,
'Incorrect resource output')
# RePack a None whitelist
- output, _ = data_pack.RePackFromDataPackStrings(inputs, None)
+ output, _ = data_pack.RePackFromDataPackStrings(
+ inputs, None, suppress_removed_key_output=True)
self.assertDictEqual(expected_without_whitelist, output,
'Incorrect resource output')
« no previous file with comments | « tools/grit/grit/format/data_pack.py ('k') | tools/grit/pak_util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698