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') |