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

Unified Diff: tools/grit/grit/node/include_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/node/include.py ('k') | tools/grit/grit/test_suite_all.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/node/include_unittest.py
diff --git a/tools/grit/grit/node/include_unittest.py b/tools/grit/grit/node/include_unittest.py
index e5544281fd0ad76dc9a988e1bd4281ee33d5349c..2b29e11815179880aed331ba4a221af5b6d78aab 100755
--- a/tools/grit/grit/node/include_unittest.py
+++ b/tools/grit/grit/node/include_unittest.py
@@ -11,8 +11,8 @@ if __name__ == '__main__':
sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
import os
-import StringIO
import unittest
+import zlib
from grit.node import misc
from grit.node import include
@@ -69,6 +69,21 @@ class IncludeNodeUnittest(unittest.TestCase):
util.normpath(
os.path.join(ur'../', ur'flugel/kugel.pdf')))
+ def testCompressGzip(self):
+ root = util.ParseGrdForUnittest('''
+ <includes>
+ <include name="TEST_TXT" file="test_text.txt"
+ compress="gzip" type="BINDATA"/>
+ </includes>''', base_dir = util.PathFromRoot('grit/testdata'))
+ inc, = root.GetChildrenOfType(include.IncludeNode)
+ throwaway, compressed = inc.GetDataPackPair(lang='en', encoding=1)
+
+ # compressed[1:] ensures we skip the special inserted first byte.
+ decompressed_data = zlib.decompress(compressed[1:], 16 + zlib.MAX_WBITS)
+ self.assertEqual(util.ReadFile(util.PathFromRoot('grit/testdata')
+ + "/test_text.txt", util.BINARY),
+ decompressed_data)
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « tools/grit/grit/node/include.py ('k') | tools/grit/grit/test_suite_all.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698