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

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

Issue 7155025: Fix string-enums in ADMX templates (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: " Created 9 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/python2.4 1 #!/usr/bin/python2.4
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 def testStringEnumPolicy(self): 260 def testStringEnumPolicy(self):
261 enum_policy = { 261 enum_policy = {
262 'name': 'SampleEnumPolicy', 262 'name': 'SampleEnumPolicy',
263 'type': 'string-enum', 263 'type': 'string-enum',
264 'items': [ 264 'items': [
265 {'name': 'item_1', 'value': 'one'}, 265 {'name': 'item_1', 'value': 'one'},
266 {'name': 'item_2', 'value': 'two'}, 266 {'name': 'item_2', 'value': 'two'},
267 ] 267 ]
268 } 268 }
269 269
270 self._initWriterForPolicy(self.writer, enum_policy) 270 # This test is different than the others because it also tests that space
271 # usage inside <string> nodes is correct.
272 dom_impl = minidom.getDOMImplementation('')
273 self.writer._doc = dom_impl.createDocument(None, 'policyDefinitions', None)
274 self.writer._active_policies_elem = self.writer._doc.documentElement
275 self.writer._active_policy_group_name = 'PolicyGroup'
271 self.writer.WritePolicy(enum_policy) 276 self.writer.WritePolicy(enum_policy)
272 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) 277 output = self.writer.GetTemplateText()
273 expected_output = ( 278 expected_output = (
274 '<policy class="TestClass" displayName="$(string.SampleEnumPolicy)"' 279 '<?xml version="1.0" ?>\n'
275 ' explainText="$(string.SampleEnumPolicy_Explain)"' 280 '<policyDefinitions>\n'
276 ' key="Software\\Policies\\Test" name="SampleEnumPolicy"' 281 ' <policy class="TestClass" displayName="$(string.SampleEnumPolicy)"'
277 ' presentation="$(presentation.SampleEnumPolicy)">\n' 282 ' explainText="$(string.SampleEnumPolicy_Explain)"'
278 ' <parentCategory ref="PolicyGroup"/>\n' 283 ' key="Software\\Policies\\Test" name="SampleEnumPolicy"'
279 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' 284 ' presentation="$(presentation.SampleEnumPolicy)">\n'
280 ' <elements>\n' 285 ' <parentCategory ref="PolicyGroup"/>\n'
281 ' <enum id="SampleEnumPolicy" valueName="SampleEnumPolicy">\n' 286 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n'
282 ' <item displayName="$(string.item_1)">\n' 287 ' <elements>\n'
283 ' <value>\n' 288 ' <enum id="SampleEnumPolicy" valueName="SampleEnumPolicy">\n'
284 ' <string value="one"/>\n' 289 ' <item displayName="$(string.item_1)">\n'
285 ' </value>\n' 290 ' <value>\n'
286 ' </item>\n' 291 ' <string>one</string>\n'
287 ' <item displayName="$(string.item_2)">\n' 292 ' </value>\n'
288 ' <value>\n' 293 ' </item>\n'
289 ' <string value="two"/>\n' 294 ' <item displayName="$(string.item_2)">\n'
290 ' </value>\n' 295 ' <value>\n'
291 ' </item>\n' 296 ' <string>two</string>\n'
292 ' </enum>\n' 297 ' </value>\n'
293 ' </elements>\n' 298 ' </item>\n'
294 '</policy>') 299 ' </enum>\n'
300 ' </elements>\n'
301 ' </policy>\n'
302 '</policyDefinitions>')
295 self.AssertXMLEquals(output, expected_output) 303 self.AssertXMLEquals(output, expected_output)
296 304
297 def testListPolicy(self): 305 def testListPolicy(self):
298 list_policy = { 306 list_policy = {
299 'name': 'SampleListPolicy', 307 'name': 'SampleListPolicy',
300 'type': 'list', 308 'type': 'list',
301 } 309 }
302 self._initWriterForPolicy(self.writer, list_policy) 310 self._initWriterForPolicy(self.writer, list_policy)
303 self.writer.WritePolicy(list_policy) 311 self.writer.WritePolicy(list_policy)
304 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) 312 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc))
(...skipping 21 matching lines...) Expand all
326 })) 334 }))
327 self.assertFalse(self.writer.IsPolicySupported({ 335 self.assertFalse(self.writer.IsPolicySupported({
328 'supported_on': [ 336 'supported_on': [
329 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} 337 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']}
330 ] 338 ]
331 })) 339 }))
332 340
333 341
334 if __name__ == '__main__': 342 if __name__ == '__main__':
335 unittest.main() 343 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698