OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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. |
11 // | 11 // |
12 // Tests should #include this file, subclass UITest, and use the TEST_F macro | 12 // Tests should #include this file, subclass UITest, and use the TEST_F macro |
13 // to declare individual test cases. This provides a running browser window | 13 // to declare individual test cases. This provides a running browser window |
14 // during the test, accessible through the window_ member variable. The window | 14 // during the test, accessible through the window_ member variable. The window |
15 // will close when the test ends, regardless of whether the test passed. | 15 // will close when the test ends, regardless of whether the test passed. |
16 // | 16 // |
17 // Tests which need to launch the browser with a particular set of command-line | 17 // Tests which need to launch the browser with a particular set of command-line |
18 // arguments should set the value of launch_arguments_ in their constructors. | 18 // arguments should set the value of launch_arguments_ in their constructors. |
19 | 19 |
20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
21 | 21 |
22 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
23 #include <windows.h> | 23 #include <windows.h> |
24 #endif | 24 #endif |
25 #include <string> | 25 #include <string> |
26 | 26 |
| 27 #include "base/command_line.h" |
27 #include "base/message_loop.h" | 28 #include "base/message_loop.h" |
28 #include "base/path_service.h" | 29 #include "base/path_service.h" |
29 #include "base/process.h" | 30 #include "base/process.h" |
30 #include "base/scoped_ptr.h" | 31 #include "base/scoped_ptr.h" |
31 #include "base/time.h" | 32 #include "base/time.h" |
32 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
33 // TODO(evanm): we should be able to just forward-declare | 34 // TODO(evanm): we should be able to just forward-declare |
34 // AutomationProxy here, but many files that #include this one don't | 35 // AutomationProxy here, but many files that #include this one don't |
35 // themselves #include automation_proxy.h. | 36 // themselves #include automation_proxy.h. |
36 #include "chrome/test/automation/automation_proxy.h" | 37 #include "chrome/test/automation/automation_proxy.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 // This differs from file_util::Delete in that it repeatedly invokes Delete | 69 // This differs from file_util::Delete in that it repeatedly invokes Delete |
69 // until successful, or a timeout is reached. Returns true on success. | 70 // until successful, or a timeout is reached. Returns true on success. |
70 bool DieFileDie(const std::wstring& file, bool recurse); | 71 bool DieFileDie(const std::wstring& file, bool recurse); |
71 | 72 |
72 // Launches the browser and IPC testing server. | 73 // Launches the browser and IPC testing server. |
73 void LaunchBrowserAndServer(); | 74 void LaunchBrowserAndServer(); |
74 | 75 |
75 // Closes the browser and IPC testing server. | 76 // Closes the browser and IPC testing server. |
76 void CloseBrowserAndServer(); | 77 void CloseBrowserAndServer(); |
77 | 78 |
78 // Launches the browser with the given arguments. | 79 // Launches the browser with the given command line. |
79 void LaunchBrowser(const std::wstring& arguments, bool clear_profile); | 80 void LaunchBrowser(const CommandLine& cmdline, bool clear_profile); |
80 | 81 |
81 // Exits out browser instance. | 82 // Exits out browser instance. |
82 void QuitBrowser(); | 83 void QuitBrowser(); |
83 | 84 |
84 // Tells the browser to navigato to the givne URL in the active tab | 85 // Tells the browser to navigato to the givne URL in the active tab |
85 // of the first app window. | 86 // of the first app window. |
86 // Does not wait for the navigation to complete to return. | 87 // Does not wait for the navigation to complete to return. |
87 void NavigateToURLAsync(const GURL& url); | 88 void NavigateToURLAsync(const GURL& url); |
88 | 89 |
89 // Tells the browser to navigate to the given URL in the active tab | 90 // Tells the browser to navigate to the given URL in the active tab |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 // tab or there was some kind of error. The returned pointer MUST be | 383 // tab or there was some kind of error. The returned pointer MUST be |
383 // deleted by the caller if non-NULL. | 384 // deleted by the caller if non-NULL. |
384 TabProxy* GetActiveTab(); | 385 TabProxy* GetActiveTab(); |
385 | 386 |
386 // ********* Member variables ********* | 387 // ********* Member variables ********* |
387 | 388 |
388 std::wstring browser_directory_; // Path to the browser executable, | 389 std::wstring browser_directory_; // Path to the browser executable, |
389 // with no trailing slash | 390 // with no trailing slash |
390 std::wstring test_data_directory_; // Path to the unit test data, | 391 std::wstring test_data_directory_; // Path to the unit test data, |
391 // with no trailing slash | 392 // with no trailing slash |
392 std::wstring launch_arguments_; // Arguments to the browser on launch. | 393 CommandLine launch_arguments_; // Command to launch the browser |
393 size_t expected_errors_; // The number of errors expected during | 394 size_t expected_errors_; // The number of errors expected during |
394 // the run (generally 0). | 395 // the run (generally 0). |
395 int expected_crashes_; // The number of crashes expected during | 396 int expected_crashes_; // The number of crashes expected during |
396 // the run (generally 0). | 397 // the run (generally 0). |
397 std::wstring homepage_; // Homepage used for testing. | 398 std::wstring homepage_; // Homepage used for testing. |
398 bool wait_for_initial_loads_; // Wait for initial loads to complete | 399 bool wait_for_initial_loads_; // Wait for initial loads to complete |
399 // in SetUp() before running test body. | 400 // in SetUp() before running test body. |
400 base::TimeTicks browser_launch_time_; // Time when the browser was run. | 401 base::TimeTicks browser_launch_time_; // Time when the browser was run. |
401 bool dom_automation_enabled_; // This can be set to true to have the | 402 bool dom_automation_enabled_; // This can be set to true to have the |
402 // test run the dom automation case. | 403 // test run the dom automation case. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 #ifdef UNIT_TEST | 460 #ifdef UNIT_TEST |
460 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); | 461 std::ostream& operator<<(std::ostream& out, const std::wstring& wstr); |
461 | 462 |
462 template<typename T> | 463 template<typename T> |
463 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { | 464 std::ostream& operator<<(std::ostream& out, const ::scoped_ptr<T>& ptr) { |
464 return out << ptr.get(); | 465 return out << ptr.get(); |
465 } | 466 } |
466 #endif // UNIT_TEST | 467 #endif // UNIT_TEST |
467 | 468 |
468 #endif // CHROME_TEST_UI_UI_TEST_H_ | 469 #endif // CHROME_TEST_UI_UI_TEST_H_ |
OLD | NEW |