| OLD | NEW |
| 1 #!/usr/bin/python2.4 | 1 #!/usr/bin/python2.4 |
| 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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.adml_writer.""" | 7 """Unittests for grit.format.policy_templates.writers.adml_writer.""" |
| 8 | 8 |
| 9 | 9 |
| 10 import os | 10 import os |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 expected_output = ( | 151 expected_output = ( |
| 152 '<presentation id="StringPolicyStub">\n' | 152 '<presentation id="StringPolicyStub">\n' |
| 153 ' <textBox refId="StringPolicyStub">\n' | 153 ' <textBox refId="StringPolicyStub">\n' |
| 154 ' <label>\n' | 154 ' <label>\n' |
| 155 ' String policy label\n' | 155 ' String policy label\n' |
| 156 ' </label>\n' | 156 ' </label>\n' |
| 157 ' </textBox>\n' | 157 ' </textBox>\n' |
| 158 '</presentation>') | 158 '</presentation>') |
| 159 self.AssertXMLEquals(output, expected_output) | 159 self.AssertXMLEquals(output, expected_output) |
| 160 | 160 |
| 161 def testEnumPolicy(self): | 161 def testIntEnumPolicy(self): |
| 162 enum_policy = { | 162 enum_policy = { |
| 163 'name': 'EnumPolicyStub', | 163 'name': 'EnumPolicyStub', |
| 164 'type': 'enum', | 164 'type': 'int-enum', |
| 165 'caption': 'Enum policy caption', | 165 'caption': 'Enum policy caption', |
| 166 'label': 'Enum policy label', | 166 'label': 'Enum policy label', |
| 167 'desc': 'This is a test description.', | 167 'desc': 'This is a test description.', |
| 168 'items': [ |
| 169 { |
| 170 'name': 'item 1', |
| 171 'value': 1, |
| 172 'caption': 'Caption Item 1', |
| 173 }, |
| 174 { |
| 175 'name': 'item 2', |
| 176 'value': 2, |
| 177 'caption': 'Caption Item 2', |
| 178 }, |
| 179 ], |
| 180 } |
| 181 self. _InitWriterForAddingPolicies(self.writer, enum_policy) |
| 182 self.writer.WritePolicy(enum_policy) |
| 183 # Assert generated string elements. |
| 184 output = self.GetXMLOfChildren(self.writer._string_table_elem) |
| 185 expected_output = ( |
| 186 '<string id="EnumPolicyStub">\n' |
| 187 ' Enum policy caption\n' |
| 188 '</string>\n' |
| 189 '<string id="EnumPolicyStub_Explain">\n' |
| 190 ' This is a test description.\n' |
| 191 '</string>\n' |
| 192 '<string id="item 1">\n' |
| 193 ' Caption Item 1\n' |
| 194 '</string>\n' |
| 195 '<string id="item 2">\n' |
| 196 ' Caption Item 2\n' |
| 197 '</string>') |
| 198 self.AssertXMLEquals(output, expected_output) |
| 199 # Assert generated presentation elements. |
| 200 output = self.GetXMLOfChildren(self.writer._presentation_table_elem) |
| 201 expected_output = ( |
| 202 '<presentation id="EnumPolicyStub">\n' |
| 203 ' <dropdownList refId="EnumPolicyStub">\n' |
| 204 ' Enum policy label\n' |
| 205 ' </dropdownList>\n' |
| 206 '</presentation>') |
| 207 self.AssertXMLEquals(output, expected_output) |
| 208 |
| 209 def testStringEnumPolicy(self): |
| 210 enum_policy = { |
| 211 'name': 'EnumPolicyStub', |
| 212 'type': 'string-enum', |
| 213 'caption': 'Enum policy caption', |
| 214 'label': 'Enum policy label', |
| 215 'desc': 'This is a test description.', |
| 168 'items': [ | 216 'items': [ |
| 169 { | 217 { |
| 170 'name': 'item 1', | 218 'name': 'item 1', |
| 171 'value': 'value 1', | 219 'value': 'value 1', |
| 172 'caption': 'Caption Item 1', | 220 'caption': 'Caption Item 1', |
| 173 }, | 221 }, |
| 174 { | 222 { |
| 175 'name': 'item 2', | 223 'name': 'item 2', |
| 176 'value': 'value 2', | 224 'value': 'value 2', |
| 177 'caption': 'Caption Item 2', | 225 'caption': 'Caption Item 2', |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 })) | 296 })) |
| 249 self.assertFalse(self.writer.IsPolicySupported({ | 297 self.assertFalse(self.writer.IsPolicySupported({ |
| 250 'supported_on': [ | 298 'supported_on': [ |
| 251 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} | 299 {'platforms': ['mac', 'linux']}, {'platforms': ['aaa']} |
| 252 ] | 300 ] |
| 253 })) | 301 })) |
| 254 | 302 |
| 255 | 303 |
| 256 if __name__ == '__main__': | 304 if __name__ == '__main__': |
| 257 unittest.main() | 305 unittest.main() |
| OLD | NEW |