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

Side by Side Diff: grit/format/policy_templates/writers/plist_strings_writer_unittest.py

Issue 347293003: Added support for string-enum-list. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 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 | Annotate | Revision Log
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 '''Unit tests for grit.format.policy_templates.writers.plist_strings_writer''' 6 '''Unit tests for grit.format.policy_templates.writers.plist_strings_writer'''
7 7
8 8
9 import os 9 import os
10 import sys 10 import sys
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 'plist_strings', 120 'plist_strings',
121 'en') 121 'en')
122 expected_output = ( 122 expected_output = (
123 'Chromium.pfm_title = "Chromium";\n' 123 'Chromium.pfm_title = "Chromium";\n'
124 'Chromium.pfm_description = "Preferences of Chromium";\n' 124 'Chromium.pfm_description = "Preferences of Chromium";\n'
125 'StringPolicy.pfm_title = "Caption of policy.";\n' 125 'StringPolicy.pfm_title = "Caption of policy.";\n'
126 'StringPolicy.pfm_description = ' 126 'StringPolicy.pfm_description = '
127 '"Description of policy.\\nWith a newline.";') 127 '"Description of policy.\\nWith a newline.";')
128 self.assertEquals(output.strip(), expected_output.strip()) 128 self.assertEquals(output.strip(), expected_output.strip())
129 129
130 def testStringListPolicy(self):
131 # Tests a policy group with a single policy of type 'list'.
132 grd = self.PrepareTest('''
133 {
134 'policy_definitions': [
135 {
136 'name': 'ListGroup',
137 'type': 'group',
138 'caption': '',
139 'desc': '',
140 'policies': [{
141 'name': 'ListPolicy',
142 'type': 'list',
143 'caption': 'Caption of policy.',
144 'desc': """Description of policy.
145 With a newline.""",
146 'schema': {
147 'type': 'array',
148 'items': { 'type': 'string' },
149 },
150 'supported_on': ['chrome.mac:8-'],
151 }],
152 },
153 ],
154 'placeholders': [],
155 'messages': {
156 'mac_chrome_preferences': {
157 'text': 'Preferences of $1',
158 'desc': 'blah'
159 }
160 }
161 }''')
162 output = self.GetOutput(
163 grd,
164 'fr',
165 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'},
166 'plist_strings',
167 'en')
168 expected_output = (
169 'Chromium.pfm_title = "Chromium";\n'
170 'Chromium.pfm_description = "Preferences of Chromium";\n'
171 'ListPolicy.pfm_title = "Caption of policy.";\n'
172 'ListPolicy.pfm_description = '
173 '"Description of policy.\\nWith a newline.";')
174 self.assertEquals(output.strip(), expected_output.strip())
175
176 def testStringEnumListPolicy(self):
177 # Tests a policy group with a single policy of type 'string-enum-list'.
178 grd = self.PrepareTest('''
179 {
180 'policy_definitions': [
181 {
182 'name': 'EnumGroup',
183 'type': 'group',
184 'caption': '',
185 'desc': '',
186 'policies': [{
187 'name': 'EnumPolicy',
188 'type': 'string-enum-list',
189 'caption': 'Caption of policy.',
190 'desc': """Description of policy.
191 With a newline.""",
192 'schema': {
193 'type': 'array',
194 'items': { 'type': 'string' },
195 },
196 'items': [
197 {
198 'name': 'ProxyServerDisabled',
199 'value': 'one',
200 'caption': 'Option1'
201 },
202 {
203 'name': 'ProxyServerAutoDetect',
204 'value': 'two',
205 'caption': 'Option2'
206 },
207 ],
208 'supported_on': ['chrome.mac:8-'],
209 }],
210 },
211 ],
212 'placeholders': [],
213 'messages': {
214 'mac_chrome_preferences': {
215 'text': 'Preferences of $1',
216 'desc': 'blah'
217 }
218 }
219 }''')
220 output = self.GetOutput(
221 grd,
222 'fr',
223 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'},
224 'plist_strings',
225 'en')
226 expected_output = (
227 'Chromium.pfm_title = "Chromium";\n'
228 'Chromium.pfm_description = "Preferences of Chromium";\n'
229 'EnumPolicy.pfm_title = "Caption of policy.";\n'
230 'EnumPolicy.pfm_description = '
231 '"one - Option1\\ntwo - Option2\\n'
232 'Description of policy.\\nWith a newline.";')
233 self.assertEquals(output.strip(), expected_output.strip())
234
130 def testIntEnumPolicy(self): 235 def testIntEnumPolicy(self):
131 # Tests a policy group with a single policy of type 'int-enum'. 236 # Tests a policy group with a single policy of type 'int-enum'.
132 grd = self.PrepareTest(''' 237 grd = self.PrepareTest('''
133 { 238 {
134 'policy_definitions': [ 239 'policy_definitions': [
135 { 240 {
136 'name': 'EnumGroup', 241 'name': 'EnumGroup',
137 'type': 'group', 242 'type': 'group',
138 'desc': '', 243 'desc': '',
139 'caption': '', 244 'caption': '',
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 'plist_strings', 375 'plist_strings',
271 'en') 376 'en')
272 expected_output = ( 377 expected_output = (
273 'Google_Chrome.pfm_title = "Google Chrome";\n' 378 'Google_Chrome.pfm_title = "Google Chrome";\n'
274 'Google_Chrome.pfm_description = "Google Chrome preferences";') 379 'Google_Chrome.pfm_description = "Google Chrome preferences";')
275 self.assertEquals(output.strip(), expected_output.strip()) 380 self.assertEquals(output.strip(), expected_output.strip())
276 381
277 382
278 if __name__ == '__main__': 383 if __name__ == '__main__':
279 unittest.main() 384 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/plist_strings_writer.py ('k') | grit/format/policy_templates/writers/plist_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698