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