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

Side by Side Diff: tools/grit/grit/format/gzip_string_unittest.py

Issue 1968993002: Compressing .pak resources with new option: "type=GZIPPABLE_BINDATA" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing some of the try bots Created 4 years, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 '''Unit tests for grit.format.gzip_string'''
6
7
8 import gzip
9 import os
10 import io
11 import sys
12 if __name__ == '__main__':
13 sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
14
15 import unittest
16
17 from grit.format import gzip_string
18
19
20 class FormatGzipStringUnittest(unittest.TestCase):
21 def testGzipStringRsyncable(self):
22 # Can only test the rsyncable version on platforms which support rsyncable,
23 # which at the moment is Linux.
24 if sys.platform == 'linux2':
25 header_begin = ('\x1f\x8b') # gzip first two bytes
26 input = ('TEST STRING STARTING NOW'
27 'continuing'
28 '<even more>'
29 '<finished NOW>')
30
31 compressed = gzip_string.GzipStringRsyncable(input)
32 self.failUnless(header_begin == compressed[:2])
33
34 compressed_file = io.BytesIO()
35 compressed_file.write(compressed)
36 compressed_file.seek(0)
37
38 with gzip.GzipFile(mode='rb', fileobj=compressed_file) as f:
39 output = f.read()
40 self.failUnless(output == input)
41
42 def testGzipString(self):
43 header_begin = '\x1f\x8b' # gzip first two bytes
44 input = ('TEST STRING STARTING NOW'
45 'continuing'
46 '<even more>'
47 '<finished NOW>')
48
49 compressed = gzip_string.GzipString(input)
50 self.failUnless(header_begin == compressed[:2])
51
52 compressed_file = io.BytesIO()
53 compressed_file.write(compressed)
54 compressed_file.seek(0)
55
56 with gzip.GzipFile(mode='rb', fileobj=compressed_file) as f:
57 output = f.read()
58 self.failUnless(output == input)
59
60 if __name__ == '__main__':
61 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698