OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/test/ui/ui_test.h" | 5 #include "chrome/test/ui/ui_test.h" |
6 | 6 |
7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
8 #include <signal.h> | 8 #include <signal.h> |
9 #include <sys/types.h> | 9 #include <sys/types.h> |
10 #endif | 10 #endif |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 wait_for_initial_loads_(true), | 86 wait_for_initial_loads_(true), |
87 dom_automation_enabled_(false), | 87 dom_automation_enabled_(false), |
88 show_window_(false), | 88 show_window_(false), |
89 clear_profile_(true), | 89 clear_profile_(true), |
90 include_testing_id_(true), | 90 include_testing_id_(true), |
91 enable_file_cookies_(true), | 91 enable_file_cookies_(true), |
92 profile_type_(ProxyLauncher::DEFAULT_THEME), | 92 profile_type_(ProxyLauncher::DEFAULT_THEME), |
93 shutdown_type_(ProxyLauncher::WINDOW_CLOSE) { | 93 shutdown_type_(ProxyLauncher::WINDOW_CLOSE) { |
94 PathService::Get(chrome::DIR_APP, &browser_directory_); | 94 PathService::Get(chrome::DIR_APP, &browser_directory_); |
95 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); | 95 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); |
96 launcher_.reset(CreateProxyLauncher()); | |
97 } | 96 } |
98 | 97 |
99 UITestBase::UITestBase(MessageLoop::Type msg_loop_type) | 98 UITestBase::UITestBase(MessageLoop::Type msg_loop_type) |
100 : launch_arguments_(CommandLine::NO_PROGRAM), | 99 : launch_arguments_(CommandLine::NO_PROGRAM), |
101 expected_errors_(0), | 100 expected_errors_(0), |
102 expected_crashes_(0), | 101 expected_crashes_(0), |
103 wait_for_initial_loads_(true), | 102 wait_for_initial_loads_(true), |
104 dom_automation_enabled_(false), | 103 dom_automation_enabled_(false), |
105 show_window_(false), | 104 show_window_(false), |
106 clear_profile_(true), | 105 clear_profile_(true), |
107 include_testing_id_(true), | 106 include_testing_id_(true), |
108 enable_file_cookies_(true), | 107 enable_file_cookies_(true), |
109 profile_type_(ProxyLauncher::DEFAULT_THEME), | 108 profile_type_(ProxyLauncher::DEFAULT_THEME), |
110 shutdown_type_(ProxyLauncher::WINDOW_CLOSE) { | 109 shutdown_type_(ProxyLauncher::WINDOW_CLOSE) { |
111 PathService::Get(chrome::DIR_APP, &browser_directory_); | 110 PathService::Get(chrome::DIR_APP, &browser_directory_); |
112 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); | 111 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); |
113 launcher_.reset(CreateProxyLauncher()); | |
114 } | 112 } |
115 | 113 |
116 UITestBase::~UITestBase() {} | 114 UITestBase::~UITestBase() {} |
117 | 115 |
118 void UITestBase::SetUp() { | 116 void UITestBase::SetUp() { |
| 117 // Some tests (e.g. SessionRestoreUITest) call SetUp() multiple times, |
| 118 // but the ProxyLauncher should be initialized only once per instance. |
| 119 if (!launcher_.get()) |
| 120 launcher_.reset(CreateProxyLauncher()); |
119 launcher_->AssertAppNotRunning(L"Please close any other instances " | 121 launcher_->AssertAppNotRunning(L"Please close any other instances " |
120 L"of the app before testing."); | 122 L"of the app before testing."); |
121 | 123 |
122 JavaScriptExecutionController::set_timeout( | 124 JavaScriptExecutionController::set_timeout( |
123 TestTimeouts::action_max_timeout_ms()); | 125 TestTimeouts::action_max_timeout_ms()); |
124 test_start_time_ = Time::NowFromSystemTime(); | 126 test_start_time_ = Time::NowFromSystemTime(); |
125 | 127 |
126 SetLaunchSwitches(); | 128 SetLaunchSwitches(); |
127 launcher_->InitializeConnection(DefaultLaunchState(), | 129 launcher_->InitializeConnection(DefaultLaunchState(), |
128 wait_for_initial_loads_); | 130 wait_for_initial_loads_); |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 incorrect_state_count++; | 847 incorrect_state_count++; |
846 } | 848 } |
847 | 849 |
848 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() | 850 LOG(INFO) << "Elapsed time: " << (base::Time::Now() - start).InSecondsF() |
849 << " seconds" | 851 << " seconds" |
850 << " call failed " << fail_count << " times" | 852 << " call failed " << fail_count << " times" |
851 << " state was incorrect " << incorrect_state_count << " times"; | 853 << " state was incorrect " << incorrect_state_count << " times"; |
852 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; | 854 ADD_FAILURE() << "Timeout reached in " << __FUNCTION__; |
853 return false; | 855 return false; |
854 } | 856 } |
OLD | NEW |