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

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: Fixing some of the try bots 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
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..5147d8718851a4ff9397f31b0e88a4054dc796bc 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()

Powered by Google App Engine
This is Rietveld 408576698