| 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 #include <set> | 5 #include <set> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "chrome/test/ui/ui_test.h" | 8 #include "chrome/test/ui/ui_test.h" |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 ASSERT_TRUE(DieFileDie(user_data_dir_, true)); | 232 ASSERT_TRUE(DieFileDie(user_data_dir_, true)); |
| 233 | 233 |
| 234 if (!template_user_data_.empty()) { | 234 if (!template_user_data_.empty()) { |
| 235 // Recursively copy the template directory to the user_data_dir. | 235 // Recursively copy the template directory to the user_data_dir. |
| 236 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache(template_user_data_, | 236 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache(template_user_data_, |
| 237 user_data_dir_)); | 237 user_data_dir_)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 browser_launch_time_ = TimeTicks::Now(); | 240 browser_launch_time_ = TimeTicks::Now(); |
| 241 | 241 |
| 242 bool started = process_util::LaunchApp( | 242 bool started = base::LaunchApp(command_line, |
| 243 command_line, | 243 false, // Don't wait for process object |
| 244 false, // Don't wait for process object (doesn't work for | 244 // (doesn't work for us) |
| 245 // us) | 245 !show_window_, |
| 246 !show_window_, | 246 &process_); |
| 247 &process_); | |
| 248 ASSERT_EQ(started, true); | 247 ASSERT_EQ(started, true); |
| 249 | 248 |
| 250 if (use_existing_browser_) { | 249 if (use_existing_browser_) { |
| 251 DWORD pid = 0; | 250 DWORD pid = 0; |
| 252 HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, | 251 HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, |
| 253 user_data_dir_.c_str()); | 252 user_data_dir_.c_str()); |
| 254 GetWindowThreadProcessId(hwnd, &pid); | 253 GetWindowThreadProcessId(hwnd, &pid); |
| 255 // This mode doesn't work if we wound up launching a new browser ourselves. | 254 // This mode doesn't work if we wound up launching a new browser ourselves. |
| 256 ASSERT_NE(pid, process_util::GetProcId(process_)); | 255 ASSERT_NE(pid, base::GetProcId(process_)); |
| 257 CloseHandle(process_); | 256 CloseHandle(process_); |
| 258 process_ = OpenProcess(SYNCHRONIZE, false, pid); | 257 process_ = OpenProcess(SYNCHRONIZE, false, pid); |
| 259 } | 258 } |
| 260 } | 259 } |
| 261 | 260 |
| 262 void UITest::QuitBrowser() { | 261 void UITest::QuitBrowser() { |
| 263 typedef std::vector<BrowserProxy*> BrowserVector; | 262 typedef std::vector<BrowserProxy*> BrowserVector; |
| 264 | 263 |
| 265 // There's nothing to do here if the browser is not running. | 264 // There's nothing to do here if the browser is not running. |
| 266 if (IsBrowserRunning()) { | 265 if (IsBrowserRunning()) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 void UITest::AssertAppNotRunning(const std::wstring& error_message) { | 309 void UITest::AssertAppNotRunning(const std::wstring& error_message) { |
| 311 ASSERT_EQ(0, GetBrowserProcessCount()) << error_message; | 310 ASSERT_EQ(0, GetBrowserProcessCount()) << error_message; |
| 312 } | 311 } |
| 313 | 312 |
| 314 void UITest::CleanupAppProcesses() { | 313 void UITest::CleanupAppProcesses() { |
| 315 BrowserProcessFilter filter(L""); | 314 BrowserProcessFilter filter(L""); |
| 316 | 315 |
| 317 // Make sure that no instances of the browser remain. | 316 // Make sure that no instances of the browser remain. |
| 318 const int kExitTimeoutMs = 5000; | 317 const int kExitTimeoutMs = 5000; |
| 319 const int kExitCode = 1; | 318 const int kExitCode = 1; |
| 320 process_util::CleanupProcesses( | 319 base::CleanupProcesses( |
| 321 chrome::kBrowserProcessExecutableName, kExitTimeoutMs, kExitCode, | 320 chrome::kBrowserProcessExecutableName, kExitTimeoutMs, kExitCode, |
| 322 &filter); | 321 &filter); |
| 323 | 322 |
| 324 // Suppress spammy failures that seem to be occurring when running | 323 // Suppress spammy failures that seem to be occurring when running |
| 325 // the UI tests in single-process mode. | 324 // the UI tests in single-process mode. |
| 326 // TODO(jhughes): figure out why this is necessary at all, and fix it | 325 // TODO(jhughes): figure out why this is necessary at all, and fix it |
| 327 if (!in_process_renderer_) { | 326 if (!in_process_renderer_) { |
| 328 AssertAppNotRunning(L"Unable to quit all browser processes."); | 327 AssertAppNotRunning(L"Unable to quit all browser processes."); |
| 329 } | 328 } |
| 330 } | 329 } |
| 331 | 330 |
| 332 TabProxy* UITest::GetActiveTab() { | 331 TabProxy* UITest::GetActiveTab() { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 return CrashAwareSleep(0); | 434 return CrashAwareSleep(0); |
| 436 } | 435 } |
| 437 | 436 |
| 438 bool UITest::CrashAwareSleep(int time_out_ms) { | 437 bool UITest::CrashAwareSleep(int time_out_ms) { |
| 439 return WAIT_TIMEOUT == WaitForSingleObject(process_, time_out_ms); | 438 return WAIT_TIMEOUT == WaitForSingleObject(process_, time_out_ms); |
| 440 } | 439 } |
| 441 | 440 |
| 442 /*static*/ | 441 /*static*/ |
| 443 int UITest::GetBrowserProcessCount() { | 442 int UITest::GetBrowserProcessCount() { |
| 444 BrowserProcessFilter filter(L""); | 443 BrowserProcessFilter filter(L""); |
| 445 return process_util::GetProcessCount(chrome::kBrowserProcessExecutableName, | 444 return base::GetProcessCount(chrome::kBrowserProcessExecutableName, |
| 446 &filter); | 445 &filter); |
| 447 } | 446 } |
| 448 | 447 |
| 449 static DictionaryValue* LoadDictionaryValueFromPath(const std::wstring& path) { | 448 static DictionaryValue* LoadDictionaryValueFromPath(const std::wstring& path) { |
| 450 if (path.empty()) | 449 if (path.empty()) |
| 451 return NULL; | 450 return NULL; |
| 452 | 451 |
| 453 JSONFileValueSerializer serializer(path); | 452 JSONFileValueSerializer serializer(path); |
| 454 Value* root_value = NULL; | 453 Value* root_value = NULL; |
| 455 if (serializer.Deserialize(&root_value) && | 454 if (serializer.Deserialize(&root_value) && |
| 456 root_value->GetType() != Value::TYPE_DICTIONARY) { | 455 root_value->GetType() != Value::TYPE_DICTIONARY) { |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 const std::wstring& units, | 662 const std::wstring& units, |
| 664 bool important) { | 663 bool important) { |
| 665 // <*>RESULT <graph_name>: <trace_name>= <value> <units> | 664 // <*>RESULT <graph_name>: <trace_name>= <value> <units> |
| 666 // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units> | 665 // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units> |
| 667 // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units> | 666 // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units> |
| 668 wprintf(L"%lsRESULT %ls%ls: %ls= %ls%ls%ls %ls\n", | 667 wprintf(L"%lsRESULT %ls%ls: %ls= %ls%ls%ls %ls\n", |
| 669 important ? L"*" : L"", measurement.c_str(), modifier.c_str(), | 668 important ? L"*" : L"", measurement.c_str(), modifier.c_str(), |
| 670 trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(), | 669 trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(), |
| 671 units.c_str()); | 670 units.c_str()); |
| 672 } | 671 } |
| OLD | NEW |