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