| 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 '''Unit tests for grit.format.policy_templates.writers.adm_writer''' | 6 '''Unit tests for grit.format.policy_templates.writers.adm_writer''' |
| 7 | 7 |
| 8 | 8 |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 [Strings] | 148 [Strings] |
| 149 SUPPORTED_WINXPSP2="At least Windows 3.13" | 149 SUPPORTED_WINXPSP2="At least Windows 3.13" |
| 150 chromium="Chromium" | 150 chromium="Chromium" |
| 151 StringPolicy_Policy="Caption of policy." | 151 StringPolicy_Policy="Caption of policy." |
| 152 StringPolicy_Explain="Description of group.\\nWith a newline." | 152 StringPolicy_Explain="Description of group.\\nWith a newline." |
| 153 StringPolicy_Part="Caption of policy." | 153 StringPolicy_Part="Caption of policy." |
| 154 ''' | 154 ''' |
| 155 self.CompareOutputs(output, expected_output) | 155 self.CompareOutputs(output, expected_output) |
| 156 | 156 |
| 157 def testEnumPolicy(self): | 157 def testIntEnumPolicy(self): |
| 158 # Tests a policy group with a single policy of type 'enum'. | 158 # Tests a policy group with a single policy of type 'int-enum'. |
| 159 grd = self.PrepareTest(''' | 159 grd = self.PrepareTest(''' |
| 160 { | 160 { |
| 161 'policy_definitions': [ | 161 'policy_definitions': [ |
| 162 { | 162 { |
| 163 'name': 'EnumPolicy', | 163 'name': 'EnumPolicy', |
| 164 'type': 'enum', | 164 'type': 'int-enum', |
| 165 'items': [ | 165 'items': [ |
| 166 {'name': 'ProxyServerDisabled', 'value': '0'}, | 166 {'name': 'ProxyServerDisabled', 'value': 0}, |
| 167 {'name': 'ProxyServerAutoDetect', 'value': '1'}, | 167 {'name': 'ProxyServerAutoDetect', 'value': 1}, |
| 168 ], | 168 ], |
| 169 'supported_on': ['chrome.win:8-'] | 169 'supported_on': ['chrome.win:8-'] |
| 170 }, | 170 }, |
| 171 ], | 171 ], |
| 172 'placeholders': [], | 172 'placeholders': [], |
| 173 }''', ''' | 173 }''', ''' |
| 174 <messages> | 174 <messages> |
| 175 <message name="IDS_POLICY_ENUMPOLICY_CAPTION">Caption of policy.</mess
age> | 175 <message name="IDS_POLICY_ENUMPOLICY_CAPTION">Caption of policy.</mess
age> |
| 176 <message name="IDS_POLICY_ENUMPOLICY_DESC">Description of policy.</mes
sage> | 176 <message name="IDS_POLICY_ENUMPOLICY_DESC">Description of policy.</mes
sage> |
| 177 <message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION">Option1</m
essage> | 177 <message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION">Option1</m
essage> |
| (...skipping 30 matching lines...) Expand all Loading... |
| 208 google="Google" | 208 google="Google" |
| 209 googlechrome="Google Chrome" | 209 googlechrome="Google Chrome" |
| 210 EnumPolicy_Policy="Caption of policy." | 210 EnumPolicy_Policy="Caption of policy." |
| 211 EnumPolicy_Explain="Description of policy." | 211 EnumPolicy_Explain="Description of policy." |
| 212 EnumPolicy_Part="Caption of policy." | 212 EnumPolicy_Part="Caption of policy." |
| 213 ProxyServerDisabled_DropDown="Option1" | 213 ProxyServerDisabled_DropDown="Option1" |
| 214 ProxyServerAutoDetect_DropDown="Option2" | 214 ProxyServerAutoDetect_DropDown="Option2" |
| 215 ''' | 215 ''' |
| 216 self.CompareOutputs(output, expected_output) | 216 self.CompareOutputs(output, expected_output) |
| 217 | 217 |
| 218 def testStringEnumPolicy(self): |
| 219 # Tests a policy group with a single policy of type 'int-enum'. |
| 220 grd = self.PrepareTest(''' |
| 221 { |
| 222 'policy_definitions': [ |
| 223 { |
| 224 'name': 'EnumPolicy', |
| 225 'type': 'string-enum', |
| 226 'items': [ |
| 227 {'name': 'ProxyServerDisabled', 'value': 'one'}, |
| 228 {'name': 'ProxyServerAutoDetect', 'value': 'two'}, |
| 229 ], |
| 230 'supported_on': ['chrome.win:8-'] |
| 231 }, |
| 232 ], |
| 233 'placeholders': [], |
| 234 }''', ''' |
| 235 <messages> |
| 236 <message name="IDS_POLICY_ENUMPOLICY_CAPTION">Caption of policy.</mess
age> |
| 237 <message name="IDS_POLICY_ENUMPOLICY_DESC">Description of policy.</mes
sage> |
| 238 <message name="IDS_POLICY_ENUM_PROXYSERVERDISABLED_CAPTION">Option1</m
essage> |
| 239 <message name="IDS_POLICY_ENUM_PROXYSERVERAUTODETECT_CAPTION">Option2<
/message> |
| 240 <message name="IDS_POLICY_WIN_SUPPORTED_WINXPSP2">At least Windows 3.1
4</message> |
| 241 </messages> |
| 242 ''' ) |
| 243 output = self.GetOutput(grd, 'fr', {'_google_chrome': '1'}, 'adm', 'en') |
| 244 expected_output = '''CLASS MACHINE |
| 245 CATEGORY !!google |
| 246 CATEGORY !!googlechrome |
| 247 KEYNAME "Software\\Policies\\Google\\Chrome" |
| 248 |
| 249 POLICY !!EnumPolicy_Policy |
| 250 #if version >= 4 |
| 251 SUPPORTED !!SUPPORTED_WINXPSP2 |
| 252 #endif |
| 253 EXPLAIN !!EnumPolicy_Explain |
| 254 |
| 255 PART !!EnumPolicy_Part DROPDOWNLIST |
| 256 VALUENAME "EnumPolicy" |
| 257 ITEMLIST |
| 258 NAME !!ProxyServerDisabled_DropDown VALUE "one" |
| 259 NAME !!ProxyServerAutoDetect_DropDown VALUE "two" |
| 260 END ITEMLIST |
| 261 END PART |
| 262 END POLICY |
| 263 |
| 264 END CATEGORY |
| 265 END CATEGORY |
| 266 |
| 267 [Strings] |
| 268 SUPPORTED_WINXPSP2="At least Windows 3.14" |
| 269 google="Google" |
| 270 googlechrome="Google Chrome" |
| 271 EnumPolicy_Policy="Caption of policy." |
| 272 EnumPolicy_Explain="Description of policy." |
| 273 EnumPolicy_Part="Caption of policy." |
| 274 ProxyServerDisabled_DropDown="Option1" |
| 275 ProxyServerAutoDetect_DropDown="Option2" |
| 276 ''' |
| 277 self.CompareOutputs(output, expected_output) |
| 278 |
| 218 def testListPolicy(self): | 279 def testListPolicy(self): |
| 219 # Tests a policy group with a single policy of type 'list'. | 280 # Tests a policy group with a single policy of type 'list'. |
| 220 grd = self.PrepareTest(''' | 281 grd = self.PrepareTest(''' |
| 221 { | 282 { |
| 222 'policy_definitions': [ | 283 'policy_definitions': [ |
| 223 { | 284 { |
| 224 'name': 'ListPolicy', | 285 'name': 'ListPolicy', |
| 225 'type': 'list', | 286 'type': 'list', |
| 226 'supported_on': ['chrome.win:8-'] | 287 'supported_on': ['chrome.win:8-'] |
| 227 }, | 288 }, |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 Policy1_Explain="Description of policy1.\\nWith a newline." | 437 Policy1_Explain="Description of policy1.\\nWith a newline." |
| 377 Policy1_Part="Caption of policy1." | 438 Policy1_Part="Caption of policy1." |
| 378 Policy2_Policy="Caption of policy2." | 439 Policy2_Policy="Caption of policy2." |
| 379 Policy2_Explain="Description of policy2.\\nWith a newline." | 440 Policy2_Explain="Description of policy2.\\nWith a newline." |
| 380 Policy2_Part="Caption of policy2." | 441 Policy2_Part="Caption of policy2." |
| 381 ''' | 442 ''' |
| 382 self.CompareOutputs(output, expected_output) | 443 self.CompareOutputs(output, expected_output) |
| 383 | 444 |
| 384 if __name__ == '__main__': | 445 if __name__ == '__main__': |
| 385 unittest.main() | 446 unittest.main() |
| OLD | NEW |