Chromium Code Reviews| 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/automation/proxy_launcher.h" | 5 #include "chrome/test/automation/proxy_launcher.h" |
| 6 | 6 |
| 7 #include "app/sql/connection.h" | 7 #include "app/sql/connection.h" |
| 8 #include "base/environment.h" | 8 #include "base/environment.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
| 11 #include "base/string_split.h" | 11 #include "base/string_split.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/test/test_file_util.h" | 13 #include "base/test/test_file_util.h" |
| 14 #include "base/test/test_timeouts.h" | 14 #include "base/test/test_timeouts.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/app/chrome_command_ids.h" | 16 #include "chrome/app/chrome_command_ids.h" |
| 17 #include "chrome/common/automation_constants.h" | 17 #include "chrome/common/automation_constants.h" |
| 18 #include "chrome/common/chrome_constants.h" | 18 #include "chrome/common/chrome_constants.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/logging_chrome.h" | 20 #include "chrome/common/logging_chrome.h" |
| 21 #include "chrome/common/url_constants.h" | 21 #include "chrome/common/url_constants.h" |
| 22 #include "chrome/test/chrome_process_util.h" | 22 #include "chrome/test/chrome_process_util.h" |
| 23 #include "chrome/test/test_launcher_utils.h" | 23 #include "chrome/test/test_launcher_utils.h" |
| 24 #include "chrome/test/test_switches.h" | 24 #include "chrome/test/test_switches.h" |
| 25 #include "chrome/test/automation/automation_proxy.h" | 25 #include "chrome/test/automation/automation_proxy.h" |
| 26 #include "chrome/test/ui/ui_test.h" | 26 #include "chrome/test/ui/ui_test.h" |
| 27 #include "content/common/child_process_info.h" | 27 #include "content/common/child_process_info.h" |
| 28 #include "content/common/debug_flags.h" | 28 #include "content/common/debug_flags.h" |
| 29 #include "ipc/ipc_channel_win.h" | |
| 30 | |
| 31 #if defined(OS_WIN) | |
| 32 #include <windows.h> | |
| 33 #endif | |
| 29 | 34 |
| 30 namespace { | 35 namespace { |
| 31 | 36 |
| 32 // Passed as value of kTestType. | 37 // Passed as value of kTestType. |
| 33 const char kUITestType[] = "ui"; | 38 const char kUITestType[] = "ui"; |
| 34 | 39 |
| 35 // We want to have a current history database when we start the browser so | 40 // We want to have a current history database when we start the browser so |
| 36 // things like the NTP will have thumbnails. This method updates the dates | 41 // things like the NTP will have thumbnails. This method updates the dates |
| 37 // in the history to be more recent. | 42 // in the history to be more recent. |
| 38 void UpdateHistoryDates(const FilePath& user_data_dir) { | 43 void UpdateHistoryDates(const FilePath& user_data_dir) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 55 yesterday_str.c_str()); | 60 yesterday_str.c_str()); |
| 56 ASSERT_TRUE(db.Execute(query.c_str())); | 61 ASSERT_TRUE(db.Execute(query.c_str())); |
| 57 db.Close(); | 62 db.Close(); |
| 58 file_util::EvictFileFromSystemCache(history); | 63 file_util::EvictFileFromSystemCache(history); |
| 59 } | 64 } |
| 60 | 65 |
| 61 } // namespace | 66 } // namespace |
| 62 | 67 |
| 63 // ProxyLauncher functions | 68 // ProxyLauncher functions |
| 64 | 69 |
| 65 const char ProxyLauncher::kDefaultInterfacePath[] = | 70 #if defined(OS_WIN) |
| 71 const char ProxyLauncher::kDefaultInterfaceId[] = "ChromeTestingInterface"; | |
| 72 #elif defined(OS_POSIX) | |
| 73 const char ProxyLauncher::kDefaultInterfaceId[] = | |
| 66 "/var/tmp/ChromeTestingInterface"; | 74 "/var/tmp/ChromeTestingInterface"; |
| 75 #endif | |
| 67 | 76 |
| 68 bool ProxyLauncher::in_process_renderer_ = false; | 77 bool ProxyLauncher::in_process_renderer_ = false; |
| 69 bool ProxyLauncher::no_sandbox_ = false; | 78 bool ProxyLauncher::no_sandbox_ = false; |
| 70 bool ProxyLauncher::full_memory_dump_ = false; | 79 bool ProxyLauncher::full_memory_dump_ = false; |
| 71 bool ProxyLauncher::show_error_dialogs_ = true; | 80 bool ProxyLauncher::show_error_dialogs_ = true; |
| 72 bool ProxyLauncher::dump_histograms_on_exit_ = false; | 81 bool ProxyLauncher::dump_histograms_on_exit_ = false; |
| 73 bool ProxyLauncher::enable_dcheck_ = false; | 82 bool ProxyLauncher::enable_dcheck_ = false; |
| 74 bool ProxyLauncher::silent_dump_on_dcheck_ = false; | 83 bool ProxyLauncher::silent_dump_on_dcheck_ = false; |
| 75 bool ProxyLauncher::disable_breakpad_ = false; | 84 bool ProxyLauncher::disable_breakpad_ = false; |
| 76 std::string ProxyLauncher::js_flags_ = ""; | 85 std::string ProxyLauncher::js_flags_ = ""; |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 505 AutomationProxy* NamedProxyLauncher::CreateAutomationProxy( | 514 AutomationProxy* NamedProxyLauncher::CreateAutomationProxy( |
| 506 int execution_timeout) { | 515 int execution_timeout) { |
| 507 AutomationProxy* proxy = new AutomationProxy(execution_timeout, | 516 AutomationProxy* proxy = new AutomationProxy(execution_timeout, |
| 508 disconnect_on_failure_); | 517 disconnect_on_failure_); |
| 509 proxy->InitializeChannel(channel_id_, true); | 518 proxy->InitializeChannel(channel_id_, true); |
| 510 return proxy; | 519 return proxy; |
| 511 } | 520 } |
| 512 | 521 |
| 513 void NamedProxyLauncher::InitializeConnection(const LaunchState& state, | 522 void NamedProxyLauncher::InitializeConnection(const LaunchState& state, |
| 514 bool wait_for_initial_loads) { | 523 bool wait_for_initial_loads) { |
| 515 FilePath testing_channel_path; | |
| 516 #if defined(OS_WIN) | |
| 517 testing_channel_path = FilePath(ASCIIToWide(channel_id_)); | |
| 518 #else | |
| 519 testing_channel_path = FilePath(channel_id_); | |
| 520 #endif | |
| 521 | |
| 522 if (launch_browser_) { | 524 if (launch_browser_) { |
| 525 #if defined(OS_POSIX) | |
| 523 // Because we are waiting on the existence of the testing file below, | 526 // Because we are waiting on the existence of the testing file below, |
| 524 // make sure there isn't one already there before browser launch. | 527 // make sure there isn't one already there before browser launch. |
| 525 EXPECT_TRUE(file_util::Delete(testing_channel_path, false)); | 528 EXPECT_TRUE(file_util::Delete(FilePath(channel_id_), false)); |
| 529 #endif | |
| 526 | 530 |
| 527 // Set up IPC testing interface as a client. | 531 // Set up IPC testing interface as a client. |
| 528 ASSERT_TRUE(LaunchBrowser(state)); | 532 ASSERT_TRUE(LaunchBrowser(state)); |
| 529 } | 533 } |
| 530 | 534 |
| 531 // Wait for browser to be ready for connections. | 535 // Wait for browser to be ready for connections. |
| 536 const int kPollIntervalMs = 50; | |
| 532 bool testing_channel_exists = false; | 537 bool testing_channel_exists = false; |
| 533 for (int wait_time = 0; | 538 for (int wait_time = 0; |
| 534 wait_time < TestTimeouts::action_max_timeout_ms(); | 539 wait_time < TestTimeouts::action_max_timeout_ms(); |
| 535 wait_time += automation::kSleepTime) { | 540 wait_time += kPollIntervalMs) { |
| 536 testing_channel_exists = file_util::PathExists(testing_channel_path); | 541 #if defined(OS_WIN) |
| 542 testing_channel_exists = WaitNamedPipe( | |
| 543 IPC::PipeNameFromChannelId(channel_id_).c_str(), | |
| 544 1); | |
|
dmac
2011/08/02 00:32:14
on Windows does it not make more sense just to cal
kkania
2011/08/02 15:00:58
WaitNamedPipe on windows returns immediately if th
| |
| 545 #elif defined(OS_POSIX) | |
| 546 testing_channel_exists = file_util::PathExists(FilePath(channel_id_)); | |
| 547 #endif | |
| 537 if (testing_channel_exists) | 548 if (testing_channel_exists) |
| 538 break; | 549 break; |
| 539 base::PlatformThread::Sleep(automation::kSleepTime); | 550 base::PlatformThread::Sleep(kPollIntervalMs); |
| 540 } | 551 } |
| 541 EXPECT_TRUE(testing_channel_exists); | 552 EXPECT_TRUE(testing_channel_exists); |
| 542 | 553 |
| 543 ASSERT_TRUE(ConnectToRunningBrowser(wait_for_initial_loads)); | 554 ASSERT_TRUE(ConnectToRunningBrowser(wait_for_initial_loads)); |
| 544 } | 555 } |
| 545 | 556 |
| 546 void NamedProxyLauncher::TerminateConnection() { | 557 void NamedProxyLauncher::TerminateConnection() { |
| 547 if (launch_browser_) | 558 if (launch_browser_) |
| 548 CloseBrowserAndServer(); | 559 CloseBrowserAndServer(); |
| 549 else | 560 else |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 576 ASSERT_TRUE(LaunchBrowserAndServer(state, wait_for_initial_loads)); | 587 ASSERT_TRUE(LaunchBrowserAndServer(state, wait_for_initial_loads)); |
| 577 } | 588 } |
| 578 | 589 |
| 579 void AnonymousProxyLauncher::TerminateConnection() { | 590 void AnonymousProxyLauncher::TerminateConnection() { |
| 580 CloseBrowserAndServer(); | 591 CloseBrowserAndServer(); |
| 581 } | 592 } |
| 582 | 593 |
| 583 std::string AnonymousProxyLauncher::PrefixedChannelID() const { | 594 std::string AnonymousProxyLauncher::PrefixedChannelID() const { |
| 584 return channel_id_; | 595 return channel_id_; |
| 585 } | 596 } |
| OLD | NEW |