| OLD | NEW |
| 1 # Copyright (C) 2010, 2012 Google Inc. All rights reserved. | 1 # Copyright (C) 2010, 2012 Google Inc. All rights reserved. |
| 2 # | 2 # |
| 3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
| 4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
| 5 # met: | 5 # met: |
| 6 # | 6 # |
| 7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
| 8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
| 9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
| 10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 def get_options(args): | 47 def get_options(args): |
| 48 print_options = printing.print_options() | 48 print_options = printing.print_options() |
| 49 option_parser = optparse.OptionParser(option_list=print_options) | 49 option_parser = optparse.OptionParser(option_list=print_options) |
| 50 return option_parser.parse_args(args) | 50 return option_parser.parse_args(args) |
| 51 | 51 |
| 52 | 52 |
| 53 class TestUtilityFunctions(unittest.TestCase): | 53 class TestUtilityFunctions(unittest.TestCase): |
| 54 | 54 |
| 55 def test_print_options(self): | 55 def test_print_options(self): |
| 56 options, args = get_options([]) | 56 options, _ = get_options([]) |
| 57 self.assertIsNotNone(options) | 57 self.assertIsNotNone(options) |
| 58 | 58 |
| 59 | 59 |
| 60 class FakeRunResults(object): | 60 class FakeRunResults(object): |
| 61 | 61 |
| 62 def __init__(self, total=1, expected=1, unexpected=0, fake_results=None): | 62 def __init__(self, total=1, expected=1, unexpected=0, fake_results=None): |
| 63 fake_results = fake_results or [] | 63 fake_results = fake_results or [] |
| 64 self.total = total | 64 self.total = total |
| 65 self.expected = expected | 65 self.expected = expected |
| 66 self.expected_failures = 0 | 66 self.expected_failures = 0 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 96 stream.buflist = [] | 96 stream.buflist = [] |
| 97 stream.buf = '' | 97 stream.buf = '' |
| 98 | 98 |
| 99 def get_printer(self, args=None): | 99 def get_printer(self, args=None): |
| 100 args = args or [] | 100 args = args or [] |
| 101 printing_options = printing.print_options() | 101 printing_options = printing.print_options() |
| 102 option_parser = optparse.OptionParser(option_list=printing_options) | 102 option_parser = optparse.OptionParser(option_list=printing_options) |
| 103 options, args = option_parser.parse_args(args) | 103 options, args = option_parser.parse_args(args) |
| 104 host = MockHost() | 104 host = MockHost() |
| 105 self._port = host.port_factory.get('test', options) | 105 self._port = host.port_factory.get('test', options) |
| 106 nproc = 2 | |
| 107 | 106 |
| 108 regular_output = StringIO.StringIO() | 107 regular_output = StringIO.StringIO() |
| 109 printer = printing.Printer(self._port, options, regular_output) | 108 printer = printing.Printer(self._port, options, regular_output) |
| 110 return printer, regular_output | 109 return printer, regular_output |
| 111 | 110 |
| 112 def get_result(self, test_name, result_type=test_expectations.PASS, run_time
=0): | 111 def get_result(self, test_name, result_type=test_expectations.PASS, run_time
=0): |
| 113 failures = [] | 112 failures = [] |
| 114 if result_type == test_expectations.TIMEOUT: | 113 if result_type == test_expectations.TIMEOUT: |
| 115 failures = [test_failures.FailureTimeout()] | 114 failures = [test_failures.FailureTimeout()] |
| 116 elif result_type == test_expectations.CRASH: | 115 elif result_type == test_expectations.CRASH: |
| 117 failures = [test_failures.FailureCrash()] | 116 failures = [test_failures.FailureCrash()] |
| 118 return test_results.TestResult(test_name, failures=failures, test_run_ti
me=run_time) | 117 return test_results.TestResult(test_name, failures=failures, test_run_ti
me=run_time) |
| 119 | 118 |
| 120 def test_configure_and_cleanup(self): | 119 def test_configure_and_cleanup(self): |
| 121 # This test verifies that calling cleanup repeatedly and deleting | 120 # This test verifies that calling cleanup repeatedly and deleting |
| 122 # the object is safe. | 121 # the object is safe. |
| 123 printer, err = self.get_printer() | 122 printer, _ = self.get_printer() |
| 124 printer.cleanup() | 123 printer.cleanup() |
| 125 printer.cleanup() | 124 printer.cleanup() |
| 126 printer = None | 125 printer = None |
| 127 | 126 |
| 128 def test_print_config(self): | 127 def test_print_config(self): |
| 129 printer, err = self.get_printer() | 128 printer, err = self.get_printer() |
| 130 # FIXME: it's lame that i have to set these options directly. | 129 # FIXME: it's lame that i have to set these options directly. |
| 131 printer._options.pixel_tests = True | 130 printer._options.pixel_tests = True |
| 132 printer._options.new_baseline = True | 131 printer._options.new_baseline = True |
| 133 printer._options.time_out_ms = 6000 | 132 printer._options.time_out_ms = 6000 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 printer.print_finished_test(result, expected=True, exp_str='', got_str='
') | 250 printer.print_finished_test(result, expected=True, exp_str='', got_str='
') |
| 252 | 251 |
| 253 printer.print_started_test('passes/text.html') | 252 printer.print_started_test('passes/text.html') |
| 254 result = self.get_result('passes/text.html') | 253 result = self.get_result('passes/text.html') |
| 255 printer.print_finished_test(result, expected=True, exp_str='', got_str='
') | 254 printer.print_finished_test(result, expected=True, exp_str='', got_str='
') |
| 256 | 255 |
| 257 # Only the first test's start should be printed. | 256 # Only the first test's start should be printed. |
| 258 lines = err.buflist | 257 lines = err.buflist |
| 259 self.assertEqual(len(lines), 1) | 258 self.assertEqual(len(lines), 1) |
| 260 self.assertTrue(lines[0].endswith('passes/image.html\n')) | 259 self.assertTrue(lines[0].endswith('passes/image.html\n')) |
| OLD | NEW |