Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright (C) 2014 Google Inc. All rights reserved. | |
| 2 # | |
| 3 # Redistribution and use in source and binary forms, with or without | |
| 4 # modification, are permitted provided that the following conditions are | |
| 5 # met: | |
| 6 # | |
| 7 # * Redistributions of source code must retain the above copyright | |
| 8 # notice, this list of conditions and the following disclaimer. | |
| 9 # * Redistributions in binary form must reproduce the above | |
| 10 # copyright notice, this list of conditions and the following disclaimer | |
| 11 # in the documentation and/or other materials provided with the | |
| 12 # distribution. | |
| 13 # * Neither the Google name nor the names of its | |
| 14 # contributors may be used to endorse or promote products derived from | |
| 15 # this software without specific prior written permission. | |
| 16 # | |
| 17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| 18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| 19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| 20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| 21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| 22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| 23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
| 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
| 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
| 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
| 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
| 28 | |
| 29 from webkitpy.layout_tests.port import driver | |
| 30 import time | |
| 31 import shutil | |
| 32 | |
| 33 | |
| 34 class BrowserTestDriver(driver.Driver): | |
| 35 """Object for running print preview test(s) using browser_tests.""" | |
| 36 def __init__(self, port, worker_number, pixel_tests, no_timeout=False): | |
| 37 """Invokes the constructor of driver.Driver.""" | |
| 38 super(BrowserTestDriver, self).__init__(port, worker_number, pixel_tests , no_timeout) | |
| 39 self.stdin_directory = None | |
| 40 | |
| 41 def start(self, pixel_tests, per_test_args, deadline): | |
| 42 """Same as Driver.start() however, it has an extra step. It waits for | |
| 43 a path to a file to be used for stdin to be printed by the browser test. | |
| 44 If a path is found by the deadline test test will open the file and | |
| 45 assign it to the stdin of the process that is owned by this driver's | |
| 46 server process. | |
| 47 """ | |
| 48 # FIXME(ivandavid): Need to handle case where the layout test doesn't | |
| 49 # get a file name. | |
| 50 new_cmd_line = self.cmd_line(pixel_tests, per_test_args) | |
| 51 if not self._server_process or new_cmd_line != self._current_cmd_line: | |
| 52 self._start(pixel_tests, per_test_args) | |
| 53 self._run_post_start_tasks() | |
| 54 path, found = self._read_stdin_path(time.time() + int(deadline) / 10 00.0) | |
| 55 if found: | |
| 56 self._server_process._proc.stdin = open(path, 'wb', 0) | |
| 57 # Gets the path of the directory that the file for stdin | |
| 58 # communication is in. Since the browser test cannot clean it | |
| 59 # up, the layout test framework will. Everything the browser tes t | |
| 60 # uses is stored in the same directory as the stdin file, so | |
| 61 # deleting that directory recursively will remove all the other | |
| 62 # temp data, like the printed pdf. | |
| 63 # Assumes that the correct file is sent, however if the path | |
| 64 # only contains one component, like '/foo' the the directory | |
| 65 # won't be deleted as it might be wrong. | |
| 66 path_split = path.split(self._port.TEST_PATH_SEPARATOR) | |
| 67 if len(path_split) > 1: | |
| 68 del path_split[-1] | |
| 69 self.stdin_directory = self._port.TEST_PATH_SEPARATOR.join(p ath_split) | |
| 70 | |
| 71 def cmd_line(self, pixel_tests, per_test_args): | |
| 72 """Command line arguments to run the browser test.""" | |
| 73 cmd = self._command_wrapper(self._port.get_option('wrapper')) | |
| 74 cmd.append(self._port._path_to_driver()) | |
| 75 cmd.append('--gtest_filter=PrintPreviewPdfGeneratedBrowserTest.MANUAL_Du mmyTest') | |
| 76 cmd.append('--run-manual') | |
| 77 cmd.append('--single_process') | |
| 78 cmd.extend(per_test_args) | |
| 79 return cmd | |
| 80 | |
| 81 def __del__(self): | |
| 82 if self.stdin_directory != None: | |
| 83 shutil.rmtree(self.stdin_directory) | |
|
Dirk Pranke
2014/07/16 23:37:20
You probably want ignore_errors=True here, or othe
ivandavid
2014/07/16 23:53:52
Done.
| |
| OLD | NEW |