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

Unified Diff: tools/grit/grit/node/structure_unittest.py

Issue 1410853008: Move grit from DEPS into src. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: webview licenses Created 5 years, 1 month 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/structure.py ('k') | tools/grit/grit/node/variant.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/node/structure_unittest.py
diff --git a/tools/grit/grit/node/structure_unittest.py b/tools/grit/grit/node/structure_unittest.py
new file mode 100755
index 0000000000000000000000000000000000000000..a039bce984b63377e880c9ea5cf42477f26249f3
--- /dev/null
+++ b/tools/grit/grit/node/structure_unittest.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 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 <structure> nodes.
+'''
+
+import os
+import os.path
+import sys
+if __name__ == '__main__':
+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
+
+import platform
+import tempfile
+import unittest
+import StringIO
+
+from grit import util
+from grit.node import structure
+from grit.format import rc
+
+
+class StructureUnittest(unittest.TestCase):
+ def testSkeleton(self):
+ grd = util.ParseGrdForUnittest('''
+ <structures>
+ <structure type="dialog" name="IDD_ABOUTBOX" file="klonk.rc" encoding="utf-16-le">
+ <skeleton expr="lang == 'fr'" variant_of_revision="1" file="klonk-alternate-skeleton.rc" />
+ </structure>
+ </structures>''', base_dir=util.PathFromRoot('grit/testdata'))
+ grd.SetOutputLanguage('fr')
+ grd.RunGatherers()
+ transl = ''.join(rc.Format(grd, 'fr', '.'))
+ self.failUnless(transl.count('040704') and transl.count('110978'))
+ self.failUnless(transl.count('2005",IDC_STATIC'))
+
+ def testRunCommandOnCurrentPlatform(self):
+ node = structure.StructureNode()
+ node.attrs = node.DefaultAttributes()
+ self.failUnless(node.RunCommandOnCurrentPlatform())
+ node.attrs['run_command_on_platforms'] = 'Nosuch'
+ self.failIf(node.RunCommandOnCurrentPlatform())
+ node.attrs['run_command_on_platforms'] = (
+ 'Nosuch,%s,Othernot' % platform.system())
+ self.failUnless(node.RunCommandOnCurrentPlatform())
+
+ def testVariables(self):
+ grd = util.ParseGrdForUnittest('''
+ <structures>
+ <structure type="chrome_html" name="hello_tmpl" file="structure_variables.html" expand_variables="true" variables="GREETING=Hello,THINGS=foo,, bar,, baz,EQUATION=2+2==4,filename=simple" flattenhtml="true"></structure>
+ </structures>''', base_dir=util.PathFromRoot('grit/testdata'))
+ grd.SetOutputLanguage('en')
+ grd.RunGatherers()
+ node, = grd.GetChildrenOfType(structure.StructureNode)
+ filename = node.Process(tempfile.gettempdir())
+ with open(os.path.join(tempfile.gettempdir(), filename)) as f:
+ result = f.read()
+ self.failUnlessEqual(('<h1>Hello!</h1>\n'
+ 'Some cool things are foo, bar, baz.\n'
+ 'Did you know that 2+2==4?\n'
+ '<p>\n'
+ ' Hello!\n'
+ '</p>\n'), result)
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « tools/grit/grit/node/structure.py ('k') | tools/grit/grit/node/variant.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698