| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 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 | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 '''Unit tests for grit.format.policy_templates.writers.plist_writer''' | |
| 7 | |
| 8 | |
| 9 import os | |
| 10 import sys | |
| 11 if __name__ == '__main__': | |
| 12 sys.path.append(os.path.join(os.path.dirname(__file__), '../../../..')) | |
| 13 | |
| 14 import unittest | |
| 15 | |
| 16 from grit.format.policy_templates.writers import writer_unittest_common | |
| 17 | |
| 18 | |
| 19 class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon): | |
| 20 '''Unit tests for PListWriter.''' | |
| 21 | |
| 22 def _GetExpectedOutputs(self, product_name, bundle_id, policies): | |
| 23 '''Substitutes the variable parts into a plist template. The result | |
| 24 of this function can be used as an expected result to test the output | |
| 25 of PListWriter. | |
| 26 | |
| 27 Args: | |
| 28 product_name: The name of the product, normally Chromium or Google Chrome. | |
| 29 bundle_id: The mac bundle id of the product. | |
| 30 policies: The list of policies. | |
| 31 | |
| 32 Returns: | |
| 33 The text of a plist template with the variable parts substituted. | |
| 34 ''' | |
| 35 return ''' | |
| 36 <?xml version="1.0" ?> | |
| 37 <!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTD
s/PropertyList-1.0.dtd'> | |
| 38 <plist version="1"> | |
| 39 <dict> | |
| 40 <key>pfm_name</key> | |
| 41 <string>%s</string> | |
| 42 <key>pfm_description</key> | |
| 43 <string/> | |
| 44 <key>pfm_title</key> | |
| 45 <string/> | |
| 46 <key>pfm_version</key> | |
| 47 <string>1</string> | |
| 48 <key>pfm_domain</key> | |
| 49 <string>%s</string> | |
| 50 <key>pfm_subkeys</key> | |
| 51 %s | |
| 52 </dict> | |
| 53 </plist>''' % (product_name, bundle_id, policies) | |
| 54 | |
| 55 def _GetExpectedOutputsWithVersion(self, product_name, bundle_id, policies, | |
| 56 version): | |
| 57 '''Substitutes the variable parts into a plist template. The result | |
| 58 of this function can be used as an expected result to test the output | |
| 59 of PListWriter. | |
| 60 | |
| 61 Args: | |
| 62 product_name: The name of the product, normally Chromium or Google Chrome. | |
| 63 bundle_id: The mac bundle id of the product. | |
| 64 policies: The list of policies. | |
| 65 | |
| 66 Returns: | |
| 67 The text of a plist template with the variable parts substituted. | |
| 68 ''' | |
| 69 return ''' | |
| 70 <?xml version="1.0" ?> | |
| 71 <!DOCTYPE plist PUBLIC '-//Apple//DTD PLIST 1.0//EN' 'http://www.apple.com/DTD
s/PropertyList-1.0.dtd'> | |
| 72 <plist version="1"> | |
| 73 <dict> | |
| 74 <key>pfm_name</key> | |
| 75 <string>%s</string> | |
| 76 <key>pfm_description</key> | |
| 77 <string/> | |
| 78 <key>pfm_title</key> | |
| 79 <string/> | |
| 80 <key>pfm_version</key> | |
| 81 <string>1</string> | |
| 82 <key>pfm_domain</key> | |
| 83 <string>%s</string> | |
| 84 <key>pfm_subkeys</key> | |
| 85 %s | |
| 86 </dict> | |
| 87 <!--%s--> | |
| 88 </plist>''' % (product_name, bundle_id, policies, version) | |
| 89 | |
| 90 def testEmpty(self): | |
| 91 # Test PListWriter in case of empty polices. | |
| 92 grd = self.PrepareTest(''' | |
| 93 { | |
| 94 'policy_definitions': [], | |
| 95 'placeholders': [], | |
| 96 'messages': {}, | |
| 97 }''') | |
| 98 | |
| 99 output = self.GetOutput( | |
| 100 grd, | |
| 101 'fr', | |
| 102 {'_chromium': '1', 'mac_bundle_id': 'com.example.Test'}, | |
| 103 'plist', | |
| 104 'en') | |
| 105 expected_output = self._GetExpectedOutputs( | |
| 106 'Chromium', 'com.example.Test', '<array/>') | |
| 107 self.assertEquals(output.strip(), expected_output.strip()) | |
| 108 | |
| 109 def testEmptyVersion(self): | |
| 110 # Test PListWriter in case of empty polices. | |
| 111 grd = self.PrepareTest(''' | |
| 112 { | |
| 113 'policy_definitions': [], | |
| 114 'placeholders': [], | |
| 115 'messages': {}, | |
| 116 }''') | |
| 117 | |
| 118 output = self.GetOutput( | |
| 119 grd, | |
| 120 'fr', | |
| 121 {'_chromium': '1', | |
| 122 'mac_bundle_id': 'com.example.Test', | |
| 123 'version': '39.0.0.0'}, | |
| 124 'plist', | |
| 125 'en') | |
| 126 expected_output = self._GetExpectedOutputsWithVersion( | |
| 127 'Chromium', | |
| 128 'com.example.Test', | |
| 129 '<array/>', | |
| 130 'chromium version: 39.0.0.0') | |
| 131 self.assertEquals(output.strip(), expected_output.strip()) | |
| 132 | |
| 133 def testMainPolicy(self): | |
| 134 # Tests a policy group with a single policy of type 'main'. | |
| 135 grd = self.PrepareTest(''' | |
| 136 { | |
| 137 'policy_definitions': [ | |
| 138 { | |
| 139 'name': 'MainGroup', | |
| 140 'type': 'group', | |
| 141 'policies': [{ | |
| 142 'name': 'MainPolicy', | |
| 143 'type': 'main', | |
| 144 'desc': '', | |
| 145 'caption': '', | |
| 146 'supported_on': ['chrome.mac:8-'], | |
| 147 }], | |
| 148 'desc': '', | |
| 149 'caption': '', | |
| 150 }, | |
| 151 ], | |
| 152 'placeholders': [], | |
| 153 'messages': {} | |
| 154 }''') | |
| 155 output = self.GetOutput( | |
| 156 grd, | |
| 157 'fr', | |
| 158 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
| 159 'plist', | |
| 160 'en') | |
| 161 expected_output = self._GetExpectedOutputs( | |
| 162 'Chromium', 'com.example.Test', '''<array> | |
| 163 <dict> | |
| 164 <key>pfm_name</key> | |
| 165 <string>MainPolicy</string> | |
| 166 <key>pfm_description</key> | |
| 167 <string/> | |
| 168 <key>pfm_title</key> | |
| 169 <string/> | |
| 170 <key>pfm_targets</key> | |
| 171 <array> | |
| 172 <string>user-managed</string> | |
| 173 </array> | |
| 174 <key>pfm_type</key> | |
| 175 <string>boolean</string> | |
| 176 </dict> | |
| 177 </array>''') | |
| 178 self.assertEquals(output.strip(), expected_output.strip()) | |
| 179 | |
| 180 def testRecommendedPolicy(self): | |
| 181 # Tests a policy group with a single policy of type 'main'. | |
| 182 grd = self.PrepareTest(''' | |
| 183 { | |
| 184 'policy_definitions': [ | |
| 185 { | |
| 186 'name': 'MainGroup', | |
| 187 'type': 'group', | |
| 188 'policies': [{ | |
| 189 'name': 'MainPolicy', | |
| 190 'type': 'main', | |
| 191 'desc': '', | |
| 192 'caption': '', | |
| 193 'features': { | |
| 194 'can_be_recommended' : True | |
| 195 }, | |
| 196 'supported_on': ['chrome.mac:8-'], | |
| 197 }], | |
| 198 'desc': '', | |
| 199 'caption': '', | |
| 200 }, | |
| 201 ], | |
| 202 'placeholders': [], | |
| 203 'messages': {} | |
| 204 }''') | |
| 205 output = self.GetOutput( | |
| 206 grd, | |
| 207 'fr', | |
| 208 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
| 209 'plist', | |
| 210 'en') | |
| 211 expected_output = self._GetExpectedOutputs( | |
| 212 'Chromium', 'com.example.Test', '''<array> | |
| 213 <dict> | |
| 214 <key>pfm_name</key> | |
| 215 <string>MainPolicy</string> | |
| 216 <key>pfm_description</key> | |
| 217 <string/> | |
| 218 <key>pfm_title</key> | |
| 219 <string/> | |
| 220 <key>pfm_targets</key> | |
| 221 <array> | |
| 222 <string>user</string> | |
| 223 <string>user-managed</string> | |
| 224 </array> | |
| 225 <key>pfm_type</key> | |
| 226 <string>boolean</string> | |
| 227 </dict> | |
| 228 </array>''') | |
| 229 self.assertEquals(output.strip(), expected_output.strip()) | |
| 230 | |
| 231 def testRecommendedOnlyPolicy(self): | |
| 232 # Tests a policy group with a single policy of type 'main'. | |
| 233 grd = self.PrepareTest(''' | |
| 234 { | |
| 235 'policy_definitions': [ | |
| 236 { | |
| 237 'name': 'MainGroup', | |
| 238 'type': 'group', | |
| 239 'policies': [{ | |
| 240 'name': 'MainPolicy', | |
| 241 'type': 'main', | |
| 242 'desc': '', | |
| 243 'caption': '', | |
| 244 'features': { | |
| 245 'can_be_recommended' : True, | |
| 246 'can_be_mandatory' : False | |
| 247 }, | |
| 248 'supported_on': ['chrome.mac:8-'], | |
| 249 }], | |
| 250 'desc': '', | |
| 251 'caption': '', | |
| 252 }, | |
| 253 ], | |
| 254 'placeholders': [], | |
| 255 'messages': {} | |
| 256 }''') | |
| 257 output = self.GetOutput( | |
| 258 grd, | |
| 259 'fr', | |
| 260 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
| 261 'plist', | |
| 262 'en') | |
| 263 expected_output = self._GetExpectedOutputs( | |
| 264 'Chromium', 'com.example.Test', '''<array> | |
| 265 <dict> | |
| 266 <key>pfm_name</key> | |
| 267 <string>MainPolicy</string> | |
| 268 <key>pfm_description</key> | |
| 269 <string/> | |
| 270 <key>pfm_title</key> | |
| 271 <string/> | |
| 272 <key>pfm_targets</key> | |
| 273 <array> | |
| 274 <string>user</string> | |
| 275 </array> | |
| 276 <key>pfm_type</key> | |
| 277 <string>boolean</string> | |
| 278 </dict> | |
| 279 </array>''') | |
| 280 self.assertEquals(output.strip(), expected_output.strip()) | |
| 281 | |
| 282 def testStringPolicy(self): | |
| 283 # Tests a policy group with a single policy of type 'string'. | |
| 284 grd = self.PrepareTest(''' | |
| 285 { | |
| 286 'policy_definitions': [ | |
| 287 { | |
| 288 'name': 'StringGroup', | |
| 289 'type': 'group', | |
| 290 'desc': '', | |
| 291 'caption': '', | |
| 292 'policies': [{ | |
| 293 'name': 'StringPolicy', | |
| 294 'type': 'string', | |
| 295 'supported_on': ['chrome.mac:8-'], | |
| 296 'desc': '', | |
| 297 'caption': '', | |
| 298 }], | |
| 299 }, | |
| 300 ], | |
| 301 'placeholders': [], | |
| 302 'messages': {}, | |
| 303 }''') | |
| 304 output = self.GetOutput( | |
| 305 grd, | |
| 306 'fr', | |
| 307 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
| 308 'plist', | |
| 309 'en') | |
| 310 expected_output = self._GetExpectedOutputs( | |
| 311 'Chromium', 'com.example.Test', '''<array> | |
| 312 <dict> | |
| 313 <key>pfm_name</key> | |
| 314 <string>StringPolicy</string> | |
| 315 <key>pfm_description</key> | |
| 316 <string/> | |
| 317 <key>pfm_title</key> | |
| 318 <string/> | |
| 319 <key>pfm_targets</key> | |
| 320 <array> | |
| 321 <string>user-managed</string> | |
| 322 </array> | |
| 323 <key>pfm_type</key> | |
| 324 <string>string</string> | |
| 325 </dict> | |
| 326 </array>''') | |
| 327 self.assertEquals(output.strip(), expected_output.strip()) | |
| 328 | |
| 329 def testListPolicy(self): | |
| 330 # Tests a policy group with a single policy of type 'list'. | |
| 331 grd = self.PrepareTest(''' | |
| 332 { | |
| 333 'policy_definitions': [ | |
| 334 { | |
| 335 'name': 'ListGroup', | |
| 336 'type': 'group', | |
| 337 'desc': '', | |
| 338 'caption': '', | |
| 339 'policies': [{ | |
| 340 'name': 'ListPolicy', | |
| 341 'type': 'list', | |
| 342 'schema': { | |
| 343 'type': 'array', | |
| 344 'items': { 'type': 'string' }, | |
| 345 }, | |
| 346 'supported_on': ['chrome.mac:8-'], | |
| 347 'desc': '', | |
| 348 'caption': '', | |
| 349 }], | |
| 350 }, | |
| 351 ], | |
| 352 'placeholders': [], | |
| 353 'messages': {}, | |
| 354 }''') | |
| 355 output = self.GetOutput( | |
| 356 grd, | |
| 357 'fr', | |
| 358 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
| 359 'plist', | |
| 360 'en') | |
| 361 expected_output = self._GetExpectedOutputs( | |
| 362 'Chromium', 'com.example.Test', '''<array> | |
| 363 <dict> | |
| 364 <key>pfm_name</key> | |
| 365 <string>ListPolicy</string> | |
| 366 <key>pfm_description</key> | |
| 367 <string/> | |
| 368 <key>pfm_title</key> | |
| 369 <string/> | |
| 370 <key>pfm_targets</key> | |
| 371 <array> | |
| 372 <string>user-managed</string> | |
| 373 </array> | |
| 374 <key>pfm_type</key> | |
| 375 <string>array</string> | |
| 376 <key>pfm_subkeys</key> | |
| 377 <array> | |
| 378 <dict> | |
| 379 <key>pfm_type</key> | |
| 380 <string>string</string> | |
| 381 </dict> | |
| 382 </array> | |
| 383 </dict> | |
| 384 </array>''') | |
| 385 self.assertEquals(output.strip(), expected_output.strip()) | |
| 386 | |
| 387 def testStringEnumListPolicy(self): | |
| 388 # Tests a policy group with a single policy of type 'string-enum-list'. | |
| 389 grd = self.PrepareTest(''' | |
| 390 { | |
| 391 'policy_definitions': [ | |
| 392 { | |
| 393 'name': 'ListGroup', | |
| 394 'type': 'group', | |
| 395 'desc': '', | |
| 396 'caption': '', | |
| 397 'policies': [{ | |
| 398 'name': 'ListPolicy', | |
| 399 'type': 'string-enum-list', | |
| 400 'schema': { | |
| 401 'type': 'array', | |
| 402 'items': { 'type': 'string' }, | |
| 403 }, | |
| 404 'items': [ | |
| 405 {'name': 'ProxyServerDisabled', 'value': 'one', 'caption': ''}, | |
| 406 {'name': 'ProxyServerAutoDetect', 'value': 'two', 'caption': ''}
, | |
| 407 ], | |
| 408 'supported_on': ['chrome.mac:8-'], | |
| 409 'supported_on': ['chrome.mac:8-'], | |
| 410 'desc': '', | |
| 411 'caption': '', | |
| 412 }], | |
| 413 }, | |
| 414 ], | |
| 415 'placeholders': [], | |
| 416 'messages': {}, | |
| 417 }''') | |
| 418 output = self.GetOutput( | |
| 419 grd, | |
| 420 'fr', | |
| 421 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
| 422 'plist', | |
| 423 'en') | |
| 424 expected_output = self._GetExpectedOutputs( | |
| 425 'Chromium', 'com.example.Test', '''<array> | |
| 426 <dict> | |
| 427 <key>pfm_name</key> | |
| 428 <string>ListPolicy</string> | |
| 429 <key>pfm_description</key> | |
| 430 <string/> | |
| 431 <key>pfm_title</key> | |
| 432 <string/> | |
| 433 <key>pfm_targets</key> | |
| 434 <array> | |
| 435 <string>user-managed</string> | |
| 436 </array> | |
| 437 <key>pfm_type</key> | |
| 438 <string>array</string> | |
| 439 <key>pfm_subkeys</key> | |
| 440 <array> | |
| 441 <dict> | |
| 442 <key>pfm_type</key> | |
| 443 <string>string</string> | |
| 444 </dict> | |
| 445 </array> | |
| 446 </dict> | |
| 447 </array>''') | |
| 448 self.assertEquals(output.strip(), expected_output.strip()) | |
| 449 | |
| 450 def testIntPolicy(self): | |
| 451 # Tests a policy group with a single policy of type 'int'. | |
| 452 grd = self.PrepareTest(''' | |
| 453 { | |
| 454 'policy_definitions': [ | |
| 455 { | |
| 456 'name': 'IntGroup', | |
| 457 'type': 'group', | |
| 458 'caption': '', | |
| 459 'desc': '', | |
| 460 'policies': [{ | |
| 461 'name': 'IntPolicy', | |
| 462 'type': 'int', | |
| 463 'caption': '', | |
| 464 'desc': '', | |
| 465 'supported_on': ['chrome.mac:8-'], | |
| 466 }], | |
| 467 }, | |
| 468 ], | |
| 469 'placeholders': [], | |
| 470 'messages': {}, | |
| 471 }''') | |
| 472 output = self.GetOutput( | |
| 473 grd, | |
| 474 'fr', | |
| 475 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
| 476 'plist', | |
| 477 'en') | |
| 478 expected_output = self._GetExpectedOutputs( | |
| 479 'Chromium', 'com.example.Test', '''<array> | |
| 480 <dict> | |
| 481 <key>pfm_name</key> | |
| 482 <string>IntPolicy</string> | |
| 483 <key>pfm_description</key> | |
| 484 <string/> | |
| 485 <key>pfm_title</key> | |
| 486 <string/> | |
| 487 <key>pfm_targets</key> | |
| 488 <array> | |
| 489 <string>user-managed</string> | |
| 490 </array> | |
| 491 <key>pfm_type</key> | |
| 492 <string>integer</string> | |
| 493 </dict> | |
| 494 </array>''') | |
| 495 self.assertEquals(output.strip(), expected_output.strip()) | |
| 496 | |
| 497 def testIntEnumPolicy(self): | |
| 498 # Tests a policy group with a single policy of type 'int-enum'. | |
| 499 grd = self.PrepareTest(''' | |
| 500 { | |
| 501 'policy_definitions': [ | |
| 502 { | |
| 503 'name': 'EnumGroup', | |
| 504 'type': 'group', | |
| 505 'caption': '', | |
| 506 'desc': '', | |
| 507 'policies': [{ | |
| 508 'name': 'EnumPolicy', | |
| 509 'type': 'int-enum', | |
| 510 'desc': '', | |
| 511 'caption': '', | |
| 512 'items': [ | |
| 513 {'name': 'ProxyServerDisabled', 'value': 0, 'caption': ''}, | |
| 514 {'name': 'ProxyServerAutoDetect', 'value': 1, 'caption': ''}, | |
| 515 ], | |
| 516 'supported_on': ['chrome.mac:8-'], | |
| 517 }], | |
| 518 }, | |
| 519 ], | |
| 520 'placeholders': [], | |
| 521 'messages': {}, | |
| 522 }''') | |
| 523 output = self.GetOutput( | |
| 524 grd, | |
| 525 'fr', | |
| 526 {'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'}, | |
| 527 'plist', | |
| 528 'en') | |
| 529 expected_output = self._GetExpectedOutputs( | |
| 530 'Google_Chrome', 'com.example.Test2', '''<array> | |
| 531 <dict> | |
| 532 <key>pfm_name</key> | |
| 533 <string>EnumPolicy</string> | |
| 534 <key>pfm_description</key> | |
| 535 <string/> | |
| 536 <key>pfm_title</key> | |
| 537 <string/> | |
| 538 <key>pfm_targets</key> | |
| 539 <array> | |
| 540 <string>user-managed</string> | |
| 541 </array> | |
| 542 <key>pfm_type</key> | |
| 543 <string>integer</string> | |
| 544 <key>pfm_range_list</key> | |
| 545 <array> | |
| 546 <integer>0</integer> | |
| 547 <integer>1</integer> | |
| 548 </array> | |
| 549 </dict> | |
| 550 </array>''') | |
| 551 self.assertEquals(output.strip(), expected_output.strip()) | |
| 552 | |
| 553 def testStringEnumPolicy(self): | |
| 554 # Tests a policy group with a single policy of type 'string-enum'. | |
| 555 grd = self.PrepareTest(''' | |
| 556 { | |
| 557 'policy_definitions': [ | |
| 558 { | |
| 559 'name': 'EnumGroup', | |
| 560 'type': 'group', | |
| 561 'caption': '', | |
| 562 'desc': '', | |
| 563 'policies': [{ | |
| 564 'name': 'EnumPolicy', | |
| 565 'type': 'string-enum', | |
| 566 'desc': '', | |
| 567 'caption': '', | |
| 568 'items': [ | |
| 569 {'name': 'ProxyServerDisabled', 'value': 'one', 'caption': ''}, | |
| 570 {'name': 'ProxyServerAutoDetect', 'value': 'two', 'caption': ''}
, | |
| 571 ], | |
| 572 'supported_on': ['chrome.mac:8-'], | |
| 573 }], | |
| 574 }, | |
| 575 ], | |
| 576 'placeholders': [], | |
| 577 'messages': {}, | |
| 578 }''') | |
| 579 output = self.GetOutput( | |
| 580 grd, | |
| 581 'fr', | |
| 582 {'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'}, | |
| 583 'plist', | |
| 584 'en') | |
| 585 expected_output = self._GetExpectedOutputs( | |
| 586 'Google_Chrome', 'com.example.Test2', '''<array> | |
| 587 <dict> | |
| 588 <key>pfm_name</key> | |
| 589 <string>EnumPolicy</string> | |
| 590 <key>pfm_description</key> | |
| 591 <string/> | |
| 592 <key>pfm_title</key> | |
| 593 <string/> | |
| 594 <key>pfm_targets</key> | |
| 595 <array> | |
| 596 <string>user-managed</string> | |
| 597 </array> | |
| 598 <key>pfm_type</key> | |
| 599 <string>string</string> | |
| 600 <key>pfm_range_list</key> | |
| 601 <array> | |
| 602 <string>one</string> | |
| 603 <string>two</string> | |
| 604 </array> | |
| 605 </dict> | |
| 606 </array>''') | |
| 607 self.assertEquals(output.strip(), expected_output.strip()) | |
| 608 | |
| 609 def testDictionaryPolicy(self): | |
| 610 # Tests a policy group with a single policy of type 'dict'. | |
| 611 grd = self.PrepareTest(''' | |
| 612 { | |
| 613 'policy_definitions': [ | |
| 614 { | |
| 615 'name': 'DictionaryGroup', | |
| 616 'type': 'group', | |
| 617 'desc': '', | |
| 618 'caption': '', | |
| 619 'policies': [{ | |
| 620 'name': 'DictionaryPolicy', | |
| 621 'type': 'dict', | |
| 622 'supported_on': ['chrome.mac:8-'], | |
| 623 'desc': '', | |
| 624 'caption': '', | |
| 625 }], | |
| 626 }, | |
| 627 ], | |
| 628 'placeholders': [], | |
| 629 'messages': {}, | |
| 630 }''') | |
| 631 output = self.GetOutput( | |
| 632 grd, | |
| 633 'fr', | |
| 634 {'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'}, | |
| 635 'plist', | |
| 636 'en') | |
| 637 expected_output = self._GetExpectedOutputs( | |
| 638 'Chromium', 'com.example.Test', '''<array> | |
| 639 <dict> | |
| 640 <key>pfm_name</key> | |
| 641 <string>DictionaryPolicy</string> | |
| 642 <key>pfm_description</key> | |
| 643 <string/> | |
| 644 <key>pfm_title</key> | |
| 645 <string/> | |
| 646 <key>pfm_targets</key> | |
| 647 <array> | |
| 648 <string>user-managed</string> | |
| 649 </array> | |
| 650 <key>pfm_type</key> | |
| 651 <string>dictionary</string> | |
| 652 </dict> | |
| 653 </array>''') | |
| 654 self.assertEquals(output.strip(), expected_output.strip()) | |
| 655 | |
| 656 def testNonSupportedPolicy(self): | |
| 657 # Tests a policy that is not supported on Mac, so it shouldn't | |
| 658 # be included in the plist file. | |
| 659 grd = self.PrepareTest(''' | |
| 660 { | |
| 661 'policy_definitions': [ | |
| 662 { | |
| 663 'name': 'NonMacGroup', | |
| 664 'type': 'group', | |
| 665 'caption': '', | |
| 666 'desc': '', | |
| 667 'policies': [{ | |
| 668 'name': 'NonMacPolicy', | |
| 669 'type': 'string', | |
| 670 'supported_on': ['chrome.linux:8-', 'chrome.win:7-'], | |
| 671 'caption': '', | |
| 672 'desc': '', | |
| 673 }], | |
| 674 }, | |
| 675 ], | |
| 676 'placeholders': [], | |
| 677 'messages': {}, | |
| 678 }''') | |
| 679 output = self.GetOutput( | |
| 680 grd, | |
| 681 'fr', | |
| 682 {'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'}, | |
| 683 'plist', | |
| 684 'en') | |
| 685 expected_output = self._GetExpectedOutputs( | |
| 686 'Google_Chrome', 'com.example.Test2', '''<array/>''') | |
| 687 self.assertEquals(output.strip(), expected_output.strip()) | |
| 688 | |
| 689 | |
| 690 if __name__ == '__main__': | |
| 691 unittest.main() | |
| OLD | NEW |