Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: chrome/test/ui/ui_test.cc

Issue 140008: Add a switch to allow longer shutdown timeouts, since quitting under valgrind... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | tools/valgrind/chrome_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base_switches.h" 10 #include "base/base_switches.h"
(...skipping 23 matching lines...) Expand all
34 #include "net/base/net_util.h" 34 #include "net/base/net_util.h"
35 35
36 36
37 using base::TimeTicks; 37 using base::TimeTicks;
38 38
39 // Delay to let browser complete a requested action. 39 // Delay to let browser complete a requested action.
40 static const int kWaitForActionMsec = 2000; 40 static const int kWaitForActionMsec = 2000;
41 static const int kWaitForActionMaxMsec = 10000; 41 static const int kWaitForActionMaxMsec = 10000;
42 // Delay to let the browser complete the test. 42 // Delay to let the browser complete the test.
43 static const int kMaxTestExecutionTime = 30000; 43 static const int kMaxTestExecutionTime = 30000;
44 // Delay to let the browser shut down.
45 static const int kWaitForTerminateMsec = 5000;
44 46
45 const wchar_t UITest::kFailedNoCrashService[] = 47 const wchar_t UITest::kFailedNoCrashService[] =
46 L"NOTE: This test is expected to fail if crash_service.exe is not " 48 L"NOTE: This test is expected to fail if crash_service.exe is not "
47 L"running. Start it manually before running this test (see the build " 49 L"running. Start it manually before running this test (see the build "
48 L"output directory)."; 50 L"output directory).";
49 bool UITest::in_process_renderer_ = false; 51 bool UITest::in_process_renderer_ = false;
50 bool UITest::no_sandbox_ = false; 52 bool UITest::no_sandbox_ = false;
51 bool UITest::full_memory_dump_ = false; 53 bool UITest::full_memory_dump_ = false;
52 bool UITest::safe_plugins_ = false; 54 bool UITest::safe_plugins_ = false;
53 bool UITest::show_error_dialogs_ = true; 55 bool UITest::show_error_dialogs_ = true;
54 bool UITest::default_use_existing_browser_ = false; 56 bool UITest::default_use_existing_browser_ = false;
55 bool UITest::dump_histograms_on_exit_ = false; 57 bool UITest::dump_histograms_on_exit_ = false;
56 bool UITest::enable_dcheck_ = false; 58 bool UITest::enable_dcheck_ = false;
57 bool UITest::silent_dump_on_dcheck_ = false; 59 bool UITest::silent_dump_on_dcheck_ = false;
58 bool UITest::disable_breakpad_ = false; 60 bool UITest::disable_breakpad_ = false;
59 int UITest::timeout_ms_ = 20 * 60 * 1000; 61 int UITest::timeout_ms_ = 20 * 60 * 1000;
60 std::wstring UITest::js_flags_ = L""; 62 std::wstring UITest::js_flags_ = L"";
61 std::wstring UITest::log_level_ = L""; 63 std::wstring UITest::log_level_ = L"";
62 64
63 65
64 // Specify the time (in milliseconds) that the ui_tests should wait before 66 // Specify the time (in milliseconds) that the ui_tests should wait before
65 // timing out. This is used to specify longer timeouts when running under Purify 67 // timing out. This is used to specify longer timeouts when running under Purify
66 // which requires much more time. 68 // which requires much more time.
67 const wchar_t kUiTestTimeout[] = L"ui-test-timeout"; 69 const wchar_t kUiTestTimeout[] = L"ui-test-timeout";
68 const wchar_t kUiTestActionTimeout[] = L"ui-test-action-timeout"; 70 const wchar_t kUiTestActionTimeout[] = L"ui-test-action-timeout";
69 const wchar_t kUiTestActionMaxTimeout[] = L"ui-test-action-max-timeout"; 71 const wchar_t kUiTestActionMaxTimeout[] = L"ui-test-action-max-timeout";
70 const wchar_t kUiTestSleepTimeout[] = L"ui-test-sleep-timeout"; 72 const wchar_t kUiTestSleepTimeout[] = L"ui-test-sleep-timeout";
73 const wchar_t kUiTestTerminateTimeout[] = L"ui-test-terminate-timeout";
71 74
72 const wchar_t kExtraChromeFlagsSwitch[] = L"extra-chrome-flags"; 75 const wchar_t kExtraChromeFlagsSwitch[] = L"extra-chrome-flags";
73 76
74 // By default error dialogs are hidden, which makes debugging failures in the 77 // By default error dialogs are hidden, which makes debugging failures in the
75 // slave process frustrating. By passing this in error dialogs are enabled. 78 // slave process frustrating. By passing this in error dialogs are enabled.
76 const wchar_t kEnableErrorDialogs[] = L"enable-errdialogs"; 79 const wchar_t kEnableErrorDialogs[] = L"enable-errdialogs";
77 80
78 // Uncomment this line to have the spawned process wait for the debugger to 81 // Uncomment this line to have the spawned process wait for the debugger to
79 // attach. This only works on Windows. On posix systems, you can set the 82 // attach. This only works on Windows. On posix systems, you can set the
80 // BROWSER_WRAPPER env variable to wrap the browser process. 83 // BROWSER_WRAPPER env variable to wrap the browser process.
(...skipping 23 matching lines...) Expand all
104 process_(0), // NULL on Windows, 0 PID on POSIX. 107 process_(0), // NULL on Windows, 0 PID on POSIX.
105 show_window_(false), 108 show_window_(false),
106 clear_profile_(true), 109 clear_profile_(true),
107 include_testing_id_(true), 110 include_testing_id_(true),
108 use_existing_browser_(default_use_existing_browser_), 111 use_existing_browser_(default_use_existing_browser_),
109 enable_file_cookies_(true), 112 enable_file_cookies_(true),
110 test_start_time_(base::Time::NowFromSystemTime()), 113 test_start_time_(base::Time::NowFromSystemTime()),
111 command_execution_timeout_ms_(kMaxTestExecutionTime), 114 command_execution_timeout_ms_(kMaxTestExecutionTime),
112 action_timeout_ms_(kWaitForActionMsec), 115 action_timeout_ms_(kWaitForActionMsec),
113 action_max_timeout_ms_(kWaitForActionMaxMsec), 116 action_max_timeout_ms_(kWaitForActionMaxMsec),
114 sleep_timeout_ms_(kWaitForActionMsec) { 117 sleep_timeout_ms_(kWaitForActionMsec),
118 terminate_timeout_ms_(kWaitForTerminateMsec) {
115 PathService::Get(chrome::DIR_APP, &browser_directory_); 119 PathService::Get(chrome::DIR_APP, &browser_directory_);
116 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); 120 PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_);
117 } 121 }
118 122
119 void UITest::SetUp() { 123 void UITest::SetUp() {
120 if (!use_existing_browser_) { 124 if (!use_existing_browser_) {
121 AssertAppNotRunning(L"Please close any other instances " 125 AssertAppNotRunning(L"Please close any other instances "
122 L"of the app before testing."); 126 L"of the app before testing.");
123 } 127 }
124 128
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 int max_timeout = StringToInt(WideToUTF16Hack(action_max_str)); 196 int max_timeout = StringToInt(WideToUTF16Hack(action_max_str));
193 action_max_timeout_ms_ = std::max(kWaitForActionMaxMsec, max_timeout); 197 action_max_timeout_ms_ = std::max(kWaitForActionMaxMsec, max_timeout);
194 } 198 }
195 199
196 if (CommandLine::ForCurrentProcess()->HasSwitch(kUiTestSleepTimeout)) { 200 if (CommandLine::ForCurrentProcess()->HasSwitch(kUiTestSleepTimeout)) {
197 std::wstring sleep_timeout_str = 201 std::wstring sleep_timeout_str =
198 CommandLine::ForCurrentProcess()->GetSwitchValue(kUiTestSleepTimeout); 202 CommandLine::ForCurrentProcess()->GetSwitchValue(kUiTestSleepTimeout);
199 int sleep_timeout = StringToInt(WideToUTF16Hack(sleep_timeout_str)); 203 int sleep_timeout = StringToInt(WideToUTF16Hack(sleep_timeout_str));
200 sleep_timeout_ms_ = std::max(kWaitForActionMsec, sleep_timeout); 204 sleep_timeout_ms_ = std::max(kWaitForActionMsec, sleep_timeout);
201 } 205 }
206
207 if (CommandLine::ForCurrentProcess()->HasSwitch(kUiTestTerminateTimeout)) {
208 std::wstring terminate_timeout_str =
209 CommandLine::ForCurrentProcess()->GetSwitchValue(
210 kUiTestTerminateTimeout);
211 int terminate_timeout = StringToInt(WideToUTF16Hack(terminate_timeout_str));
212 terminate_timeout_ms_ = std::max(kWaitForActionMsec, terminate_timeout);
213 }
202 } 214 }
203 215
204 AutomationProxy* UITest::CreateAutomationProxy(int execution_timeout) { 216 AutomationProxy* UITest::CreateAutomationProxy(int execution_timeout) {
205 // By default we create a plain vanilla AutomationProxy. 217 // By default we create a plain vanilla AutomationProxy.
206 return new AutomationProxy(execution_timeout); 218 return new AutomationProxy(execution_timeout);
207 } 219 }
208 220
209 void UITest::LaunchBrowserAndServer() { 221 void UITest::LaunchBrowserAndServer() {
210 // Set up IPC testing interface server. 222 // Set up IPC testing interface server.
211 server_.reset(CreateAutomationProxy(command_execution_timeout_ms_)); 223 server_.reset(CreateAutomationProxy(command_execution_timeout_ms_));
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 } 432 }
421 433
422 browsers.clear(); 434 browsers.clear();
423 435
424 // Now, drop the automation IPC channel so that the automation provider in 436 // Now, drop the automation IPC channel so that the automation provider in
425 // the browser notices and drops its reference to the browser process. 437 // the browser notices and drops its reference to the browser process.
426 server_->Disconnect(); 438 server_->Disconnect();
427 439
428 // Wait for the browser process to quit. It should quit once all tabs have 440 // Wait for the browser process to quit. It should quit once all tabs have
429 // been closed. 441 // been closed.
430 int timeout = 5000; 442 int timeout = terminate_timeout_ms_;
431 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN 443 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN
432 timeout = 500000; 444 timeout = 500000;
433 #endif 445 #endif
434 if (!base::WaitForSingleProcess(process_, timeout)) { 446 if (!base::WaitForSingleProcess(process_, timeout)) {
435 // We need to force the browser to quit because it didn't quit fast 447 // We need to force the browser to quit because it didn't quit fast
436 // enough. Take no chance and kill every chrome processes. 448 // enough. Take no chance and kill every chrome processes.
437 CleanupAppProcesses(); 449 CleanupAppProcesses();
438 } 450 }
439 } 451 }
440 452
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
874 } 886 }
875 887
876 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) { 888 bool UITest::EvictFileFromSystemCacheWrapper(const FilePath& path) {
877 for (int i = 0; i < 10; i++) { 889 for (int i = 0; i < 10; i++) {
878 if (file_util::EvictFileFromSystemCache(path)) 890 if (file_util::EvictFileFromSystemCache(path))
879 return true; 891 return true;
880 PlatformThread::Sleep(sleep_timeout_ms() / 10); 892 PlatformThread::Sleep(sleep_timeout_ms() / 10);
881 } 893 }
882 return false; 894 return false;
883 } 895 }
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test.h ('k') | tools/valgrind/chrome_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698