OLD | NEW |
1 # -*- coding: utf-8 -*- | 1 # -*- coding: utf-8 -*- |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """Automated tests for many websites""" | 6 """Automated tests for many websites""" |
7 | 7 |
8 import argparse | 8 import argparse |
9 import logging | 9 import logging |
10 | 10 |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 environment.AddWebsiteTest(One63("163"), disabled=True) | 400 environment.AddWebsiteTest(One63("163"), disabled=True) |
401 | 401 |
402 # http://crbug.com/368690 | 402 # http://crbug.com/368690 |
403 environment.AddWebsiteTest(Vube("vube"), disabled=True) | 403 environment.AddWebsiteTest(Vube("vube"), disabled=True) |
404 | 404 |
405 # Tests that can cause a crash (the cause of the crash is not related to the | 405 # Tests that can cause a crash (the cause of the crash is not related to the |
406 # password manager). | 406 # password manager). |
407 environment.AddWebsiteTest(Yahoo("yahoo", username_not_auto=True), | 407 environment.AddWebsiteTest(Yahoo("yahoo", username_not_auto=True), |
408 disabled=True) | 408 disabled=True) |
409 | 409 |
| 410 def resultsToXml(environment_tests_results): |
| 411 """Convert the test results to an xml string. |
| 412 |
| 413 Args: |
| 414 environment_tests_results: A list of the TestResults that are going to be |
| 415 converted. |
| 416 Returns: |
| 417 A string containing the result of the tests in the xml format. |
| 418 """ |
| 419 xml = "<result>" |
| 420 for test_result in environment_tests_results: |
| 421 xml += ("<test name='%s' successful='%s' type='%s'>%s</test>" |
| 422 % (test_result.name, str(test_result.successful), |
| 423 test_result.test_type, test_result.message)) |
| 424 xml += "</result>" |
| 425 return xml |
| 426 |
410 def saveResults(environment_tests_results, environment_save_path): | 427 def saveResults(environment_tests_results, environment_save_path): |
411 """Save the test results in an xml file. | 428 """Save the test results in an xml file. |
412 | 429 |
413 Args: | 430 Args: |
414 environment_tests_results: A list of the TestResults that are going to be | 431 environment_tests_results: A list of the TestResults that are going to be |
415 saved. | 432 saved. |
416 environment_save_path: The file where the results are going to be saved. | 433 environment_save_path: The file where the results are going to be saved. |
417 If it's None, the results are not going to be stored. | 434 If it's None, the results are not going to be stored. |
418 Raises: | 435 Raises: |
419 Exception: An exception is raised if the file is not found. | 436 Exception: An exception is raised if the file is not found. |
420 """ | 437 """ |
421 if environment_save_path: | 438 if environment_save_path: |
422 xml = "<result>" | |
423 for test_result in environment_tests_results: | |
424 xml += ("<test name='%s' successful='%s' type='%s'>%s</test>" | |
425 % (test_result.name, str(test_result.successful), | |
426 test_result.test_type, test_result.message)) | |
427 xml += "</result>" | |
428 with open(environment_save_path, "w") as save_file: | 439 with open(environment_save_path, "w") as save_file: |
429 save_file.write(xml) | 440 save_file.write(resultsToXml(environment_tests_results)) |
430 | 441 |
431 def RunTests(chrome_path, chromedriver_path, profile_path, | 442 def RunTests(chrome_path, chromedriver_path, profile_path, |
432 environment_passwords_path, enable_automatic_password_saving, | 443 environment_passwords_path, enable_automatic_password_saving, |
433 environment_numeric_level, log_to_console, environment_log_file, | 444 environment_numeric_level, log_to_console, environment_log_file, |
434 environment_tested_websites, tests=None): | 445 environment_tested_websites, tests=None): |
435 | 446 |
436 """Runs the the tests | 447 """Runs the the tests |
437 | 448 |
438 Args: | 449 Args: |
439 chrome_path: The chrome binary file. | 450 chrome_path: The chrome binary file. |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 args.profile_path[0], | 580 args.profile_path[0], |
570 passwords_path, | 581 passwords_path, |
571 True, | 582 True, |
572 numeric_level, | 583 numeric_level, |
573 args.log_screen, | 584 args.log_screen, |
574 log_file, | 585 log_file, |
575 tested_websites, | 586 tested_websites, |
576 args.tests) | 587 args.tests) |
577 | 588 |
578 saveResults(tests_results, save_path) | 589 saveResults(tests_results, save_path) |
OLD | NEW |