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

Unified 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: Fixed Python formatting 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
« no previous file with comments | « tools/grit/grit/format/gzip_string.py ('k') | tools/grit/grit/node/include.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/format/gzip_string_unittest.py
diff --git a/tools/grit/grit/format/gzip_string_unittest.py b/tools/grit/grit/format/gzip_string_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..8df8b3b3f6a71b4687893030fe9d9b24ad9ab814
--- /dev/null
+++ b/tools/grit/grit/format/gzip_string_unittest.py
@@ -0,0 +1,62 @@
+# Copyright (c) 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+'''Unit tests for grit.format.gzip_string'''
+
+import gzip
+import io
+import os
+import sys
+if __name__ == '__main__':
+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
+
+import unittest
+
+from grit.format import gzip_string
+
+
+class FormatGzipStringUnittest(unittest.TestCase):
+
+ def testGzipStringRsyncable(self):
+ # Can only test the rsyncable version on platforms which support rsyncable,
+ # which at the moment is Linux.
+ if sys.platform == 'linux2':
+ header_begin = ('\x1f\x8b') # gzip first two bytes
+ input = ('TEST STRING STARTING NOW'
+ 'continuing'
+ '<even more>'
+ '<finished NOW>')
+
+ compressed = gzip_string.GzipStringRsyncable(input)
+ self.failUnless(header_begin == compressed[:2])
+
+ compressed_file = io.BytesIO()
+ compressed_file.write(compressed)
+ compressed_file.seek(0)
+
+ with gzip.GzipFile(mode='rb', fileobj=compressed_file) as f:
+ output = f.read()
+ self.failUnless(output == input)
+
+ def testGzipString(self):
+ header_begin = '\x1f\x8b' # gzip first two bytes
+ input = ('TEST STRING STARTING NOW'
+ 'continuing'
+ '<even more>'
+ '<finished NOW>')
+
+ compressed = gzip_string.GzipString(input)
+ self.failUnless(header_begin == compressed[:2])
+
+ compressed_file = io.BytesIO()
+ compressed_file.write(compressed)
+ compressed_file.seek(0)
+
+ with gzip.GzipFile(mode='rb', fileobj=compressed_file) as f:
+ output = f.read()
+ self.failUnless(output == input)
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « tools/grit/grit/format/gzip_string.py ('k') | tools/grit/grit/node/include.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698