Chromium Code Reviews| 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 '''Unit tests for grit.format.policy_templates.writers.doc_writer''' | 6 '''Unit tests for grit.format.policy_templates.writers.doc_writer''' |
| 7 | 7 |
| 8 | 8 |
| 9 import json | 9 import json |
| 10 import os | 10 import os |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 'doc_description': {'text': '_test_description'}, | 48 'doc_description': {'text': '_test_description'}, |
| 49 'doc_description_column_title': { | 49 'doc_description_column_title': { |
| 50 'text': '_test_description_column_title' | 50 'text': '_test_description_column_title' |
| 51 }, | 51 }, |
| 52 'doc_example_value': {'text': '_test_example_value'}, | 52 'doc_example_value': {'text': '_test_example_value'}, |
| 53 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'}, | 53 'doc_feature_dynamic_refresh': {'text': '_test_feature_dynamic_refresh'}, |
| 54 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'}, | 54 'doc_feature_can_be_recommended': {'text': '_test_feature_recommended'}, |
| 55 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'}, | 55 'doc_feature_can_be_mandatory': {'text': '_test_feature_mandatory'}, |
| 56 'doc_intro': {'text': '_test_intro'}, | 56 'doc_intro': {'text': '_test_intro'}, |
| 57 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'}, | 57 'doc_mac_linux_pref_name': {'text': '_test_mac_linux_pref_name'}, |
| 58 'doc_android_restriction_name': { | |
| 59 'text': '_test_android_restriction_name' | |
| 60 }, | |
| 58 'doc_note': {'text': '_test_note'}, | 61 'doc_note': {'text': '_test_note'}, |
| 59 'doc_name_column_title': {'text': '_test_name_column_title'}, | 62 'doc_name_column_title': {'text': '_test_name_column_title'}, |
| 60 'doc_not_supported': {'text': '_test_not_supported'}, | 63 'doc_not_supported': {'text': '_test_not_supported'}, |
| 61 'doc_since_version': {'text': '_test_since_version'}, | 64 'doc_since_version': {'text': '_test_since_version'}, |
| 62 'doc_supported': {'text': '_test_supported'}, | 65 'doc_supported': {'text': '_test_supported'}, |
| 63 'doc_supported_features': {'text': '_test_supported_features'}, | 66 'doc_supported_features': {'text': '_test_supported_features'}, |
| 64 'doc_supported_on': {'text': '_test_supported_on'}, | 67 'doc_supported_on': {'text': '_test_supported_on'}, |
| 65 'doc_win_reg_loc': {'text': '_test_win_reg_loc'}, | 68 'doc_win_reg_loc': {'text': '_test_win_reg_loc'}, |
| 66 | 69 |
| 67 'doc_bla': {'text': '_test_bla'}, | 70 'doc_bla': {'text': '_test_bla'}, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 self.writer._AddListExample(self.doc_root, policy) | 254 self.writer._AddListExample(self.doc_root, policy) |
| 252 self.assertEquals( | 255 self.assertEquals( |
| 253 self.doc_root.toxml(), | 256 self.doc_root.toxml(), |
| 254 '<root>' | 257 '<root>' |
| 255 '<dl style="style_dd dl;">' | 258 '<dl style="style_dd dl;">' |
| 256 '<dt>Windows:</dt>' | 259 '<dt>Windows:</dt>' |
| 257 '<dd style="style_.monospace;style_.pre;">' | 260 '<dd style="style_.monospace;style_.pre;">' |
| 258 'MockKey\\PolicyName\\1 = "Foo"\n' | 261 'MockKey\\PolicyName\\1 = "Foo"\n' |
| 259 'MockKey\\PolicyName\\2 = "Bar"' | 262 'MockKey\\PolicyName\\2 = "Bar"' |
| 260 '</dd>' | 263 '</dd>' |
| 261 '<dt>Linux:</dt>' | 264 '<dt>Android/Linux:</dt>' |
| 262 '<dd style="style_.monospace;">' | 265 '<dd style="style_.monospace;">' |
| 263 '["Foo", "Bar"]' | 266 '["Foo", "Bar"]' |
| 264 '</dd>' | 267 '</dd>' |
| 265 '<dt>Mac:</dt>' | 268 '<dt>Mac:</dt>' |
| 266 '<dd style="style_.monospace;style_.pre;">' | 269 '<dd style="style_.monospace;style_.pre;">' |
| 267 '<array>\n' | 270 '<array>\n' |
| 268 ' <string>Foo</string>\n' | 271 ' <string>Foo</string>\n' |
| 269 ' <string>Bar</string>\n' | 272 ' <string>Bar</string>\n' |
| 270 '</array>' | 273 '</array>' |
| 271 '</dd>' | 274 '</dd>' |
| 272 '</dl>' | 275 '</dl>' |
| 273 '</root>') | 276 '</root>') |
| 274 | 277 |
| 275 def testBoolExample(self): | 278 def testBoolExample(self): |
| 276 # Test representation of boolean example values. | 279 # Test representation of boolean example values. |
| 277 policy = { | 280 policy = { |
| 278 'name': 'PolicyName', | 281 'name': 'PolicyName', |
| 279 'type': 'main', | 282 'type': 'main', |
| 280 'example_value': True, | 283 'example_value': True, |
| 281 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ] | 284 'supported_on': [ { 'platforms': ['win', 'mac', 'linux', 'android'] } ] |
| 282 } | 285 } |
| 283 e1 = self.writer.AddElement(self.doc_root, 'e1') | 286 e1 = self.writer.AddElement(self.doc_root, 'e1') |
| 284 self.writer._AddExample(e1, policy) | 287 self.writer._AddExample(e1, policy) |
| 285 self.assertEquals( | 288 self.assertEquals( |
| 286 e1.toxml(), | 289 e1.toxml(), |
| 287 '<e1>0x00000001 (Windows), true (Linux), <true /> (Mac)</e1>') | 290 '<e1>0x00000001 (Windows),' |
| 291 ' true (Linux), true (Android),' | |
| 292 ' <true /> (Mac)</e1>') | |
| 288 | 293 |
| 289 policy = { | 294 policy = { |
| 290 'name': 'PolicyName', | 295 'name': 'PolicyName', |
| 291 'type': 'main', | 296 'type': 'main', |
| 292 'example_value': False, | 297 'example_value': False, |
| 293 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ] | 298 'supported_on': [ { 'platforms': ['win', 'mac', 'linux', 'android'] } ] |
| 294 } | 299 } |
| 295 e2 = self.writer.AddElement(self.doc_root, 'e2') | 300 e2 = self.writer.AddElement(self.doc_root, 'e2') |
| 296 self.writer._AddExample(e2, policy) | 301 self.writer._AddExample(e2, policy) |
| 297 self.assertEquals( | 302 self.assertEquals( |
| 298 e2.toxml(), | 303 e2.toxml(), |
| 299 '<e2>0x00000000 (Windows), false (Linux), <false /> (Mac)</e2>') | 304 '<e2>0x00000000 (Windows),' |
| 305 ' false (Linux), false (Android),' | |
| 306 ' <false /> (Mac)</e2>') | |
| 300 | 307 |
| 301 def testIntEnumExample(self): | 308 def testIntEnumExample(self): |
| 302 # Test representation of 'int-enum' example values. | 309 # Test representation of 'int-enum' example values. |
| 303 policy = { | 310 policy = { |
| 304 'name': 'PolicyName', | 311 'name': 'PolicyName', |
| 305 'type': 'int-enum', | 312 'type': 'int-enum', |
| 306 'example_value': 16, | 313 'example_value': 16, |
| 307 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ] | 314 'supported_on': [ { 'platforms': ['win', 'mac', 'linux', 'android'] } ] |
| 308 } | 315 } |
| 309 self.writer._AddExample(self.doc_root, policy) | 316 self.writer._AddExample(self.doc_root, policy) |
| 310 self.assertEquals( | 317 self.assertEquals( |
| 311 self.doc_root.toxml(), | 318 self.doc_root.toxml(), |
| 312 '<root>0x00000010 (Windows), 16 (Linux), 16 (Mac)</root>') | 319 '<root>0x00000010 (Windows), 16 (Linux), 16 (Android), 16 (Mac)</root>') |
| 313 | 320 |
| 314 def testStringEnumExample(self): | 321 def testStringEnumExample(self): |
| 315 # Test representation of 'string-enum' example values. | 322 # Test representation of 'string-enum' example values. |
| 316 policy = { | 323 policy = { |
| 317 'name': 'PolicyName', | 324 'name': 'PolicyName', |
| 318 'type': 'string-enum', | 325 'type': 'string-enum', |
| 319 'example_value': "wacky" | 326 'example_value': "wacky" |
| 320 } | 327 } |
| 321 self.writer._AddExample(self.doc_root, policy) | 328 self.writer._AddExample(self.doc_root, policy) |
| 322 self.assertEquals( | 329 self.assertEquals( |
| 323 self.doc_root.toxml(), | 330 self.doc_root.toxml(), |
| 324 '<root>"wacky"</root>') | 331 '<root>"wacky"</root>') |
| 325 | 332 |
| 326 def testListExample(self): | 333 def testListExample(self): |
| 327 # Test representation of 'list' example values. | 334 # Test representation of 'list' example values. |
| 328 policy = { | 335 policy = { |
| 329 'name': 'PolicyName', | 336 'name': 'PolicyName', |
| 330 'type': 'list', | 337 'type': 'list', |
| 331 'example_value': ['one', 'two'], | 338 'example_value': ['one', 'two'], |
| 332 'supported_on': [ { 'platforms': ['linux'] } ] | 339 'supported_on': [ { 'platforms': ['linux'] } ] |
| 333 } | 340 } |
| 334 self.writer._AddExample(self.doc_root, policy) | 341 self.writer._AddExample(self.doc_root, policy) |
| 335 self.assertEquals( | 342 self.assertEquals( |
| 336 self.doc_root.toxml(), | 343 self.doc_root.toxml(), |
| 337 '<root><dl style="style_dd dl;">' | 344 '<root><dl style="style_dd dl;">' |
| 338 '<dt>Linux:</dt>' | 345 '<dt>Android/Linux:</dt>' |
| 339 '<dd style="style_.monospace;">' | 346 '<dd style="style_.monospace;">' |
| 340 '["one", "two"]' | 347 '["one", "two"]' |
| 341 '</dd></dl></root>') | 348 '</dd></dl></root>') |
| 342 | 349 |
| 343 def testStringEnumListExample(self): | 350 def testStringEnumListExample(self): |
| 344 # Test representation of 'string-enum-list' example values. | 351 # Test representation of 'string-enum-list' example values. |
| 345 policy = { | 352 policy = { |
| 346 'name': 'PolicyName', | 353 'name': 'PolicyName', |
| 347 'type': 'string-enum-list', | 354 'type': 'string-enum-list', |
| 348 'example_value': ['one', 'two'], | 355 'example_value': ['one', 'two'], |
| 349 'supported_on': [ { 'platforms': ['linux'] } ] | 356 'supported_on': [ { 'platforms': ['linux'] } ] |
| 350 } | 357 } |
| 351 self.writer._AddExample(self.doc_root, policy) | 358 self.writer._AddExample(self.doc_root, policy) |
| 352 self.assertEquals( | 359 self.assertEquals( |
| 353 self.doc_root.toxml(), | 360 self.doc_root.toxml(), |
| 354 '<root><dl style="style_dd dl;">' | 361 '<root><dl style="style_dd dl;">' |
| 355 '<dt>Linux:</dt>' | 362 '<dt>Android/Linux:</dt>' |
| 356 '<dd style="style_.monospace;">' | 363 '<dd style="style_.monospace;">' |
| 357 '["one", "two"]' | 364 '["one", "two"]' |
| 358 '</dd></dl></root>') | 365 '</dd></dl></root>') |
| 359 | 366 |
| 360 def testStringExample(self): | 367 def testStringExample(self): |
| 361 # Test representation of 'string' example values. | 368 # Test representation of 'string' example values. |
| 362 policy = { | 369 policy = { |
| 363 'name': 'PolicyName', | 370 'name': 'PolicyName', |
| 364 'type': 'string', | 371 'type': 'string', |
| 365 'example_value': 'awesome-example' | 372 'example_value': 'awesome-example' |
| 366 } | 373 } |
| 367 self.writer._AddExample(self.doc_root, policy) | 374 self.writer._AddExample(self.doc_root, policy) |
| 368 self.assertEquals( | 375 self.assertEquals( |
| 369 self.doc_root.toxml(), | 376 self.doc_root.toxml(), |
| 370 '<root>"awesome-example"</root>') | 377 '<root>"awesome-example"</root>') |
| 371 | 378 |
| 372 def testIntExample(self): | 379 def testIntExample(self): |
| 373 # Test representation of 'int' example values. | 380 # Test representation of 'int' example values. |
| 374 policy = { | 381 policy = { |
| 375 'name': 'PolicyName', | 382 'name': 'PolicyName', |
| 376 'type': 'int', | 383 'type': 'int', |
| 377 'example_value': 26, | 384 'example_value': 26, |
| 378 'supported_on': [ { 'platforms': ['win', 'mac', 'linux'] } ] | 385 'supported_on': [ { 'platforms': ['win', 'mac', 'linux', 'android'] } ] |
| 379 } | 386 } |
| 380 self.writer._AddExample(self.doc_root, policy) | 387 self.writer._AddExample(self.doc_root, policy) |
| 381 self.assertEquals( | 388 self.assertEquals( |
| 382 self.doc_root.toxml(), | 389 self.doc_root.toxml(), |
| 383 '<root>0x0000001a (Windows), 26 (Linux), 26 (Mac)</root>') | 390 '<root>0x0000001a (Windows), 26 (Linux), 26 (Android), 26 (Mac)</root>') |
| 384 | 391 |
| 385 def testAddPolicyAttribute(self): | 392 def testAddPolicyAttribute(self): |
| 386 # Test creating a policy attribute term-definition pair. | 393 # Test creating a policy attribute term-definition pair. |
| 387 self.writer._AddPolicyAttribute( | 394 self.writer._AddPolicyAttribute( |
| 388 self.doc_root, 'bla', 'hello, world', ['key1']) | 395 self.doc_root, 'bla', 'hello, world', ['key1']) |
| 389 self.assertEquals( | 396 self.assertEquals( |
| 390 self.doc_root.toxml(), | 397 self.doc_root.toxml(), |
| 391 '<root>' | 398 '<root>' |
| 392 '<dt style="style_dt;">_test_bla</dt>' | 399 '<dt style="style_dt;">_test_bla</dt>' |
| 393 '<dd style="style1;">hello, world</dd>' | 400 '<dd style="style1;">hello, world</dd>' |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 417 'until_version': '', | 424 'until_version': '', |
| 418 }], | 425 }], |
| 419 'features': {'dynamic_refresh': False}, | 426 'features': {'dynamic_refresh': False}, |
| 420 'example_value': False | 427 'example_value': False |
| 421 } | 428 } |
| 422 self.writer.messages['doc_since_version'] = {'text': '...$6...'} | 429 self.writer.messages['doc_since_version'] = {'text': '...$6...'} |
| 423 self.writer._AddPolicyDetails(self.doc_root, policy) | 430 self.writer._AddPolicyDetails(self.doc_root, policy) |
| 424 self.assertEquals( | 431 self.assertEquals( |
| 425 self.doc_root.toxml(), | 432 self.doc_root.toxml(), |
| 426 '<root><dl>' | 433 '<root><dl>' |
| 427 '<dt style="style_dt;">_test_data_type</dt><dd>Boolean (REG_DWORD)</dd>' | 434 '<dt style="style_dt;">_test_data_type</dt>' |
| 435 '<dd>Boolean [Windows:REG_DWORD]</dd>' | |
| 428 '<dt style="style_dt;">_test_win_reg_loc</dt>' | 436 '<dt style="style_dt;">_test_win_reg_loc</dt>' |
| 429 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>' | 437 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>' |
| 430 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' | 438 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' |
| 431 '<dd style="style_.monospace;">TestPolicyName</dd>' | 439 '<dd style="style_.monospace;">TestPolicyName</dd>' |
| 440 '<dt style="style_dt;">_test_android_restriction_name</dt>' | |
| 441 '<dd style="style_.monospace;">TestPolicyName</dd>' | |
| 432 '<dt style="style_dt;">_test_supported_on</dt>' | 442 '<dt style="style_dt;">_test_supported_on</dt>' |
| 433 '<dd>' | 443 '<dd>' |
| 434 '<ul style="style_ul;">' | 444 '<ul style="style_ul;">' |
| 435 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' | 445 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' |
| 436 '<li>Chrome (Android) ...30...</li>' | 446 '<li>Chrome (Android) ...30...</li>' |
| 437 '<li>Chrome (iOS) ...34...</li>' | 447 '<li>Chrome (iOS) ...34...</li>' |
| 438 '</ul>' | 448 '</ul>' |
| 439 '</dd>' | 449 '</dd>' |
| 440 '<dt style="style_dt;">_test_supported_features</dt>' | 450 '<dt style="style_dt;">_test_supported_features</dt>' |
| 441 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' | 451 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' |
| 442 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' | 452 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' |
| 443 '<dt style="style_dt;">_test_example_value</dt>' | 453 '<dt style="style_dt;">_test_example_value</dt>' |
| 444 '<dd>0x00000000 (Windows), false (Linux), <false /> (Mac)</dd>' | 454 '<dd>0x00000000 (Windows), false (Linux),' |
| 455 ' false (Android), <false /> (Mac)</dd>' | |
| 445 '</dl></root>') | 456 '</dl></root>') |
| 446 | 457 |
| 447 def testAddDictPolicyDetails(self): | 458 def testAddDictPolicyDetails(self): |
| 448 # Test if the definition list (<dl>) of policy details is created correctly | 459 # Test if the definition list (<dl>) of policy details is created correctly |
| 449 # for 'dict' policies. | 460 # for 'dict' policies. |
| 450 policy = { | 461 policy = { |
| 451 'type': 'dict', | 462 'type': 'dict', |
| 452 'name': 'TestPolicyName', | 463 'name': 'TestPolicyName', |
| 453 'caption': 'TestPolicyCaption', | 464 'caption': 'TestPolicyCaption', |
| 454 'desc': 'TestPolicyDesc', | 465 'desc': 'TestPolicyDesc', |
| 455 'supported_on': [{ | 466 'supported_on': [{ |
| 456 'product': 'chrome', | 467 'product': 'chrome', |
| 457 'platforms': ['win', 'mac', 'linux'], | 468 'platforms': ['win', 'mac', 'linux'], |
| 458 'since_version': '8', | 469 'since_version': '8', |
| 459 'until_version': '', | 470 'until_version': '', |
| 460 }], | 471 }], |
| 461 'features': {'dynamic_refresh': False}, | 472 'features': {'dynamic_refresh': False}, |
| 462 'example_value': { 'foo': 123 } | 473 'example_value': { 'foo': 123 } |
| 463 } | 474 } |
| 464 self.writer.messages['doc_since_version'] = {'text': '...$6...'} | 475 self.writer.messages['doc_since_version'] = {'text': '...$6...'} |
| 465 self.writer._AddPolicyDetails(self.doc_root, policy) | 476 self.writer._AddPolicyDetails(self.doc_root, policy) |
| 466 self.assertEquals( | 477 self.assertEquals( |
| 467 self.doc_root.toxml(), | 478 self.doc_root.toxml(), |
| 468 '<root><dl>' | 479 '<root><dl>' |
| 469 '<dt style="style_dt;">_test_data_type</dt><dd>Dictionary (REG_SZ; _test_c omplex_policies_win)</dd>' | 480 '<dt style="style_dt;">_test_data_type</dt>' |
| 481 '<dd>Dictionary [Windows:REG_SZ] (_test_complex_policies_win)</dd>' | |
| 470 '<dt style="style_dt;">_test_win_reg_loc</dt>' | 482 '<dt style="style_dt;">_test_win_reg_loc</dt>' |
| 471 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>' | 483 '<dd style="style_.monospace;">MockKey\TestPolicyName</dd>' |
| 472 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' | 484 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' |
| 473 '<dd style="style_.monospace;">TestPolicyName</dd>' | 485 '<dd style="style_.monospace;">TestPolicyName</dd>' |
| 474 '<dt style="style_dt;">_test_supported_on</dt>' | 486 '<dt style="style_dt;">_test_supported_on</dt>' |
| 475 '<dd>' | 487 '<dd>' |
| 476 '<ul style="style_ul;">' | 488 '<ul style="style_ul;">' |
| 477 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' | 489 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' |
| 478 '</ul>' | 490 '</ul>' |
| 479 '</dd>' | 491 '</dd>' |
| 480 '<dt style="style_dt;">_test_supported_features</dt>' | 492 '<dt style="style_dt;">_test_supported_features</dt>' |
| 481 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' | 493 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' |
| 482 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' | 494 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' |
| 483 '<dt style="style_dt;">_test_example_value</dt>' | 495 '<dt style="style_dt;">_test_example_value</dt>' |
| 484 '<dd>' | 496 '<dd>' |
| 485 '<dl style="style_dd dl;">' | 497 '<dl style="style_dd dl;">' |
| 486 '<dt>Windows:</dt>' | 498 '<dt>Windows:</dt>' |
| 487 '<dd style="style_.monospace;style_.pre;">MockKey\TestPolicyName = { "foo": 123}</dd>' | 499 '<dd style="style_.monospace;style_.pre;">MockKey\TestPolicyName = { "foo": 123}</dd>' |
| 488 '<dt>Linux:</dt>' | 500 '<dt>Android/Linux:</dt>' |
| 489 '<dd style="style_.monospace;">TestPolicyName: {"foo": 123 }</dd>' | 501 '<dd style="style_.monospace;">TestPolicyName: {"foo": 123 }</dd>' |
| 490 '<dt>Mac:</dt>' | 502 '<dt>Mac:</dt>' |
| 491 '<dd style="style_.monospace;style_.pre;">' | 503 '<dd style="style_.monospace;style_.pre;">' |
| 492 '<key>TestPolicyName</key>\n' | 504 '<key>TestPolicyName</key>\n' |
| 493 '<dict>\n' | 505 '<dict>\n' |
| 494 ' <key>foo</key>\n' | 506 ' <key>foo</key>\n' |
| 495 ' <integer>123</integer>\n' | 507 ' <integer>123</integer>\n' |
| 496 '</dict>' | 508 '</dict>' |
| 497 '</dd>' | 509 '</dd>' |
| 498 '</dl>' | 510 '</dl>' |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 526 'can_be_mandatory': False, | 538 'can_be_mandatory': False, |
| 527 'can_be_recommended': True | 539 'can_be_recommended': True |
| 528 }, | 540 }, |
| 529 'example_value': False | 541 'example_value': False |
| 530 } | 542 } |
| 531 self.writer.messages['doc_since_version'] = {'text': '...$6...'} | 543 self.writer.messages['doc_since_version'] = {'text': '...$6...'} |
| 532 self.writer._AddPolicyDetails(self.doc_root, policy) | 544 self.writer._AddPolicyDetails(self.doc_root, policy) |
| 533 self.assertEquals( | 545 self.assertEquals( |
| 534 self.doc_root.toxml(), | 546 self.doc_root.toxml(), |
| 535 '<root><dl>' | 547 '<root><dl>' |
| 536 '<dt style="style_dt;">_test_data_type</dt><dd>Boolean (REG_DWORD)</dd>' | 548 '<dt style="style_dt;">_test_data_type</dt>' |
| 549 '<dd>Boolean [Windows:REG_DWORD]</dd>' | |
| 537 '<dt style="style_dt;">_test_win_reg_loc</dt>' | 550 '<dt style="style_dt;">_test_win_reg_loc</dt>' |
| 538 '<dd style="style_.monospace;">MockKeyRec\TestPolicyName</dd>' | 551 '<dd style="style_.monospace;">MockKeyRec\TestPolicyName</dd>' |
| 539 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' | 552 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' |
| 540 '<dd style="style_.monospace;">TestPolicyName</dd>' | 553 '<dd style="style_.monospace;">TestPolicyName</dd>' |
| 554 '<dt style="style_dt;">_test_android_restriction_name</dt>' | |
| 555 '<dd style="style_.monospace;">TestPolicyName</dd>' | |
| 541 '<dt style="style_dt;">_test_supported_on</dt>' | 556 '<dt style="style_dt;">_test_supported_on</dt>' |
| 542 '<dd>' | 557 '<dd>' |
| 543 '<ul style="style_ul;">' | 558 '<ul style="style_ul;">' |
| 544 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' | 559 '<li>Chrome (Windows, Mac, Linux) ...8...</li>' |
| 545 '<li>Chrome (Android) ...30...</li>' | 560 '<li>Chrome (Android) ...30...</li>' |
| 546 '<li>Chrome (iOS) ...34...</li>' | 561 '<li>Chrome (iOS) ...34...</li>' |
| 547 '</ul>' | 562 '</ul>' |
| 548 '</dd>' | 563 '</dd>' |
| 549 '<dt style="style_dt;">_test_supported_features</dt>' | 564 '<dt style="style_dt;">_test_supported_features</dt>' |
| 550 '<dd>_test_feature_mandatory: _test_not_supported,' | 565 '<dd>_test_feature_mandatory: _test_not_supported,' |
| 551 ' _test_feature_recommended: _test_supported,' | 566 ' _test_feature_recommended: _test_supported,' |
| 552 ' _test_feature_dynamic_refresh: _test_not_supported</dd>' | 567 ' _test_feature_dynamic_refresh: _test_not_supported</dd>' |
| 553 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' | 568 '<dt style="style_dt;">_test_description</dt><dd>TestPolicyDesc</dd>' |
| 554 '<dt style="style_dt;">_test_example_value</dt>' | 569 '<dt style="style_dt;">_test_example_value</dt>' |
| 555 '<dd>0x00000000 (Windows), false (Linux), <false /> (Mac)</dd>' | 570 '<dd>0x00000000 (Windows), false (Linux),' |
| 571 ' false (Android), <false /> (Mac)</dd>' | |
| 556 '</dl></root>') | 572 '</dl></root>') |
| 557 | 573 |
| 558 def testAddPolicyNote(self): | 574 def testAddPolicyNote(self): |
| 559 # TODO(jkummerow): The functionality tested by this test is currently not | 575 # TODO(jkummerow): The functionality tested by this test is currently not |
| 560 # used for anything and will probably soon be removed. | 576 # used for anything and will probably soon be removed. |
| 561 # Test if nodes are correctly added to policies. | 577 # Test if nodes are correctly added to policies. |
| 562 policy = { | 578 policy = { |
| 563 'problem_href': 'http://www.example.com/5' | 579 'problem_href': 'http://www.example.com/5' |
| 564 } | 580 } |
| 565 self.writer.messages['doc_note'] = {'text': '...$6...'} | 581 self.writer.messages['doc_note'] = {'text': '...$6...'} |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 622 self.writer.messages['doc_since_version'] = {'text': '..$6..'} | 638 self.writer.messages['doc_since_version'] = {'text': '..$6..'} |
| 623 self.writer._AddPolicySection(self.doc_root, policy) | 639 self.writer._AddPolicySection(self.doc_root, policy) |
| 624 self.assertEquals( | 640 self.assertEquals( |
| 625 self.doc_root.toxml(), | 641 self.doc_root.toxml(), |
| 626 '<root>' | 642 '<root>' |
| 627 '<div style="margin-left: 0px">' | 643 '<div style="margin-left: 0px">' |
| 628 '<h3><a name="PolicyName"/>PolicyName</h3>' | 644 '<h3><a name="PolicyName"/>PolicyName</h3>' |
| 629 '<span>PolicyCaption</span>' | 645 '<span>PolicyCaption</span>' |
| 630 '<dl>' | 646 '<dl>' |
| 631 '<dt style="style_dt;">_test_data_type</dt>' | 647 '<dt style="style_dt;">_test_data_type</dt>' |
| 632 '<dd>String (REG_SZ)</dd>' | 648 '<dd>String [Windows:REG_SZ]</dd>' |
| 633 '<dt style="style_dt;">_test_win_reg_loc</dt>' | 649 '<dt style="style_dt;">_test_win_reg_loc</dt>' |
| 634 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>' | 650 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>' |
| 635 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' | 651 '<dt style="style_dt;">_test_mac_linux_pref_name</dt>' |
| 636 '<dd style="style_.monospace;">PolicyName</dd>' | 652 '<dd style="style_.monospace;">PolicyName</dd>' |
| 637 '<dt style="style_dt;">_test_supported_on</dt>' | 653 '<dt style="style_dt;">_test_supported_on</dt>' |
| 638 '<dd>' | 654 '<dd>' |
| 639 '<ul style="style_ul;">' | 655 '<ul style="style_ul;">' |
| 640 '<li>Chrome (Windows, Mac) ..7..</li>' | 656 '<li>Chrome (Windows, Mac) ..7..</li>' |
| 641 '</ul>' | 657 '</ul>' |
| 642 '</dd>' | 658 '</dd>' |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 682 self.writer.messages['doc_since_version'] = {'text': '..$6..'} | 698 self.writer.messages['doc_since_version'] = {'text': '..$6..'} |
| 683 self.writer._AddPolicySection(self.doc_root, policy) | 699 self.writer._AddPolicySection(self.doc_root, policy) |
| 684 self.assertEquals( | 700 self.assertEquals( |
| 685 self.doc_root.toxml(), | 701 self.doc_root.toxml(), |
| 686 '<root>' | 702 '<root>' |
| 687 '<div style="margin-left: 0px">' | 703 '<div style="margin-left: 0px">' |
| 688 '<h3><a name="PolicyName"/>PolicyName</h3>' | 704 '<h3><a name="PolicyName"/>PolicyName</h3>' |
| 689 '<span>PolicyCaption</span>' | 705 '<span>PolicyCaption</span>' |
| 690 '<dl>' | 706 '<dl>' |
| 691 '<dt style="style_dt;">_test_data_type</dt>' | 707 '<dt style="style_dt;">_test_data_type</dt>' |
| 692 '<dd>Integer (REG_DWORD)</dd>' | 708 '<dd>Integer [Windows:REG_DWORD]</dd>' |
| 693 '<dt style="style_dt;">_test_win_reg_loc</dt>' | 709 '<dt style="style_dt;">_test_win_reg_loc</dt>' |
| 694 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>' | 710 '<dd style="style_.monospace;">MockKey\\PolicyName</dd>' |
| 695 '<dt style="style_dt;">_test_supported_on</dt>' | 711 '<dt style="style_dt;">_test_supported_on</dt>' |
| 696 '<dd>' | 712 '<dd>' |
| 697 '<ul style="style_ul;">' | 713 '<ul style="style_ul;">' |
| 698 '<li>Chrome (Windows) ..33..</li>' | 714 '<li>Chrome (Windows) ..33..</li>' |
| 699 '</ul>' | 715 '</ul>' |
| 700 '</dd>' | 716 '</dd>' |
| 701 '<dt style="style_dt;">_test_supported_features</dt>' | 717 '<dt style="style_dt;">_test_supported_features</dt>' |
| 702 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' | 718 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' | 808 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' |
| 793 '<dt style="style_dt;">_test_description</dt>' | 809 '<dt style="style_dt;">_test_description</dt>' |
| 794 '<dd>PolicyDesc</dd>' | 810 '<dd>PolicyDesc</dd>' |
| 795 '<dt style="style_dt;">_test_example_value</dt>' | 811 '<dt style="style_dt;">_test_example_value</dt>' |
| 796 '<dd>123 (Linux)</dd>' | 812 '<dd>123 (Linux)</dd>' |
| 797 '</dl>' | 813 '</dl>' |
| 798 '<a href="#top">_test_back_to_top</a>' | 814 '<a href="#top">_test_back_to_top</a>' |
| 799 '</div>' | 815 '</div>' |
| 800 '</root>') | 816 '</root>') |
| 801 | 817 |
| 818 def testAddPolicySectionForAndroidOnly(self): | |
| 819 policy = { | |
| 820 'name': 'PolicyName', | |
| 821 'caption': 'PolicyCaption', | |
| 822 'desc': 'PolicyDesc', | |
| 823 'type': 'int', | |
| 824 'supported_on': [{ | |
| 825 'product': 'chrome', | |
| 826 'platforms': ['android'], | |
| 827 'since_version': '33', | |
| 828 'until_version': '', | |
| 829 }], | |
| 830 'features': {'dynamic_refresh': False}, | |
| 831 'example_value': 123 | |
| 832 } | |
| 833 self.writer.messages['doc_since_version'] = {'text': '..$6..'} | |
| 834 self.writer._AddPolicySection(self.doc_root, policy) | |
| 835 self.assertTrue(self.writer.IsPolicySupportedOnPlatform(policy, 'android')) | |
| 836 self.assertEquals( | |
| 837 self.doc_root.toxml(), | |
| 838 '<root>' | |
| 839 '<div style="margin-left: 0px">' | |
| 840 '<h3><a name="PolicyName"/>PolicyName</h3>' | |
| 841 '<span>PolicyCaption</span>' | |
| 842 '<dl>' | |
| 843 '<dt style="style_dt;">_test_data_type</dt>' | |
| 844 '<dd>Integer</dd>' | |
| 845 '<dt style="style_dt;">_test_android_restriction_name</dt>' | |
| 846 '<dd style="style_.monospace;">PolicyName</dd>' | |
| 847 '<dt style="style_dt;">_test_supported_on</dt>' | |
| 848 '<dd>' | |
| 849 '<ul style="style_ul;">' | |
| 850 '<li>Chrome (Android) ..33..</li>' | |
| 851 '</ul>' | |
| 852 '</dd>' | |
| 853 '<dt style="style_dt;">_test_supported_features</dt>' | |
| 854 '<dd>_test_feature_dynamic_refresh: _test_not_supported</dd>' | |
| 855 '<dt style="style_dt;">_test_description</dt>' | |
| 856 '<dd>PolicyDesc</dd>' | |
|
Nico
2015/03/04 19:15:23
Changing this line to
'<dd><p>PolicyD
knn
2015/03/04 19:45:09
None of tests have <p> around PolicyDesc right?
Nico
2015/03/04 19:56:07
all of the other PolicyDescs in <dl>s in the test
| |
| 857 '<dt style="style_dt;">_test_example_value</dt>' | |
| 858 '<dd>123 (Android)</dd>' | |
| 859 '</dl>' | |
| 860 '<a href="#top">_test_back_to_top</a>' | |
| 861 '</div>' | |
| 862 '</root>') | |
| 863 | |
| 802 def testAddDictionaryExample(self): | 864 def testAddDictionaryExample(self): |
| 803 policy = { | 865 policy = { |
| 804 'name': 'PolicyName', | 866 'name': 'PolicyName', |
| 805 'caption': 'PolicyCaption', | 867 'caption': 'PolicyCaption', |
| 806 'desc': 'PolicyDesc', | 868 'desc': 'PolicyDesc', |
| 807 'type': 'dict', | 869 'type': 'dict', |
| 808 'supported_on': [{ | 870 'supported_on': [{ |
| 809 'product': 'chrome', | 871 'product': 'chrome', |
| 810 'platforms': ['win', 'mac', 'linux'], | 872 'platforms': ['win', 'mac', 'linux'], |
| 811 'since_version': '7', | 873 'since_version': '7', |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 831 self.writer._AddDictionaryExample(self.doc_root, policy) | 893 self.writer._AddDictionaryExample(self.doc_root, policy) |
| 832 value = json.dumps(policy['example_value']).replace('"', '"') | 894 value = json.dumps(policy['example_value']).replace('"', '"') |
| 833 self.assertEquals( | 895 self.assertEquals( |
| 834 self.doc_root.toxml(), | 896 self.doc_root.toxml(), |
| 835 '<root>' | 897 '<root>' |
| 836 '<dl style="style_dd dl;">' | 898 '<dl style="style_dd dl;">' |
| 837 '<dt>Windows:</dt>' | 899 '<dt>Windows:</dt>' |
| 838 '<dd style="style_.monospace;style_.pre;">MockKey\PolicyName = ' | 900 '<dd style="style_.monospace;style_.pre;">MockKey\PolicyName = ' |
| 839 + value + | 901 + value + |
| 840 '</dd>' | 902 '</dd>' |
| 841 '<dt>Linux:</dt>' | 903 '<dt>Android/Linux:</dt>' |
| 842 '<dd style="style_.monospace;">PolicyName: ' + value + '</dd>' | 904 '<dd style="style_.monospace;">PolicyName: ' + value + '</dd>' |
| 843 '<dt>Mac:</dt>' | 905 '<dt>Mac:</dt>' |
| 844 '<dd style="style_.monospace;style_.pre;">' | 906 '<dd style="style_.monospace;style_.pre;">' |
| 845 '<key>PolicyName</key>\n' | 907 '<key>PolicyName</key>\n' |
| 846 '<dict>\n' | 908 '<dict>\n' |
| 847 ' <key>DictList</key>\n' | 909 ' <key>DictList</key>\n' |
| 848 ' <array>\n' | 910 ' <array>\n' |
| 849 ' <dict>\n' | 911 ' <dict>\n' |
| 850 ' <key>A</key>\n' | 912 ' <key>A</key>\n' |
| 851 ' <integer>1</integer>\n' | 913 ' <integer>1</integer>\n' |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 874 ' <key>True</key>\n' | 936 ' <key>True</key>\n' |
| 875 ' <true/>\n' | 937 ' <true/>\n' |
| 876 '</dict>' | 938 '</dict>' |
| 877 '</dd>' | 939 '</dd>' |
| 878 '</dl>' | 940 '</dl>' |
| 879 '</root>') | 941 '</root>') |
| 880 | 942 |
| 881 | 943 |
| 882 if __name__ == '__main__': | 944 if __name__ == '__main__': |
| 883 unittest.main() | 945 unittest.main() |
| OLD | NEW |