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

Side by Side Diff: grit/format/js_map_format_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/format/js_map_format.py ('k') | grit/format/policy_templates/PRESUBMIT.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 """Unittest for js_map_format.py.
7 """
8
9 import os
10 import sys
11 if __name__ == '__main__':
12 sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
13
14 import unittest
15 import StringIO
16
17 from grit import util
18 from grit.tool import build
19
20
21 class JsMapFormatUnittest(unittest.TestCase):
22
23 def testMessages(self):
24 root = util.ParseGrdForUnittest(u"""
25 <messages>
26 <message name="IDS_SIMPLE_MESSAGE">
27 Simple message.
28 </message>
29 <message name="IDS_QUOTES">
30 element\u2019s \u201c<ph name="NAME">%s<ex>name</ex></ph>\u201d at tribute
31 </message>
32 <message name="IDS_PLACEHOLDERS">
33 <ph name="ERROR_COUNT">%1$d<ex>1</ex></ph> error, <ph name="WARNIN G_COUNT">%2$d<ex>1</ex></ph> warning
34 </message>
35 <message name="IDS_STARTS_WITH_SPACE">
36 ''' (<ph name="COUNT">%d<ex>2</ex></ph>)
37 </message>
38 <message name="IDS_DOUBLE_QUOTES">
39 A "double quoted" message.
40 </message>
41 <message name="IDS_BACKSLASH">
42 \\
43 </message>
44 </messages>
45 """)
46
47 buf = StringIO.StringIO()
48 build.RcBuilder.ProcessNode(root, DummyOutput('js_map_format', 'en'), buf)
49 output = util.StripBlankLinesAndComments(buf.getvalue())
50 self.assertEqual(u"""\
51 localizedStrings["Simple message."] = "Simple message.";
52 localizedStrings["element\u2019s \u201c%s\u201d attribute"] = "element\u2019s \u 201c%s\u201d attribute";
53 localizedStrings["%d error, %d warning"] = "%1$d error, %2$d warning";
54 localizedStrings[" (%d)"] = " (%d)";
55 localizedStrings["A \\\"double quoted\\\" message."] = "A \\\"double quoted\\\" message.";
56 localizedStrings["\\\\"] = "\\\\";""", output)
57
58 def testTranslations(self):
59 root = util.ParseGrdForUnittest("""
60 <messages>
61 <message name="ID_HELLO">Hello!</message>
62 <message name="ID_HELLO_USER">Hello <ph name="USERNAME">%s<ex>
63 Joi</ex></ph></message>
64 </messages>
65 """)
66
67 buf = StringIO.StringIO()
68 build.RcBuilder.ProcessNode(root, DummyOutput('js_map_format', 'fr'), buf)
69 output = util.StripBlankLinesAndComments(buf.getvalue())
70 self.assertEqual(u"""\
71 localizedStrings["Hello!"] = "H\xe9P\xe9ll\xf4P\xf4!";
72 localizedStrings["Hello %s"] = "H\xe9P\xe9ll\xf4P\xf4 %s";\
73 """, output)
74
75
76 class DummyOutput(object):
77
78 def __init__(self, type, language):
79 self.type = type
80 self.language = language
81
82 def GetType(self):
83 return self.type
84
85 def GetLanguage(self):
86 return self.language
87
88 def GetOutputFilename(self):
89 return 'hello.gif'
90
91 if __name__ == '__main__':
92 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/js_map_format.py ('k') | grit/format/policy_templates/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698