| 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 "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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
| 13 #include "base/platform_thread.h" | 13 #include "base/platform_thread.h" |
| 14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
| 15 #include "base/scoped_ptr.h" | 15 #include "base/scoped_ptr.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/test_file_util.h" | 17 #include "base/test_file_util.h" |
| 18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "chrome/app/chrome_dll_resource.h" | 19 #include "chrome/app/chrome_dll_resource.h" |
| 20 #include "chrome/browser/net/url_fixer_upper.h" | 20 #include "chrome/browser/net/url_fixer_upper.h" |
| 21 #include "chrome/common/chrome_constants.h" | 21 #include "chrome/common/chrome_constants.h" |
| 22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/debug_flags.h" | 24 #include "chrome/common/debug_flags.h" |
| 25 #include "chrome/common/logging_chrome.h" | 25 #include "chrome/common/logging_chrome.h" |
| 26 #include "chrome/common/json_value_serializer.h" | 26 #include "chrome/common/json_value_serializer.h" |
| 27 #include "chrome/test/automation/automation_proxy.h" |
| 28 #include "chrome/test/automation/browser_proxy.h" |
| 27 #include "googleurl/src/gurl.h" | 29 #include "googleurl/src/gurl.h" |
| 28 #include "net/base/net_util.h" | 30 #include "net/base/net_util.h" |
| 29 | 31 |
| 30 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 31 // TODO(port): these just need to be ported. | 33 // TODO(port): these just need to be ported. |
| 32 #include "chrome/common/chrome_process_filter.h" | 34 #include "chrome/common/chrome_process_filter.h" |
| 33 #include "chrome/test/automation/browser_proxy.h" | |
| 34 #include "chrome/test/automation/tab_proxy.h" | 35 #include "chrome/test/automation/tab_proxy.h" |
| 35 #include "chrome/test/automation/window_proxy.h" | 36 #include "chrome/test/automation/window_proxy.h" |
| 36 #endif | 37 #endif |
| 37 | 38 |
| 38 using base::TimeTicks; | 39 using base::TimeTicks; |
| 39 | 40 |
| 40 // Delay to let browser complete a requested action. | 41 // Delay to let browser complete a requested action. |
| 41 static const int kWaitForActionMsec = 2000; | 42 static const int kWaitForActionMsec = 2000; |
| 42 static const int kWaitForActionMaxMsec = 10000; | 43 static const int kWaitForActionMaxMsec = 10000; |
| 43 // Delay to let the browser complete the test. | 44 // Delay to let the browser complete the test. |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 | 205 |
| 205 if (CommandLine::ForCurrentProcess()->HasSwitch(kUiTestSleepTimeout)) { | 206 if (CommandLine::ForCurrentProcess()->HasSwitch(kUiTestSleepTimeout)) { |
| 206 std::wstring sleep_timeout_str = | 207 std::wstring sleep_timeout_str = |
| 207 CommandLine::ForCurrentProcess()->GetSwitchValue(kUiTestSleepTimeout); | 208 CommandLine::ForCurrentProcess()->GetSwitchValue(kUiTestSleepTimeout); |
| 208 int sleep_timeout = StringToInt(WideToUTF16Hack(sleep_timeout_str)); | 209 int sleep_timeout = StringToInt(WideToUTF16Hack(sleep_timeout_str)); |
| 209 sleep_timeout_ms_ = std::max(kWaitForActionMsec, sleep_timeout); | 210 sleep_timeout_ms_ = std::max(kWaitForActionMsec, sleep_timeout); |
| 210 } | 211 } |
| 211 } | 212 } |
| 212 | 213 |
| 213 void UITest::LaunchBrowserAndServer() { | 214 void UITest::LaunchBrowserAndServer() { |
| 214 #if defined(OS_WIN) | |
| 215 // Set up IPC testing interface server. | 215 // Set up IPC testing interface server. |
| 216 server_.reset(new AutomationProxy(command_execution_timeout_ms_)); | 216 server_.reset(new AutomationProxy(command_execution_timeout_ms_)); |
| 217 | 217 |
| 218 LaunchBrowser(launch_arguments_, clear_profile_); | 218 LaunchBrowser(launch_arguments_, clear_profile_); |
| 219 if (wait_for_initial_loads_) | 219 if (wait_for_initial_loads_) |
| 220 ASSERT_TRUE(server_->WaitForInitialLoads()); | 220 ASSERT_TRUE(server_->WaitForInitialLoads()); |
| 221 else | 221 else |
| 222 Sleep(2000); | 222 PlatformThread::Sleep(2000); |
| 223 | 223 |
| 224 automation()->SetFilteredInet(true); | 224 automation()->SetFilteredInet(true); |
| 225 #else | |
| 226 // TODO(port): depends on AutomationProxy. | |
| 227 NOTIMPLEMENTED(); | |
| 228 #endif | |
| 229 } | 225 } |
| 230 | 226 |
| 231 void UITest::CloseBrowserAndServer() { | 227 void UITest::CloseBrowserAndServer() { |
| 232 QuitBrowser(); | 228 QuitBrowser(); |
| 233 CleanupAppProcesses(); | 229 CleanupAppProcesses(); |
| 234 | 230 |
| 235 #if defined(OS_WIN) | |
| 236 // Shut down IPC testing interface. | 231 // Shut down IPC testing interface. |
| 237 server_.reset(); | 232 server_.reset(); |
| 238 #else | |
| 239 // TODO(port): depends on AutomationProxy. | |
| 240 NOTIMPLEMENTED(); | |
| 241 #endif | |
| 242 } | 233 } |
| 243 | 234 |
| 244 void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) { | 235 void UITest::LaunchBrowser(const CommandLine& arguments, bool clear_profile) { |
| 245 std::wstring command = browser_directory_; | 236 std::wstring command = browser_directory_; |
| 246 file_util::AppendToPath(&command, | 237 file_util::AppendToPath(&command, |
| 247 chrome::kBrowserProcessExecutableName); | 238 chrome::kBrowserProcessExecutableName); |
| 248 CommandLine command_line(command); | 239 CommandLine command_line(command); |
| 249 | 240 |
| 250 // Add any explict command line flags passed to the process. | 241 // Add any explict command line flags passed to the process. |
| 251 std::wstring extra_chrome_flags = | 242 std::wstring extra_chrome_flags = |
| 252 CommandLine::ForCurrentProcess()->GetSwitchValue(kExtraChromeFlagsSwitch); | 243 CommandLine::ForCurrentProcess()->GetSwitchValue(kExtraChromeFlagsSwitch); |
| 253 if (!extra_chrome_flags.empty()) { | 244 if (!extra_chrome_flags.empty()) { |
| 254 #if defined(OS_WIN) | 245 #if defined(OS_WIN) |
| 255 command_line.AppendLooseValue(extra_chrome_flags); | 246 command_line.AppendLooseValue(extra_chrome_flags); |
| 256 #else | 247 #else |
| 257 // TODO(port): figure out how to pass through extra flags via a string. | 248 // TODO(port): figure out how to pass through extra flags via a string. |
| 258 NOTIMPLEMENTED(); | 249 NOTIMPLEMENTED(); |
| 259 #endif | 250 #endif |
| 260 } | 251 } |
| 261 | 252 |
| 262 // We need cookies on file:// for things like the page cycler. | 253 // We need cookies on file:// for things like the page cycler. |
| 263 command_line.AppendSwitch(switches::kEnableFileCookies); | 254 command_line.AppendSwitch(switches::kEnableFileCookies); |
| 264 | 255 |
| 265 if (dom_automation_enabled_) | 256 if (dom_automation_enabled_) |
| 266 command_line.AppendSwitch(switches::kDomAutomationController); | 257 command_line.AppendSwitch(switches::kDomAutomationController); |
| 267 | 258 |
| 268 #if defined(OS_WIN) | |
| 269 if (include_testing_id_) { | 259 if (include_testing_id_) { |
| 270 if (use_existing_browser_) { | 260 if (use_existing_browser_) { |
| 271 // TODO(erikkay): The new switch depends on a browser instance already | 261 // TODO(erikkay): The new switch depends on a browser instance already |
| 272 // running, it won't open a new browser window if it's not. We could fix | 262 // running, it won't open a new browser window if it's not. We could fix |
| 273 // this by passing an url (e.g. about:blank) on the command line, but | 263 // this by passing an url (e.g. about:blank) on the command line, but |
| 274 // I decided to keep using the old switch in the existing use case to | 264 // I decided to keep using the old switch in the existing use case to |
| 275 // minimize changes in behavior. | 265 // minimize changes in behavior. |
| 276 command_line.AppendSwitchWithValue(switches::kAutomationClientChannelID, | 266 command_line.AppendSwitchWithValue(switches::kAutomationClientChannelID, |
| 277 server_->channel_id()); | 267 server_->channel_id()); |
| 278 } else { | 268 } else { |
| 279 command_line.AppendSwitchWithValue(switches::kTestingChannelID, | 269 command_line.AppendSwitchWithValue(switches::kTestingChannelID, |
| 280 server_->channel_id()); | 270 server_->channel_id()); |
| 281 } | 271 } |
| 282 } | 272 } |
| 283 #else | |
| 284 // TODO(port): depends on AutomationProxy. | |
| 285 NOTIMPLEMENTED(); | |
| 286 #endif | |
| 287 | 273 |
| 288 if (!show_error_dialogs_ && | 274 if (!show_error_dialogs_ && |
| 289 !CommandLine::ForCurrentProcess()->HasSwitch(kEnableErrorDialogs)) { | 275 !CommandLine::ForCurrentProcess()->HasSwitch(kEnableErrorDialogs)) { |
| 290 command_line.AppendSwitch(switches::kNoErrorDialogs); | 276 command_line.AppendSwitch(switches::kNoErrorDialogs); |
| 291 } | 277 } |
| 292 if (in_process_renderer_) | 278 if (in_process_renderer_) |
| 293 command_line.AppendSwitch(switches::kSingleProcess); | 279 command_line.AppendSwitch(switches::kSingleProcess); |
| 294 if (no_sandbox_) | 280 if (no_sandbox_) |
| 295 command_line.AppendSwitch(switches::kNoSandbox); | 281 command_line.AppendSwitch(switches::kNoSandbox); |
| 296 if (full_memory_dump_) | 282 if (full_memory_dump_) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // Clear user data directory to make sure test environment is consistent | 325 // Clear user data directory to make sure test environment is consistent |
| 340 // We balk on really short (absolute) user_data_dir directory names, because | 326 // We balk on really short (absolute) user_data_dir directory names, because |
| 341 // we're worried that they'd accidentally be root or something. | 327 // we're worried that they'd accidentally be root or something. |
| 342 ASSERT_LT(10, static_cast<int>(user_data_dir_.size())) << | 328 ASSERT_LT(10, static_cast<int>(user_data_dir_.size())) << |
| 343 "The user data directory name passed into this test was too " | 329 "The user data directory name passed into this test was too " |
| 344 "short to delete safely. Please check the user-data-dir " | 330 "short to delete safely. Please check the user-data-dir " |
| 345 "argument and try again."; | 331 "argument and try again."; |
| 346 if (clear_profile) | 332 if (clear_profile) |
| 347 ASSERT_TRUE(DieFileDie(user_data_dir_, true)); | 333 ASSERT_TRUE(DieFileDie(user_data_dir_, true)); |
| 348 | 334 |
| 349 #if defined(OS_WIN) | |
| 350 if (!template_user_data_.empty()) { | 335 if (!template_user_data_.empty()) { |
| 351 // Recursively copy the template directory to the user_data_dir. | 336 // Recursively copy the template directory to the user_data_dir. |
| 352 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache(template_user_data_, | 337 ASSERT_TRUE(file_util::CopyRecursiveDirNoCache(template_user_data_, |
| 353 user_data_dir_)); | 338 user_data_dir_)); |
| 354 } | 339 } |
| 355 | 340 |
| 356 browser_launch_time_ = TimeTicks::Now(); | 341 browser_launch_time_ = TimeTicks::Now(); |
| 357 | 342 |
| 343 #if defined(OS_WIN) |
| 358 bool started = base::LaunchApp(command_line, | 344 bool started = base::LaunchApp(command_line, |
| 359 false, // Don't wait for process object | 345 false, // Don't wait for process object |
| 360 // (doesn't work for us) | 346 // (doesn't work for us) |
| 361 !show_window_, | 347 !show_window_, |
| 362 &process_); | 348 &process_); |
| 363 ASSERT_EQ(started, true); | 349 #elif defined(OS_POSIX) |
| 350 bool started = base::LaunchApp(command_line.argv(), |
| 351 server_->fds_to_map(), |
| 352 false, // Don't wait. |
| 353 &process_); |
| 354 #endif |
| 355 ASSERT_TRUE(started); |
| 364 | 356 |
| 357 #if defined(OS_WIN) |
| 365 if (use_existing_browser_) { | 358 if (use_existing_browser_) { |
| 366 DWORD pid = 0; | 359 DWORD pid = 0; |
| 367 HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, | 360 HWND hwnd = FindWindowEx(HWND_MESSAGE, NULL, chrome::kMessageWindowClass, |
| 368 user_data_dir_.c_str()); | 361 user_data_dir_.c_str()); |
| 369 GetWindowThreadProcessId(hwnd, &pid); | 362 GetWindowThreadProcessId(hwnd, &pid); |
| 370 // This mode doesn't work if we wound up launching a new browser ourselves. | 363 // This mode doesn't work if we wound up launching a new browser ourselves. |
| 371 ASSERT_NE(pid, base::GetProcId(process_)); | 364 ASSERT_NE(pid, base::GetProcId(process_)); |
| 372 CloseHandle(process_); | 365 CloseHandle(process_); |
| 373 process_ = OpenProcess(SYNCHRONIZE, false, pid); | 366 process_ = OpenProcess(SYNCHRONIZE, false, pid); |
| 374 } | 367 } |
| 375 #else | 368 #else |
| 376 // TODO(port): above code is very Windows-specific; we need to | 369 // TODO(port): above code is very Windows-specific; we need to |
| 377 // figure out and abstract out how we'll handle finding any existing | 370 // figure out and abstract out how we'll handle finding any existing |
| 378 // running process, etc. on other platforms. | 371 // running process, etc. on other platforms. |
| 379 NOTIMPLEMENTED(); | 372 NOTIMPLEMENTED(); |
| 380 #endif | 373 #endif |
| 381 } | 374 } |
| 382 | 375 |
| 383 void UITest::QuitBrowser() { | 376 void UITest::QuitBrowser() { |
| 384 #if defined(OS_WIN) | |
| 385 typedef std::vector<BrowserProxy*> BrowserVector; | 377 typedef std::vector<BrowserProxy*> BrowserVector; |
| 386 | 378 |
| 387 // There's nothing to do here if the browser is not running. | 379 // There's nothing to do here if the browser is not running. |
| 388 if (IsBrowserRunning()) { | 380 if (IsBrowserRunning()) { |
| 389 automation()->SetFilteredInet(false); | 381 automation()->SetFilteredInet(false); |
| 390 BrowserVector browsers; | 382 BrowserVector browsers; |
| 391 | 383 |
| 392 // Build up a list of HWNDs; we do this as a separate step so that closing | 384 // Build up a list of HWNDs; we do this as a separate step so that closing |
| 393 // the windows doesn't mess up the iteration. | 385 // the windows doesn't mess up the iteration. |
| 394 int window_count = 0; | 386 int window_count = 0; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 409 // Now, drop the automation IPC channel so that the automation provider in | 401 // Now, drop the automation IPC channel so that the automation provider in |
| 410 // the browser notices and drops its reference to the browser process. | 402 // the browser notices and drops its reference to the browser process. |
| 411 server_->Disconnect(); | 403 server_->Disconnect(); |
| 412 | 404 |
| 413 // Wait for the browser process to quit. It should quit once all tabs have | 405 // Wait for the browser process to quit. It should quit once all tabs have |
| 414 // been closed. | 406 // been closed. |
| 415 int timeout = 5000; | 407 int timeout = 5000; |
| 416 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN | 408 #ifdef WAIT_FOR_DEBUGGER_ON_OPEN |
| 417 timeout = 500000; | 409 timeout = 500000; |
| 418 #endif | 410 #endif |
| 419 if (WAIT_TIMEOUT == WaitForSingleObject(process_, timeout)) { | 411 if (!base::WaitForSingleProcess(process_, timeout)) { |
| 420 // We need to force the browser to quit because it didn't quit fast | 412 // We need to force the browser to quit because it didn't quit fast |
| 421 // enough. Take no chance and kill every chrome processes. | 413 // enough. Take no chance and kill every chrome processes. |
| 422 CleanupAppProcesses(); | 414 CleanupAppProcesses(); |
| 423 } | 415 } |
| 424 } | 416 } |
| 425 | 417 |
| 426 // Don't forget to close the handle | 418 // Don't forget to close the handle |
| 427 CloseHandle(process_); | 419 base::CloseProcessHandle(process_); |
| 428 process_ = NULL; | 420 process_ = NULL; |
| 429 #else | |
| 430 // TODO(port): depends on AutomationProxy. | |
| 431 NOTIMPLEMENTED(); | |
| 432 #endif // OS_WIN | |
| 433 } | 421 } |
| 434 | 422 |
| 435 void UITest::AssertAppNotRunning(const std::wstring& error_message) { | 423 void UITest::AssertAppNotRunning(const std::wstring& error_message) { |
| 436 #if defined(OS_WIN) | 424 #if defined(OS_WIN) |
| 437 ASSERT_EQ(0, GetBrowserProcessCount()) << error_message; | 425 ASSERT_EQ(0, GetBrowserProcessCount()) << error_message; |
| 438 #else | 426 #else |
| 439 // TODO(port): depends on AutomationProxy. | 427 // TODO(port): Enable when chrome_process_filter is ported. |
| 440 NOTIMPLEMENTED(); | 428 NOTIMPLEMENTED(); |
| 441 #endif | 429 #endif |
| 442 } | 430 } |
| 443 | 431 |
| 444 void UITest::CleanupAppProcesses() { | 432 void UITest::CleanupAppProcesses() { |
| 445 #if defined(OS_WIN) | 433 #if defined(OS_WIN) |
| 446 BrowserProcessFilter filter(L""); | 434 BrowserProcessFilter filter(L""); |
| 447 | 435 |
| 448 // Make sure that no instances of the browser remain. | 436 // Make sure that no instances of the browser remain. |
| 449 const int kExitTimeoutMs = 5000; | 437 const int kExitTimeoutMs = 5000; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 551 |
| 564 std::wstring UITest::GetActiveTabTitle() { | 552 std::wstring UITest::GetActiveTabTitle() { |
| 565 std::wstring title; | 553 std::wstring title; |
| 566 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); | 554 scoped_ptr<TabProxy> tab_proxy(GetActiveTab()); |
| 567 if (!tab_proxy.get()) | 555 if (!tab_proxy.get()) |
| 568 return title; | 556 return title; |
| 569 | 557 |
| 570 EXPECT_TRUE(tab_proxy->GetTabTitle(&title)); | 558 EXPECT_TRUE(tab_proxy->GetTabTitle(&title)); |
| 571 return title; | 559 return title; |
| 572 } | 560 } |
| 561 #endif // defined(OS_WIN) |
| 573 | 562 |
| 574 bool UITest::IsBrowserRunning() { | 563 bool UITest::IsBrowserRunning() { |
| 575 return CrashAwareSleep(0); | 564 return CrashAwareSleep(0); |
| 576 } | 565 } |
| 577 | 566 |
| 578 bool UITest::CrashAwareSleep(int time_out_ms) { | 567 bool UITest::CrashAwareSleep(int time_out_ms) { |
| 579 return base::CrashAwareSleep(process_, time_out_ms); | 568 return base::CrashAwareSleep(process_, time_out_ms); |
| 580 } | 569 } |
| 581 | 570 |
| 571 #if defined(OS_WIN) |
| 572 // TODO(port): Port these. |
| 573 |
| 582 /*static*/ | 574 /*static*/ |
| 583 int UITest::GetBrowserProcessCount() { | 575 int UITest::GetBrowserProcessCount() { |
| 584 BrowserProcessFilter filter(L""); | 576 BrowserProcessFilter filter(L""); |
| 585 return base::GetProcessCount(chrome::kBrowserProcessExecutableName, | 577 return base::GetProcessCount(chrome::kBrowserProcessExecutableName, |
| 586 &filter); | 578 &filter); |
| 587 } | 579 } |
| 588 | 580 |
| 589 static DictionaryValue* LoadDictionaryValueFromPath(const std::wstring& path) { | 581 static DictionaryValue* LoadDictionaryValueFromPath(const std::wstring& path) { |
| 590 if (path.empty()) | 582 if (path.empty()) |
| 591 return NULL; | 583 return NULL; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 | 709 |
| 718 if (*application_closed) { | 710 if (*application_closed) { |
| 719 // Let's wait until the process dies (if it is not gone already). | 711 // Let's wait until the process dies (if it is not gone already). |
| 720 int r = WaitForSingleObject(process_, INFINITE); | 712 int r = WaitForSingleObject(process_, INFINITE); |
| 721 DCHECK(r != WAIT_FAILED); | 713 DCHECK(r != WAIT_FAILED); |
| 722 } | 714 } |
| 723 | 715 |
| 724 return result; | 716 return result; |
| 725 } | 717 } |
| 726 | 718 |
| 727 void UITest::PrintResult(const std::wstring& measurement, | |
| 728 const std::wstring& modifier, | |
| 729 const std::wstring& trace, | |
| 730 size_t value, | |
| 731 const std::wstring& units, | |
| 732 bool important) { | |
| 733 std::wstring value_str = StringPrintf(L"%d", value); | |
| 734 PrintResultsImpl(measurement, modifier, trace, value_str, | |
| 735 L"", L"", units, important); | |
| 736 } | |
| 737 | |
| 738 void UITest::PrintResultMeanAndError(const std::wstring& measurement, | |
| 739 const std::wstring& modifier, | |
| 740 const std::wstring& trace, | |
| 741 const std::wstring& mean_and_error, | |
| 742 const std::wstring& units, | |
| 743 bool important) { | |
| 744 PrintResultsImpl(measurement, modifier, trace, mean_and_error, | |
| 745 L"{", L"}", units, important); | |
| 746 } | |
| 747 | |
| 748 void UITest::PrintResultList(const std::wstring& measurement, | |
| 749 const std::wstring& modifier, | |
| 750 const std::wstring& trace, | |
| 751 const std::wstring& values, | |
| 752 const std::wstring& units, | |
| 753 bool important) { | |
| 754 PrintResultsImpl(measurement, modifier, trace, values, | |
| 755 L"[", L"]", units, important); | |
| 756 } | |
| 757 | |
| 758 GURL UITest::GetTestUrl(const std::wstring& test_directory, | 719 GURL UITest::GetTestUrl(const std::wstring& test_directory, |
| 759 const std::wstring &test_case) { | 720 const std::wstring &test_case) { |
| 760 std::wstring path; | 721 std::wstring path; |
| 761 PathService::Get(chrome::DIR_TEST_DATA, &path); | 722 PathService::Get(chrome::DIR_TEST_DATA, &path); |
| 762 file_util::AppendToPath(&path, test_directory); | 723 file_util::AppendToPath(&path, test_directory); |
| 763 file_util::AppendToPath(&path, test_case); | 724 file_util::AppendToPath(&path, test_case); |
| 764 return net::FilePathToFileURL(path); | 725 return net::FilePathToFileURL(path); |
| 765 } | 726 } |
| 766 | 727 |
| 767 void UITest::WaitForFinish(const std::string &name, | 728 void UITest::WaitForFinish(const std::string &name, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 784 | 745 |
| 785 scoped_ptr<TabProxy> tab(GetActiveTab()); | 746 scoped_ptr<TabProxy> tab(GetActiveTab()); |
| 786 | 747 |
| 787 bool test_result = WaitUntilCookieValue(tab.get(), url, | 748 bool test_result = WaitUntilCookieValue(tab.get(), url, |
| 788 cookie_name.c_str(), | 749 cookie_name.c_str(), |
| 789 kIntervalMilliSeconds, wait_time, | 750 kIntervalMilliSeconds, wait_time, |
| 790 expected_cookie_value.c_str()); | 751 expected_cookie_value.c_str()); |
| 791 EXPECT_EQ(true, test_result); | 752 EXPECT_EQ(true, test_result); |
| 792 } | 753 } |
| 793 | 754 |
| 755 #endif // OS_WIN |
| 756 |
| 757 void UITest::PrintResult(const std::wstring& measurement, |
| 758 const std::wstring& modifier, |
| 759 const std::wstring& trace, |
| 760 size_t value, |
| 761 const std::wstring& units, |
| 762 bool important) { |
| 763 std::wstring value_str = StringPrintf(L"%d", value); |
| 764 PrintResultsImpl(measurement, modifier, trace, value_str, |
| 765 L"", L"", units, important); |
| 766 } |
| 767 |
| 768 void UITest::PrintResultMeanAndError(const std::wstring& measurement, |
| 769 const std::wstring& modifier, |
| 770 const std::wstring& trace, |
| 771 const std::wstring& mean_and_error, |
| 772 const std::wstring& units, |
| 773 bool important) { |
| 774 PrintResultsImpl(measurement, modifier, trace, mean_and_error, |
| 775 L"{", L"}", units, important); |
| 776 } |
| 777 |
| 778 void UITest::PrintResultList(const std::wstring& measurement, |
| 779 const std::wstring& modifier, |
| 780 const std::wstring& trace, |
| 781 const std::wstring& values, |
| 782 const std::wstring& units, |
| 783 bool important) { |
| 784 PrintResultsImpl(measurement, modifier, trace, values, |
| 785 L"[", L"]", units, important); |
| 786 } |
| 787 |
| 794 void UITest::PrintResultsImpl(const std::wstring& measurement, | 788 void UITest::PrintResultsImpl(const std::wstring& measurement, |
| 795 const std::wstring& modifier, | 789 const std::wstring& modifier, |
| 796 const std::wstring& trace, | 790 const std::wstring& trace, |
| 797 const std::wstring& values, | 791 const std::wstring& values, |
| 798 const std::wstring& prefix, | 792 const std::wstring& prefix, |
| 799 const std::wstring& suffix, | 793 const std::wstring& suffix, |
| 800 const std::wstring& units, | 794 const std::wstring& units, |
| 801 bool important) { | 795 bool important) { |
| 802 // <*>RESULT <graph_name>: <trace_name>= <value> <units> | 796 // <*>RESULT <graph_name>: <trace_name>= <value> <units> |
| 803 // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units> | 797 // <*>RESULT <graph_name>: <trace_name>= {<mean>, <std deviation>} <units> |
| 804 // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units> | 798 // <*>RESULT <graph_name>: <trace_name>= [<value>,value,value,...,] <units> |
| 805 wprintf(L"%lsRESULT %ls%ls: %ls= %ls%ls%ls %ls\n", | 799 wprintf(L"%lsRESULT %ls%ls: %ls= %ls%ls%ls %ls\n", |
| 806 important ? L"*" : L"", measurement.c_str(), modifier.c_str(), | 800 important ? L"*" : L"", measurement.c_str(), modifier.c_str(), |
| 807 trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(), | 801 trace.c_str(), prefix.c_str(), values.c_str(), suffix.c_str(), |
| 808 units.c_str()); | 802 units.c_str()); |
| 809 } | 803 } |
| 810 | |
| 811 #endif // OS_WIN | |
| OLD | NEW |