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

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

Issue 692033002: Set the MAXLEN/maxLength attribute for strings in ADM[X] templates. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: fixed upload Created 6 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
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 6
7 """Unittests for grit.format.policy_templates.writers.admx_writer.""" 7 """Unittests for grit.format.policy_templates.writers.admx_writer."""
8 8
9 9
10 import os 10 import os
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 self.writer.WritePolicy(string_policy) 269 self.writer.WritePolicy(string_policy)
270 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) 270 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
271 expected_output = ( 271 expected_output = (
272 '<policy class="TestClass" displayName="$(string.SampleStringPolicy)"' 272 '<policy class="TestClass" displayName="$(string.SampleStringPolicy)"'
273 ' explainText="$(string.SampleStringPolicy_Explain)"' 273 ' explainText="$(string.SampleStringPolicy_Explain)"'
274 ' key="Software\\Policies\\Test" name="SampleStringPolicy"' 274 ' key="Software\\Policies\\Test" name="SampleStringPolicy"'
275 ' presentation="$(presentation.SampleStringPolicy)">\n' 275 ' presentation="$(presentation.SampleStringPolicy)">\n'
276 ' <parentCategory ref="PolicyGroup"/>\n' 276 ' <parentCategory ref="PolicyGroup"/>\n'
277 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' 277 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
278 ' <elements>\n' 278 ' <elements>\n'
279 ' <text id="SampleStringPolicy" valueName="SampleStringPolicy"/>\n' 279 ' <text id="SampleStringPolicy" maxLength="1000000"'
280 ' valueName="SampleStringPolicy"/>\n'
280 ' </elements>\n' 281 ' </elements>\n'
281 '</policy>') 282 '</policy>')
282 self.AssertXMLEquals(output, expected_output) 283 self.AssertXMLEquals(output, expected_output)
283 284
284 def testIntPolicy(self): 285 def testIntPolicy(self):
285 int_policy = { 286 int_policy = {
286 'name': 'SampleIntPolicy', 287 'name': 'SampleIntPolicy',
287 'type': 'int', 288 'type': 'int',
288 } 289 }
289 self._initWriterForPolicy(self.writer, int_policy) 290 self._initWriterForPolicy(self.writer, int_policy)
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) 448 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
448 expected_output = ( 449 expected_output = (
449 '<policy class="TestClass" displayName="$(string.' 450 '<policy class="TestClass" displayName="$(string.'
450 'SampleDictionaryPolicy)"' 451 'SampleDictionaryPolicy)"'
451 ' explainText="$(string.SampleDictionaryPolicy_Explain)"' 452 ' explainText="$(string.SampleDictionaryPolicy_Explain)"'
452 ' key="Software\\Policies\\Test" name="SampleDictionaryPolicy"' 453 ' key="Software\\Policies\\Test" name="SampleDictionaryPolicy"'
453 ' presentation="$(presentation.SampleDictionaryPolicy)">\n' 454 ' presentation="$(presentation.SampleDictionaryPolicy)">\n'
454 ' <parentCategory ref="PolicyGroup"/>\n' 455 ' <parentCategory ref="PolicyGroup"/>\n'
455 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' 456 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
456 ' <elements>\n' 457 ' <elements>\n'
457 ' <text id="SampleDictionaryPolicy" ' 458 ' <text id="SampleDictionaryPolicy" maxLength="1000000"'
458 'valueName="SampleDictionaryPolicy"/>\n' 459 ' valueName="SampleDictionaryPolicy"/>\n'
459 ' </elements>\n' 460 ' </elements>\n'
460 '</policy>') 461 '</policy>')
461 self.AssertXMLEquals(output, expected_output) 462 self.AssertXMLEquals(output, expected_output)
462 463
463 def testPlatform(self): 464 def testPlatform(self):
464 # Test that the writer correctly chooses policies of platform Windows. 465 # Test that the writer correctly chooses policies of platform Windows.
465 self.assertTrue(self.writer.IsPolicySupported({ 466 self.assertTrue(self.writer.IsPolicySupported({
466 'supported_on': [ 467 'supported_on': [
467 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']} 468 {'platforms': ['win', 'zzz']}, {'platforms': ['aaa']}
468 ] 469 ]
469 })) 470 }))
470 self.assertFalse(self.writer.IsPolicySupported({ 471 self.assertFalse(self.writer.IsPolicySupported({
471 'supported_on': [ 472 'supported_on': [
472 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} 473 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']}
473 ] 474 ]
474 })) 475 }))
475 476
476 477
477 if __name__ == '__main__': 478 if __name__ == '__main__':
478 unittest.main() 479 unittest.main()
OLDNEW
« no previous file with comments | « grit/format/policy_templates/writers/admx_writer.py ('k') | grit/format/policy_templates/writers/xml_formatted_writer.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698