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

Side by Side Diff: grit/node/structure_unittest.py

Issue 1442863002: Remove contents of grit's SVN repository. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « grit/node/structure.py ('k') | grit/node/variant.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 '''Unit tests for <structure> nodes.
7 '''
8
9 import os
10 import os.path
11 import sys
12 if __name__ == '__main__':
13 sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
14
15 import platform
16 import tempfile
17 import unittest
18 import StringIO
19
20 from grit import util
21 from grit.node import structure
22 from grit.format import rc
23
24
25 class StructureUnittest(unittest.TestCase):
26 def testSkeleton(self):
27 grd = util.ParseGrdForUnittest('''
28 <structures>
29 <structure type="dialog" name="IDD_ABOUTBOX" file="klonk.rc" encoding= "utf-16-le">
30 <skeleton expr="lang == 'fr'" variant_of_revision="1" file="klonk-al ternate-skeleton.rc" />
31 </structure>
32 </structures>''', base_dir=util.PathFromRoot('grit/testdata'))
33 grd.SetOutputLanguage('fr')
34 grd.RunGatherers()
35 transl = ''.join(rc.Format(grd, 'fr', '.'))
36 self.failUnless(transl.count('040704') and transl.count('110978'))
37 self.failUnless(transl.count('2005",IDC_STATIC'))
38
39 def testRunCommandOnCurrentPlatform(self):
40 node = structure.StructureNode()
41 node.attrs = node.DefaultAttributes()
42 self.failUnless(node.RunCommandOnCurrentPlatform())
43 node.attrs['run_command_on_platforms'] = 'Nosuch'
44 self.failIf(node.RunCommandOnCurrentPlatform())
45 node.attrs['run_command_on_platforms'] = (
46 'Nosuch,%s,Othernot' % platform.system())
47 self.failUnless(node.RunCommandOnCurrentPlatform())
48
49 def testVariables(self):
50 grd = util.ParseGrdForUnittest('''
51 <structures>
52 <structure type="chrome_html" name="hello_tmpl" file="structure_variab les.html" expand_variables="true" variables="GREETING=Hello,THINGS=foo,, bar,, b az,EQUATION=2+2==4,filename=simple" flattenhtml="true"></structure>
53 </structures>''', base_dir=util.PathFromRoot('grit/testdata'))
54 grd.SetOutputLanguage('en')
55 grd.RunGatherers()
56 node, = grd.GetChildrenOfType(structure.StructureNode)
57 filename = node.Process(tempfile.gettempdir())
58 with open(os.path.join(tempfile.gettempdir(), filename)) as f:
59 result = f.read()
60 self.failUnlessEqual(('<h1>Hello!</h1>\n'
61 'Some cool things are foo, bar, baz.\n'
62 'Did you know that 2+2==4?\n'
63 '<p>\n'
64 ' Hello!\n'
65 '</p>\n'), result)
66
67
68 if __name__ == '__main__':
69 unittest.main()
OLDNEW
« no previous file with comments | « grit/node/structure.py ('k') | grit/node/variant.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698