| 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 "ipc/ipc_channel.h" |
| 29 #include "ipc/ipc_descriptors.h" |
| 29 #include "sql/connection.h" | 30 #include "sql/connection.h" |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 // Passed as value of kTestType. | 34 // Passed as value of kTestType. |
| 34 const char kUITestType[] = "ui"; | 35 const char kUITestType[] = "ui"; |
| 35 | 36 |
| 36 // We want to have a current history database when we start the browser so | 37 // We want to have a current history database when we start the browser so |
| 37 // things like the NTP will have thumbnails. This method updates the dates | 38 // things like the NTP will have thumbnails. This method updates the dates |
| 38 // in the history to be more recent. | 39 // in the history to be more recent. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 << "Error while awaiting automation ping from browser process"; | 103 << "Error while awaiting automation ping from browser process"; |
| 103 if (app_launched != AUTOMATION_SUCCESS) | 104 if (app_launched != AUTOMATION_SUCCESS) |
| 104 return false; | 105 return false; |
| 105 | 106 |
| 106 if (wait_for_initial_loads) { | 107 if (wait_for_initial_loads) { |
| 107 if (!automation_proxy_->WaitForInitialLoads()) { | 108 if (!automation_proxy_->WaitForInitialLoads()) { |
| 108 LOG(ERROR) << "WaitForInitialLoads failed."; | 109 LOG(ERROR) << "WaitForInitialLoads failed."; |
| 109 return false; | 110 return false; |
| 110 } | 111 } |
| 111 } else { | 112 } else { |
| 112 // TODO(phajdan.jr): We should get rid of this sleep, but some tests | 113 #if defined(OS_WIN) |
| 113 // "rely" on it, e.g. AssertionTest.Assertion and CheckFalseTest.CheckFails. | 114 // TODO(phajdan.jr): Get rid of this Sleep when logging_chrome_uitest |
| 114 // Those tests do not wait in any way until the crash gets noticed, | 115 // stops "relying" on it. |
| 115 // so it's possible for the browser to exit before the tested crash happens. | |
| 116 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); | 116 base::PlatformThread::Sleep(TestTimeouts::action_timeout_ms()); |
| 117 #endif |
| 117 } | 118 } |
| 118 | 119 |
| 119 if (!automation()->SetFilteredInet(ShouldFilterInet())) { | 120 if (!automation()->SetFilteredInet(ShouldFilterInet())) { |
| 120 LOG(ERROR) << "SetFilteredInet failed."; | 121 LOG(ERROR) << "SetFilteredInet failed."; |
| 121 return false; | 122 return false; |
| 122 } | 123 } |
| 123 | 124 |
| 124 return true; | 125 return true; |
| 125 } | 126 } |
| 126 | 127 |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 | 461 |
| 461 // TODO(phajdan.jr): Only run it for "main" browser launch. | 462 // TODO(phajdan.jr): Only run it for "main" browser launch. |
| 462 browser_launch_time_ = base::TimeTicks::Now(); | 463 browser_launch_time_ = base::TimeTicks::Now(); |
| 463 | 464 |
| 464 base::LaunchOptions options; | 465 base::LaunchOptions options; |
| 465 options.wait = wait; | 466 options.wait = wait; |
| 466 | 467 |
| 467 #if defined(OS_WIN) | 468 #if defined(OS_WIN) |
| 468 options.start_hidden = !state.show_window; | 469 options.start_hidden = !state.show_window; |
| 469 #elif defined(OS_POSIX) | 470 #elif defined(OS_POSIX) |
| 471 int ipcfd = -1; |
| 472 file_util::ScopedFD ipcfd_closer(&ipcfd); |
| 473 |
| 470 base::file_handle_mapping_vector fds; | 474 base::file_handle_mapping_vector fds; |
| 471 if (automation_proxy_.get()) | 475 if (automation_proxy_.get()) { |
| 472 fds = automation_proxy_->fds_to_map(); | 476 ipcfd = automation_proxy_->TakeClientFileDescriptor(); |
| 477 fds.push_back(std::make_pair(ipcfd, kPrimaryIPCChannel + 3)); |
| 478 } |
| 473 options.fds_to_remap = &fds; | 479 options.fds_to_remap = &fds; |
| 474 #endif | 480 #endif |
| 475 | 481 |
| 476 return base::LaunchProcess(command_line, options, process); | 482 return base::LaunchProcess(command_line, options, process); |
| 477 } | 483 } |
| 478 | 484 |
| 479 AutomationProxy* ProxyLauncher::automation() const { | 485 AutomationProxy* ProxyLauncher::automation() const { |
| 480 EXPECT_TRUE(automation_proxy_.get()); | 486 EXPECT_TRUE(automation_proxy_.get()); |
| 481 return automation_proxy_.get(); | 487 return automation_proxy_.get(); |
| 482 } | 488 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 return LaunchBrowserAndServer(state, wait_for_initial_loads); | 599 return LaunchBrowserAndServer(state, wait_for_initial_loads); |
| 594 } | 600 } |
| 595 | 601 |
| 596 void AnonymousProxyLauncher::TerminateConnection() { | 602 void AnonymousProxyLauncher::TerminateConnection() { |
| 597 CloseBrowserAndServer(); | 603 CloseBrowserAndServer(); |
| 598 } | 604 } |
| 599 | 605 |
| 600 std::string AnonymousProxyLauncher::PrefixedChannelID() const { | 606 std::string AnonymousProxyLauncher::PrefixedChannelID() const { |
| 601 return channel_id_; | 607 return channel_id_; |
| 602 } | 608 } |
| OLD | NEW |