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

Side by Side Diff: tools/grit/grit/format/chrome_messages_json_unittest.py

Issue 2948893002: Revert of Skip missing translations when generating JSON resources. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 3 years, 6 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
« no previous file with comments | « tools/grit/grit/format/chrome_messages_json.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Unittest for chrome_messages_json.py. 6 """Unittest for chrome_messages_json.py.
7 """ 7 """
8 8
9 import os 9 import os
10 import sys 10 import sys
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 def testTranslations(self): 101 def testTranslations(self):
102 root = util.ParseGrdForUnittest(""" 102 root = util.ParseGrdForUnittest("""
103 <messages> 103 <messages>
104 <message name="ID_HELLO">Hello!</message> 104 <message name="ID_HELLO">Hello!</message>
105 <message name="ID_HELLO_USER">Hello <ph name="USERNAME">%s<ex> 105 <message name="ID_HELLO_USER">Hello <ph name="USERNAME">%s<ex>
106 Joi</ex></ph></message> 106 Joi</ex></ph></message>
107 </messages> 107 </messages>
108 """) 108 """)
109 109
110 buf = StringIO.StringIO() 110 buf = StringIO.StringIO()
111 build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'fr'), 111 build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'fr'), buf)
112 buf)
113 output = buf.getvalue() 112 output = buf.getvalue()
114 test = u""" 113 test = u"""
115 { 114 {
116 "ID_HELLO": { 115 "ID_HELLO": {
117 "message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4!" 116 "message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4!"
118 }, 117 },
119 "ID_HELLO_USER": { 118 "ID_HELLO_USER": {
120 "message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4 %s" 119 "message": "H\\u00e9P\\u00e9ll\\u00f4P\\u00f4 %s"
121 } 120 }
122 } 121 }
123 """ 122 """
124 self.assertEqual(test.strip(), output.strip()) 123 self.assertEqual(test.strip(), output.strip())
125
126 def testSkipMissingTranslations(self):
127 grd = """<?xml version="1.0" encoding="UTF-8"?>
128 <grit latest_public_release="2" current_release="3" source_lang_id="en"
129 base_dir="%s">
130 <outputs>
131 </outputs>
132 <release seq="3" allow_pseudo="False">
133 <messages fallback_to_english="true">
134 <message name="ID_HELLO_NO_TRANSLATION">Hello not translated</message>
135 </messages>
136 </release>
137 </grit>"""
138 root = grd_reader.Parse(StringIO.StringIO(grd), dir=".")
139
140 buf = StringIO.StringIO()
141 build.RcBuilder.ProcessNode(root, DummyOutput('chrome_messages_json', 'fr'),
142 buf)
143 output = buf.getvalue()
144 test = u"""
145 {
146
147 }
148 """
149 self.assertEqual(test.strip(), output.strip())
150 124
151 125
152 class DummyOutput(object): 126 class DummyOutput(object):
153 127
154 def __init__(self, type, language): 128 def __init__(self, type, language):
155 self.type = type 129 self.type = type
156 self.language = language 130 self.language = language
157 131
158 def GetType(self): 132 def GetType(self):
159 return self.type 133 return self.type
160 134
161 def GetLanguage(self): 135 def GetLanguage(self):
162 return self.language 136 return self.language
163 137
164 def GetOutputFilename(self): 138 def GetOutputFilename(self):
165 return 'hello.gif' 139 return 'hello.gif'
166 140
167 141
168 if __name__ == '__main__': 142 if __name__ == '__main__':
169 unittest.main() 143 unittest.main()
OLDNEW
« no previous file with comments | « tools/grit/grit/format/chrome_messages_json.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698