OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/file_path.h" | 5 #include "base/file_path.h" |
6 #include "base/scoped_temp_dir.h" | 6 #include "base/scoped_temp_dir.h" |
7 #include "chrome/test/base/in_process_browser_test.h" | 7 #include "chrome/test/base/in_process_browser_test.h" |
8 | 8 |
| 9 class LayoutTestHttpServer; |
| 10 |
9 class InProcessBrowserLayoutTest : public InProcessBrowserTest { | 11 class InProcessBrowserLayoutTest : public InProcessBrowserTest { |
10 public: | 12 public: |
11 explicit InProcessBrowserLayoutTest(const FilePath relative_layout_test_path); | 13 explicit InProcessBrowserLayoutTest(const FilePath& test_parent_dir, |
| 14 const FilePath& test_case_dir); |
| 15 // Used when running HTTP layout tests. Starts the server in the constructor |
| 16 // and keeps it running through the lifetime of this test. This is done to |
| 17 // avoid flakiness in restarting the server while the port is still in use. |
| 18 // If -1 is passed for |port|, a random number will be used. This is |
| 19 // recommended when possible, in case multiple tests are running at the same |
| 20 // time. For some tests this isn't possible though, because they use resources |
| 21 // that hardcode a specific port. |
| 22 InProcessBrowserLayoutTest(const FilePath& test_parent_dir, |
| 23 const FilePath& test_case_dir, |
| 24 int port); |
12 virtual ~InProcessBrowserLayoutTest(); | 25 virtual ~InProcessBrowserLayoutTest(); |
13 | 26 |
14 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | 27 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
| 28 // Runs a layout test given its filename relative to the path given to the |
| 29 // constructor. |
15 void RunLayoutTest(const std::string& test_case_file_name); | 30 void RunLayoutTest(const std::string& test_case_file_name); |
| 31 // Runs a layout test using the HTTP test server. The second constructor must |
| 32 // have been used. |
| 33 void RunHttpLayoutTest(const std::string& test_case_file_name); |
16 void AddResourceForLayoutTest(const FilePath& parent_dir, | 34 void AddResourceForLayoutTest(const FilePath& parent_dir, |
17 const FilePath& resource_name); | 35 const FilePath& resource_name); |
18 | 36 |
19 private: | 37 private: |
| 38 void RunLayoutTestInternal(const std::string& test_case_file_name, |
| 39 const GURL& url); |
20 void WriteModifiedFile(const std::string& test_case_file_name, | 40 void WriteModifiedFile(const std::string& test_case_file_name, |
21 GURL* test_url); | 41 FilePath* test_path); |
22 | 42 |
23 FilePath our_original_layout_test_dir_; | 43 FilePath our_original_layout_test_dir_; |
24 FilePath original_relative_path_; | 44 FilePath test_parent_dir_; |
| 45 FilePath test_case_dir_; |
25 FilePath our_layout_test_temp_dir_; | 46 FilePath our_layout_test_temp_dir_; |
| 47 FilePath rebase_result_dir_; |
| 48 FilePath rebase_result_chromium_dir_; |
| 49 FilePath rebase_result_win_dir_; |
26 ScopedTempDir scoped_temp_dir_; | 50 ScopedTempDir scoped_temp_dir_; |
| 51 int port_; // -2 means no port. -1 means random. |
| 52 scoped_ptr<LayoutTestHttpServer> test_http_server_; |
27 | 53 |
28 DISALLOW_COPY_AND_ASSIGN(InProcessBrowserLayoutTest); | 54 DISALLOW_COPY_AND_ASSIGN(InProcessBrowserLayoutTest); |
29 }; | 55 }; |
OLD | NEW |