| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/media/webrtc_browsertest_common.h" | 5 #include "chrome/browser/media/webrtc_browsertest_common.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 8 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 9 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 10 #include "base/process/launch.h" | |
| 11 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 12 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
| 13 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_tabstrip.h" |
| 16 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 17 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
| 18 | 16 |
| 19 namespace test { | 17 namespace test { |
| 20 | 18 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 LOG(ERROR) << "Failed to sleep."; | 125 LOG(ERROR) << "Failed to sleep."; |
| 128 } | 126 } |
| 129 } | 127 } |
| 130 LOG(ERROR) | 128 LOG(ERROR) |
| 131 << "Timed out while waiting for " << javascript | 129 << "Timed out while waiting for " << javascript |
| 132 << " to evaluate to " << evaluates_to << "; last result was '" << result | 130 << " to evaluate to " << evaluates_to << "; last result was '" << result |
| 133 << "'"; | 131 << "'"; |
| 134 return false; | 132 return false; |
| 135 } | 133 } |
| 136 | 134 |
| 137 static base::FilePath::CharType kServerExecutable[] = | |
| 138 #if defined(OS_WIN) | |
| 139 FILE_PATH_LITERAL("peerconnection_server.exe"); | |
| 140 #else | |
| 141 FILE_PATH_LITERAL("peerconnection_server"); | |
| 142 #endif | |
| 143 | |
| 144 const char PeerConnectionServerRunner::kDefaultPort[] = "7778"; | |
| 145 | |
| 146 bool PeerConnectionServerRunner::Start() { | |
| 147 base::FilePath peerconnection_server; | |
| 148 if (!PathService::Get(base::DIR_MODULE, &peerconnection_server)) { | |
| 149 LOG(ERROR) << "Failed retrieving base::DIR_MODULE!"; | |
| 150 return false; | |
| 151 } | |
| 152 peerconnection_server = peerconnection_server.Append(kServerExecutable); | |
| 153 | |
| 154 if (!base::PathExists(peerconnection_server)) { | |
| 155 LOG(ERROR) | |
| 156 << "Missing " << kServerExecutable << ". You must build " | |
| 157 << "it so it ends up next to the browser test binary."; | |
| 158 return false; | |
| 159 } | |
| 160 | |
| 161 CommandLine command_line(peerconnection_server); | |
| 162 command_line.AppendSwitchASCII("port", kDefaultPort); | |
| 163 VLOG(0) << "Running " << command_line.GetCommandLineString(); | |
| 164 return base::LaunchProcess(command_line, | |
| 165 base::LaunchOptions(), | |
| 166 &server_pid_); | |
| 167 } | |
| 168 | |
| 169 bool PeerConnectionServerRunner::Stop() { | |
| 170 return base::KillProcess(server_pid_, 0, false); | |
| 171 } | |
| 172 | |
| 173 void PeerConnectionServerRunner::KillAllPeerConnectionServers() { | |
| 174 if (!base::KillProcesses(kServerExecutable, -1, NULL)) { | |
| 175 LOG(ERROR) << "Failed to kill instances of " << kServerExecutable << "."; | |
| 176 return; | |
| 177 } | |
| 178 base::WaitForProcessesToExit(kServerExecutable, | |
| 179 base::TimeDelta::FromSeconds(5), NULL); | |
| 180 } | |
| 181 | |
| 182 } // namespace test | 135 } // namespace test |
| OLD | NEW |