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