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

Side by Side Diff: grit/tool/postprocess_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/tool/postprocess_interface.py ('k') | grit/tool/preprocess_interface.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 test that checks postprocessing of files.
7 Tests postprocessing by having the postprocessor
8 modify the grd data tree, changing the message name attributes.
9 '''
10
11 import os
12 import re
13 import sys
14 if __name__ == '__main__':
15 sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
16
17 import unittest
18
19 import grit.tool.postprocess_interface
20 from grit.tool import rc2grd
21
22
23 class PostProcessingUnittest(unittest.TestCase):
24
25 def testPostProcessing(self):
26 rctext = '''STRINGTABLE
27 BEGIN
28 DUMMY_STRING_1 "String 1"
29 // Some random description
30 DUMMY_STRING_2 "This text was added during preprocessing"
31 END
32 '''
33 tool = rc2grd.Rc2Grd()
34 class DummyOpts(object):
35 verbose = False
36 extra_verbose = False
37 tool.o = DummyOpts()
38 tool.post_process = 'grit.tool.postprocess_unittest.DummyPostProcessor'
39 result = tool.Process(rctext, '.\resource.rc')
40
41 self.failUnless(
42 result.children[2].children[2].children[0].attrs['name'] == 'SMART_STRING_ 1')
43 self.failUnless(
44 result.children[2].children[2].children[1].attrs['name'] == 'SMART_STRING_ 2')
45
46 class DummyPostProcessor(grit.tool.postprocess_interface.PostProcessor):
47 '''
48 Post processing replaces all message name attributes containing "DUMMY" to
49 "SMART".
50 '''
51 def Process(self, rctext, rcpath, grdnode):
52 smarter = re.compile(r'(DUMMY)(.*)')
53 messages = grdnode.children[2].children[2]
54 for node in messages.children:
55 name_attr = node.attrs['name']
56 m = smarter.search(name_attr)
57 if m:
58 node.attrs['name'] = 'SMART' + m.group(2)
59 return grdnode
60
61 if __name__ == '__main__':
62 unittest.main()
63
OLDNEW
« no previous file with comments | « grit/tool/postprocess_interface.py ('k') | grit/tool/preprocess_interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698