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

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

Issue 7994004: Initial source commit to grit-i18n project. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 3 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 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')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin/python2.4
2 # Copyright (c) 2006-2008 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 sys
11 if __name__ == '__main__':
12 sys.path.append(os.path.join(os.path.dirname(sys.argv[0]), '../..'))
13
14 import unittest
15 import StringIO
16
17 from grit.node import structure
18 from grit import grd_reader
19 from grit import util
20
21
22 class StructureUnittest(unittest.TestCase):
23 def testSkeleton(self):
24 grd = grd_reader.Parse(StringIO.StringIO(
25 '''<?xml version="1.0" encoding="UTF-8"?>
26 <grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir=".">
27 <release seq="3">
28 <structures>
29 <structure type="dialog" name="IDD_ABOUTBOX" file="klonk.rc" encodin g="utf-16-le">
30 <skeleton expr="lang == 'fr'" variant_of_revision="1" file="klonk- alternate-skeleton.rc" />
31 </structure>
32 </structures>
33 </release>
34 </grit>'''), dir=util.PathFromRoot('grit\\test\\data'))
35 grd.RunGatherers(recursive=True)
36 grd.output_language = 'fr'
37
38 node = grd.GetNodeById('IDD_ABOUTBOX')
39 formatter = node.ItemFormatter('rc_all')
40 self.failUnless(formatter)
41 transl = formatter.Format(node, 'fr')
42
43 self.failUnless(transl.count('040704') and transl.count('110978'))
44 self.failUnless(transl.count('2005",IDC_STATIC'))
45
46 def testOutputEncoding(self):
47 grd = grd_reader.Parse(StringIO.StringIO(
48 '''<?xml version="1.0" encoding="UTF-8"?>
49 <grit latest_public_release="2" source_lang_id="en-US" current_release="3" base_dir=".">
50 <release seq="3">
51 <structures>
52 <structure type="dialog" name="IDD_ABOUTBOX" file="klonk.rc" encodin g="utf-16-le" output_encoding="utf-8-sig" />
53 </structures>
54 </release>
55 </grit>'''), dir=util.PathFromRoot('grit\\test\\data'))
56 node = grd.GetNodeById('IDD_ABOUTBOX')
57 self.failUnless(node._GetOutputEncoding() == 'utf-8')
58 self.failUnless(node._ShouldAddBom())
59
60 if __name__ == '__main__':
61 unittest.main()
62
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