| 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 CHROME_TEST_UI_UI_TEST_H_ | 5 #ifndef CHROME_TEST_UI_UI_TEST_H_ |
| 6 #define CHROME_TEST_UI_UI_TEST_H_ | 6 #define CHROME_TEST_UI_UI_TEST_H_ |
| 7 | 7 |
| 8 // This file provides a common base for running UI unit tests, which operate | 8 // This file provides a common base for running UI unit tests, which operate |
| 9 // the entire browser application in a separate process for holistic | 9 // the entire browser application in a separate process for holistic |
| 10 // functional testing. | 10 // functional testing. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 class FilePath; | 38 class FilePath; |
| 39 } | 39 } |
| 40 | 40 |
| 41 // Base class for UI Tests. This implements the core of the functions. | 41 // Base class for UI Tests. This implements the core of the functions. |
| 42 // This base class decouples all automation functionality from testing | 42 // This base class decouples all automation functionality from testing |
| 43 // infrastructure, for use without gtest. | 43 // infrastructure, for use without gtest. |
| 44 // If using gtest, you probably want to inherit from UITest (declared below) | 44 // If using gtest, you probably want to inherit from UITest (declared below) |
| 45 // rather than UITestBase. | 45 // rather than UITestBase. |
| 46 class UITestBase { | 46 class UITestBase { |
| 47 public: | 47 public: |
| 48 // Profile theme type choices. | |
| 49 enum ProfileType { | |
| 50 DEFAULT_THEME = 0, | |
| 51 COMPLEX_THEME = 1, | |
| 52 }; | |
| 53 | |
| 54 // ********* Utility functions ********* | 48 // ********* Utility functions ********* |
| 55 | 49 |
| 56 // Launches the browser only. | 50 // Launches the browser only. |
| 57 void LaunchBrowser(); | 51 void LaunchBrowser(); |
| 58 | 52 |
| 59 // Launches the browser and IPC testing connection in server mode. | 53 // Launches the browser and IPC testing connection in server mode. |
| 60 void LaunchBrowserAndServer(); | 54 void LaunchBrowserAndServer(); |
| 61 | 55 |
| 62 // Launches the IPC testing connection in client mode, | 56 // Launches the IPC testing connection in client mode, |
| 63 // which then attempts to connect to a browser. | 57 // which then attempts to connect to a browser. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 // Closes the specified browser. Returns true if the browser was closed. | 135 // Closes the specified browser. Returns true if the browser was closed. |
| 142 // This call is blocking. |application_closed| is set to true if this was | 136 // This call is blocking. |application_closed| is set to true if this was |
| 143 // the last browser window (and therefore as a result of it closing the | 137 // the last browser window (and therefore as a result of it closing the |
| 144 // browser process terminated). Note that in that case this method returns | 138 // browser process terminated). Note that in that case this method returns |
| 145 // after the browser process has terminated. | 139 // after the browser process has terminated. |
| 146 bool CloseBrowser(BrowserProxy* browser, bool* application_closed) const; | 140 bool CloseBrowser(BrowserProxy* browser, bool* application_closed) const; |
| 147 | 141 |
| 148 // Gets the executable file path of the Chrome browser process. | 142 // Gets the executable file path of the Chrome browser process. |
| 149 const base::FilePath::CharType* GetExecutablePath(); | 143 const base::FilePath::CharType* GetExecutablePath(); |
| 150 | 144 |
| 151 // Returns the directory name where the "typical" user data is that we use | |
| 152 // for testing. | |
| 153 static base::FilePath ComputeTypicalUserDataSource(ProfileType profile_type); | |
| 154 | |
| 155 // Return the user data directory being used by the browser instance in | 145 // Return the user data directory being used by the browser instance in |
| 156 // UITest::SetUp(). | 146 // UITest::SetUp(). |
| 157 base::FilePath user_data_dir() const { | 147 base::FilePath user_data_dir() const { |
| 158 return launcher_->user_data_dir(); | 148 return launcher_->user_data_dir(); |
| 159 } | 149 } |
| 160 | 150 |
| 161 // Called by some tests that wish to have a base profile to start from. This | 151 // Called by some tests that wish to have a base profile to start from. This |
| 162 // "user data directory" (containing one or more profiles) will be recursively | 152 // "user data directory" (containing one or more profiles) will be recursively |
| 163 // copied into the user data directory for the test and the files will be | 153 // copied into the user data directory for the test and the files will be |
| 164 // evicted from the OS cache. To start with a blank profile, supply an empty | 154 // evicted from the OS cache. To start with a blank profile, supply an empty |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 // Should we supply the testing channel id | 311 // Should we supply the testing channel id |
| 322 // on the command line? Default is true. | 312 // on the command line? Default is true. |
| 323 bool include_testing_id_; | 313 bool include_testing_id_; |
| 324 | 314 |
| 325 // Enable file cookies, default is true. | 315 // Enable file cookies, default is true. |
| 326 bool enable_file_cookies_; | 316 bool enable_file_cookies_; |
| 327 | 317 |
| 328 // Launches browser and AutomationProxy. | 318 // Launches browser and AutomationProxy. |
| 329 scoped_ptr<ProxyLauncher> launcher_; | 319 scoped_ptr<ProxyLauncher> launcher_; |
| 330 | 320 |
| 331 // Are we using a profile with a complex theme? | |
| 332 ProfileType profile_type_; | |
| 333 | |
| 334 // PID file for websocket server. | 321 // PID file for websocket server. |
| 335 base::FilePath websocket_pid_file_; | 322 base::FilePath websocket_pid_file_; |
| 336 | 323 |
| 337 private: | 324 private: |
| 338 // Time the test was started (so we can check for new crash dumps) | 325 // Time the test was started (so we can check for new crash dumps) |
| 339 base::Time test_start_time_; | 326 base::Time test_start_time_; |
| 340 }; | 327 }; |
| 341 | 328 |
| 342 class UITest : public UITestBase, public PlatformTest { | 329 class UITest : public UITestBase, public PlatformTest { |
| 343 protected: | 330 protected: |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 #ifdef UNIT_TEST | 416 #ifdef UNIT_TEST |
| 430 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); | 417 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); |
| 431 | 418 |
| 432 template<typename T> | 419 template<typename T> |
| 433 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { | 420 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { |
| 434 return out << ptr.get(); | 421 return out << ptr.get(); |
| 435 } | 422 } |
| 436 #endif // UNIT_TEST | 423 #endif // UNIT_TEST |
| 437 | 424 |
| 438 #endif // CHROME_TEST_UI_UI_TEST_H_ | 425 #endif // CHROME_TEST_UI_UI_TEST_H_ |
| OLD | NEW |