| 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 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ | 5 #ifndef CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ |
| 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ | 6 #define CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 11 #include "net/test/spawned_test_server/spawned_test_server.h" | 12 #include "net/test/spawned_test_server/spawned_test_server.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 14 |
| 14 namespace base { | 15 namespace base { |
| 15 class CommandLine; | 16 class CommandLine; |
| 16 class FilePath; | 17 class FilePath; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace net { | 20 namespace net { |
| 20 namespace test_server { | |
| 21 class EmbeddedTestServer; | |
| 22 } | |
| 23 | |
| 24 class RuleBasedHostResolverProc; | 21 class RuleBasedHostResolverProc; |
| 25 } // namespace net | 22 } // namespace net |
| 26 | 23 |
| 27 namespace content { | 24 namespace content { |
| 28 | 25 |
| 29 class BrowserTestBase : public testing::Test { | 26 class BrowserTestBase : public testing::Test { |
| 30 public: | 27 public: |
| 31 BrowserTestBase(); | 28 BrowserTestBase(); |
| 32 ~BrowserTestBase() override; | 29 ~BrowserTestBase() override; |
| 33 | 30 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // This prepares for the test by creating a new browser, runs the test | 77 // This prepares for the test by creating a new browser, runs the test |
| 81 // (RunTestOnMainThread), quits the browsers and returns. | 78 // (RunTestOnMainThread), quits the browsers and returns. |
| 82 virtual void RunTestOnMainThreadLoop() = 0; | 79 virtual void RunTestOnMainThreadLoop() = 0; |
| 83 | 80 |
| 84 // Sets expected browser exit code, in case it's different than 0 (success). | 81 // Sets expected browser exit code, in case it's different than 0 (success). |
| 85 void set_expected_exit_code(int code) { expected_exit_code_ = code; } | 82 void set_expected_exit_code(int code) { expected_exit_code_ = code; } |
| 86 | 83 |
| 87 // Returns the testing server. Guaranteed to be non-NULL. | 84 // Returns the testing server. Guaranteed to be non-NULL. |
| 88 // TODO(phajdan.jr): Remove test_server accessor (http://crbug.com/96594). | 85 // TODO(phajdan.jr): Remove test_server accessor (http://crbug.com/96594). |
| 89 const net::SpawnedTestServer* test_server() const { | 86 const net::SpawnedTestServer* test_server() const { |
| 90 return test_server_.get(); | 87 return spawned_test_server_.get(); |
| 91 } | 88 } |
| 92 net::SpawnedTestServer* test_server() { return test_server_.get(); } | 89 net::SpawnedTestServer* test_server() { return spawned_test_server_.get(); } |
| 90 |
| 91 const net::SpawnedTestServer* spawned_test_server() const { |
| 92 return spawned_test_server_.get(); |
| 93 } |
| 94 net::SpawnedTestServer* spawned_test_server() { |
| 95 return spawned_test_server_.get(); |
| 96 } |
| 93 | 97 |
| 94 // Returns the embedded test server. Guaranteed to be non-NULL. | 98 // Returns the embedded test server. Guaranteed to be non-NULL. |
| 95 const net::test_server::EmbeddedTestServer* embedded_test_server() const { | 99 const net::EmbeddedTestServer* embedded_test_server() const { |
| 96 return embedded_test_server_.get(); | 100 return embedded_test_server_.get(); |
| 97 } | 101 } |
| 98 net::test_server::EmbeddedTestServer* embedded_test_server() { | 102 net::EmbeddedTestServer* embedded_test_server() { |
| 99 return embedded_test_server_.get(); | 103 return embedded_test_server_.get(); |
| 100 } | 104 } |
| 101 | 105 |
| 102 #if defined(OS_POSIX) | 106 #if defined(OS_POSIX) |
| 103 // This is only needed by a test that raises SIGTERM to ensure that a specific | 107 // This is only needed by a test that raises SIGTERM to ensure that a specific |
| 104 // codepath is taken. | 108 // codepath is taken. |
| 105 void DisableSIGTERMHandling() { | 109 void DisableSIGTERMHandling() { |
| 106 handle_sigterm_ = false; | 110 handle_sigterm_ = false; |
| 107 } | 111 } |
| 108 #endif | 112 #endif |
| (...skipping 18 matching lines...) Expand all Loading... |
| 127 // instead. | 131 // instead. |
| 128 void UseSoftwareCompositing(); | 132 void UseSoftwareCompositing(); |
| 129 | 133 |
| 130 // Returns true if the test will be using GL acceleration via OSMesa. | 134 // Returns true if the test will be using GL acceleration via OSMesa. |
| 131 bool UsingOSMesa() const; | 135 bool UsingOSMesa() const; |
| 132 | 136 |
| 133 private: | 137 private: |
| 134 void ProxyRunTestOnMainThreadLoop(); | 138 void ProxyRunTestOnMainThreadLoop(); |
| 135 | 139 |
| 136 // Testing server, started on demand. | 140 // Testing server, started on demand. |
| 137 scoped_ptr<net::SpawnedTestServer> test_server_; | 141 scoped_ptr<net::SpawnedTestServer> spawned_test_server_; |
| 138 | 142 |
| 139 // Embedded test server, cheap to create, started on demand. | 143 // Embedded test server, cheap to create, started on demand. |
| 140 scoped_ptr<net::test_server::EmbeddedTestServer> embedded_test_server_; | 144 scoped_ptr<net::EmbeddedTestServer> embedded_test_server_; |
| 141 | 145 |
| 142 // Host resolver used during tests. | 146 // Host resolver used during tests. |
| 143 scoped_refptr<net::RuleBasedHostResolverProc> rule_based_resolver_; | 147 scoped_refptr<net::RuleBasedHostResolverProc> rule_based_resolver_; |
| 144 | 148 |
| 145 // Expected exit code (default is 0). | 149 // Expected exit code (default is 0). |
| 146 int expected_exit_code_; | 150 int expected_exit_code_; |
| 147 | 151 |
| 148 // When true, the compositor will produce pixel output that can be read back | 152 // When true, the compositor will produce pixel output that can be read back |
| 149 // for pixel tests. | 153 // for pixel tests. |
| 150 bool enable_pixel_output_; | 154 bool enable_pixel_output_; |
| 151 | 155 |
| 152 // When true, do compositing with the software backend instead of using GL. | 156 // When true, do compositing with the software backend instead of using GL. |
| 153 bool use_software_compositing_; | 157 bool use_software_compositing_; |
| 154 | 158 |
| 155 // Whether SetUp was called. This value is checked in the destructor of this | 159 // Whether SetUp was called. This value is checked in the destructor of this |
| 156 // class to ensure that SetUp was called. If it's not called, the test will | 160 // class to ensure that SetUp was called. If it's not called, the test will |
| 157 // not run and report a false positive result. | 161 // not run and report a false positive result. |
| 158 bool set_up_called_; | 162 bool set_up_called_; |
| 159 | 163 |
| 160 #if defined(OS_POSIX) | 164 #if defined(OS_POSIX) |
| 161 bool handle_sigterm_; | 165 bool handle_sigterm_; |
| 162 #endif | 166 #endif |
| 163 }; | 167 }; |
| 164 | 168 |
| 165 } // namespace content | 169 } // namespace content |
| 166 | 170 |
| 167 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ | 171 #endif // CONTENT_PUBLIC_TEST_BROWSER_TEST_BASE_H_ |
| OLD | NEW |