OLD | NEW |
---|---|
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_writer''' | 6 '''Unit tests for grit.format.policy_templates.writers.plist_writer''' |
7 | 7 |
8 | 8 |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 <key>pfm_targets</key> | 158 <key>pfm_targets</key> |
159 <array> | 159 <array> |
160 <string>user-managed</string> | 160 <string>user-managed</string> |
161 </array> | 161 </array> |
162 <key>pfm_type</key> | 162 <key>pfm_type</key> |
163 <string>string</string> | 163 <string>string</string> |
164 </dict> | 164 </dict> |
165 </array>''') | 165 </array>''') |
166 self.assertEquals(output.strip(), expected_output.strip()) | 166 self.assertEquals(output.strip(), expected_output.strip()) |
167 | 167 |
168 def testListPolicy(self): | |
169 # Tests a policy group with a single policy of type 'list'. | |
170 grd = self.PrepareTest(''' | |
171 { | |
172 'policy_definitions': [ | |
173 { | |
174 'name': 'ListGroup', | |
175 'type': 'group', | |
176 'desc': '', | |
177 'caption': '', | |
178 'policies': [{ | |
179 'name': 'ListPolicy', | |
180 'type': 'list', | |
181 'schema': { | |
182 'type': 'array', | |
183 'items': { 'type': 'string' }, | |
184 }, | |
185 'supported_on': ['chrome.mac:8-'], | |
186 'desc': '', | |
187 'caption': '', | |
188 }], | |
189 }, | |
190 ], | |
191 'placeholders': [], | |
192 'messages': {}, | |
193 }''') | |
194 output = self.GetOutput( | |
195 grd, | |
196 'fr', | |
197 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
198 'plist', | |
199 'en') | |
200 expected_output = self._GetExpectedOutputs( | |
201 'Chromium', 'com.example.Test', '''<array> | |
202 <dict> | |
203 <key>pfm_name</key> | |
204 <string>ListPolicy</string> | |
205 <key>pfm_description</key> | |
206 <string/> | |
207 <key>pfm_title</key> | |
208 <string/> | |
209 <key>pfm_targets</key> | |
210 <array> | |
211 <string>user-managed</string> | |
212 </array> | |
213 <key>pfm_type</key> | |
214 <string>array</string> | |
215 <key>pfm_subkeys</key> | |
216 <array> | |
217 <dict> | |
218 <key>pfm_type</key> | |
219 <string>string</string> | |
220 </dict> | |
221 </array> | |
222 </dict> | |
223 </array>''') | |
224 self.assertEquals(output.strip(), expected_output.strip()) | |
225 | |
226 def testStringEnumListPolicy(self): | |
227 # Tests a policy group with a single policy of type 'list'. | |
Joao da Silva
2014/06/25 16:46:56
string-enum-list
Andrew T Wilson (Slow)
2014/06/26 08:08:56
Done.
| |
228 grd = self.PrepareTest(''' | |
229 { | |
230 'policy_definitions': [ | |
231 { | |
232 'name': 'ListGroup', | |
233 'type': 'group', | |
234 'desc': '', | |
235 'caption': '', | |
236 'policies': [{ | |
237 'name': 'ListPolicy', | |
238 'type': 'string-enum-list', | |
239 'schema': { | |
240 'type': 'array', | |
241 'items': { 'type': 'string' }, | |
242 }, | |
243 'items': [ | |
244 {'name': 'ProxyServerDisabled', 'value': 'one', 'caption': ''}, | |
245 {'name': 'ProxyServerAutoDetect', 'value': 'two', 'caption': ''} , | |
246 ], | |
247 'supported_on': ['chrome.mac:8-'], | |
248 'supported_on': ['chrome.mac:8-'], | |
249 'desc': '', | |
250 'caption': '', | |
251 }], | |
252 }, | |
253 ], | |
254 'placeholders': [], | |
255 'messages': {}, | |
256 }''') | |
257 output = self.GetOutput( | |
258 grd, | |
259 'fr', | |
260 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
261 'plist', | |
262 'en') | |
263 expected_output = self._GetExpectedOutputs( | |
264 'Chromium', 'com.example.Test', '''<array> | |
265 <dict> | |
266 <key>pfm_name</key> | |
267 <string>ListPolicy</string> | |
268 <key>pfm_description</key> | |
269 <string/> | |
270 <key>pfm_title</key> | |
271 <string/> | |
272 <key>pfm_targets</key> | |
273 <array> | |
274 <string>user-managed</string> | |
275 </array> | |
276 <key>pfm_type</key> | |
277 <string>array</string> | |
278 <key>pfm_subkeys</key> | |
279 <array> | |
280 <dict> | |
281 <key>pfm_type</key> | |
282 <string>string</string> | |
Joao da Silva
2014/06/25 16:46:57
See the int-enum example below: it's possible to e
Andrew T Wilson (Slow)
2014/06/26 08:08:56
I'm trying really hard not to have to actually tes
Joao da Silva
2014/06/26 11:34:07
That's cool, I can do the testing for the followup
| |
283 </dict> | |
284 </array> | |
285 </dict> | |
286 </array>''') | |
287 self.assertEquals(output.strip(), expected_output.strip()) | |
288 | |
168 def testIntPolicy(self): | 289 def testIntPolicy(self): |
169 # Tests a policy group with a single policy of type 'int'. | 290 # Tests a policy group with a single policy of type 'int'. |
170 grd = self.PrepareTest(''' | 291 grd = self.PrepareTest(''' |
171 { | 292 { |
172 'policy_definitions': [ | 293 'policy_definitions': [ |
173 { | 294 { |
174 'name': 'IntGroup', | 295 'name': 'IntGroup', |
175 'type': 'group', | 296 'type': 'group', |
176 'caption': '', | 297 'caption': '', |
177 'desc': '', | 298 'desc': '', |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
400 {'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'}, | 521 {'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'}, |
401 'plist', | 522 'plist', |
402 'en') | 523 'en') |
403 expected_output = self._GetExpectedOutputs( | 524 expected_output = self._GetExpectedOutputs( |
404 'Google_Chrome', 'com.example.Test2', '''<array/>''') | 525 'Google_Chrome', 'com.example.Test2', '''<array/>''') |
405 self.assertEquals(output.strip(), expected_output.strip()) | 526 self.assertEquals(output.strip(), expected_output.strip()) |
406 | 527 |
407 | 528 |
408 if __name__ == '__main__': | 529 if __name__ == '__main__': |
409 unittest.main() | 530 unittest.main() |
OLD | NEW |