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 | 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 ' <enabledValue>\n' | 212 ' <enabledValue>\n' |
213 ' <decimal value="1"/>\n' | 213 ' <decimal value="1"/>\n' |
214 ' </enabledValue>\n' | 214 ' </enabledValue>\n' |
215 ' <disabledValue>\n' | 215 ' <disabledValue>\n' |
216 ' <decimal value="0"/>\n' | 216 ' <decimal value="0"/>\n' |
217 ' </disabledValue>\n' | 217 ' </disabledValue>\n' |
218 '</policy>') | 218 '</policy>') |
219 | 219 |
220 self.AssertXMLEquals(output, expected_output) | 220 self.AssertXMLEquals(output, expected_output) |
221 | 221 |
| 222 def testRecommendedOnlyPolicy(self): |
| 223 main_policy = { |
| 224 'name': 'DummyMainPolicy', |
| 225 'type': 'main', |
| 226 'features': { |
| 227 'can_be_recommended': True, |
| 228 'can_be_mandatory': False, |
| 229 } |
| 230 } |
| 231 |
| 232 policy_group = { |
| 233 'name': 'PolicyGroup', |
| 234 'policies': [main_policy], |
| 235 } |
| 236 self.writer.BeginTemplate() |
| 237 self.writer.BeginRecommendedPolicyGroup(policy_group) |
| 238 |
| 239 self.writer.WritePolicy(main_policy) |
| 240 self.writer.WriteRecommendedPolicy(main_policy) |
| 241 |
| 242 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) |
| 243 expected_output = ( |
| 244 '<policy class="TestClass" displayName="$(string.DummyMainPolicy)"' |
| 245 ' explainText="$(string.DummyMainPolicy_Explain)"' |
| 246 ' key="Software\\Policies\\Test\\Recommended"' |
| 247 ' name="DummyMainPolicy_recommended"' |
| 248 ' presentation="$(presentation.DummyMainPolicy)"' |
| 249 ' valueName="DummyMainPolicy">\n' |
| 250 ' <parentCategory ref="PolicyGroup_recommended"/>\n' |
| 251 ' <supportedOn ref="SUPPORTED_TESTOS"/>\n' |
| 252 ' <enabledValue>\n' |
| 253 ' <decimal value="1"/>\n' |
| 254 ' </enabledValue>\n' |
| 255 ' <disabledValue>\n' |
| 256 ' <decimal value="0"/>\n' |
| 257 ' </disabledValue>\n' |
| 258 '</policy>') |
| 259 |
| 260 self.AssertXMLEquals(output, expected_output) |
| 261 |
222 def testStringPolicy(self): | 262 def testStringPolicy(self): |
223 string_policy = { | 263 string_policy = { |
224 'name': 'SampleStringPolicy', | 264 'name': 'SampleStringPolicy', |
225 'type': 'string', | 265 'type': 'string', |
226 } | 266 } |
227 self._initWriterForPolicy(self.writer, string_policy) | 267 self._initWriterForPolicy(self.writer, string_policy) |
228 | 268 |
229 self.writer.WritePolicy(string_policy) | 269 self.writer.WritePolicy(string_policy) |
230 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) | 270 output = self.GetXMLOfChildren(self._GetPoliciesElement(self.writer._doc)) |
231 expected_output = ( | 271 expected_output = ( |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 })) | 469 })) |
430 self.assertFalse(self.writer.IsPolicySupported({ | 470 self.assertFalse(self.writer.IsPolicySupported({ |
431 'supported_on': [ | 471 'supported_on': [ |
432 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} | 472 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} |
433 ] | 473 ] |
434 })) | 474 })) |
435 | 475 |
436 | 476 |
437 if __name__ == '__main__': | 477 if __name__ == '__main__': |
438 unittest.main() | 478 unittest.main() |
OLD | NEW |