| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/json/json_reader.h" | |
| 7 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | |
| 9 #include "base/test/trace_event_analyzer.h" | |
| 10 #include "base/values.h" | 7 #include "base/values.h" |
| 11 #include "content/browser/media/webrtc_internals.h" | 8 #include "content/browser/media/webrtc_internals.h" |
| 12 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 13 #include "content/public/common/content_switches.h" | 10 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/test/browser_test_utils.h" | 11 #include "content/public/test/browser_test_utils.h" |
| 15 #include "content/public/test/test_utils.h" | 12 #include "content/public/test/test_utils.h" |
| 16 #include "content/shell/browser/shell.h" | 13 #include "content/shell/browser/shell.h" |
| 17 #include "content/test/content_browser_test.h" | |
| 18 #include "content/test/content_browser_test_utils.h" | 14 #include "content/test/content_browser_test_utils.h" |
| 15 #include "content/test/webrtc_content_browsertest_base.h" |
| 19 #include "media/audio/audio_manager.h" | 16 #include "media/audio/audio_manager.h" |
| 20 #include "net/test/embedded_test_server/embedded_test_server.h" | 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 21 #include "testing/perf/perf_test.h" | |
| 22 | 18 |
| 23 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 24 #include "base/win/windows_version.h" | 20 #include "base/win/windows_version.h" |
| 25 #endif | 21 #endif |
| 26 | 22 |
| 27 using trace_analyzer::TraceAnalyzer; | |
| 28 using trace_analyzer::Query; | |
| 29 using trace_analyzer::TraceEventVector; | |
| 30 | |
| 31 namespace { | |
| 32 | |
| 33 static const char kGetUserMediaAndStop[] = "getUserMediaAndStop"; | |
| 34 static const char kGetUserMediaAndWaitAndStop[] = "getUserMediaAndWaitAndStop"; | |
| 35 static const char kGetUserMediaAndAnalyseAndStop[] = | |
| 36 "getUserMediaAndAnalyseAndStop"; | |
| 37 | |
| 38 // Results returned by JS. | |
| 39 static const char kOK[] = "OK"; | |
| 40 static const char kGetUserMediaFailed[] = | |
| 41 "GetUserMedia call failed with code undefined"; | |
| 42 | |
| 43 std::string GenerateGetUserMediaCall(const char* function_name, | |
| 44 int min_width, | |
| 45 int max_width, | |
| 46 int min_height, | |
| 47 int max_height, | |
| 48 int min_frame_rate, | |
| 49 int max_frame_rate) { | |
| 50 return base::StringPrintf( | |
| 51 "%s({video: {mandatory: {minWidth: %d, maxWidth: %d, " | |
| 52 "minHeight: %d, maxHeight: %d, minFrameRate: %d, maxFrameRate: %d}, " | |
| 53 "optional: []}});", | |
| 54 function_name, | |
| 55 min_width, | |
| 56 max_width, | |
| 57 min_height, | |
| 58 max_height, | |
| 59 min_frame_rate, | |
| 60 max_frame_rate); | |
| 61 } | |
| 62 | |
| 63 std::string GenerateGetUserMediaWithMandatorySourceID( | |
| 64 const std::string& function_name, | |
| 65 const std::string& audio_source_id, | |
| 66 const std::string& video_source_id) { | |
| 67 const std::string audio_constraint = | |
| 68 "audio: {mandatory: { sourceId:\"" + audio_source_id + "\"}}, "; | |
| 69 | |
| 70 const std::string video_constraint = | |
| 71 "video: {mandatory: { sourceId:\"" + video_source_id + "\"}}"; | |
| 72 return function_name + "({" + audio_constraint + video_constraint + "});"; | |
| 73 } | |
| 74 | |
| 75 std::string GenerateGetUserMediaWithOptionalSourceID( | |
| 76 const std::string& function_name, | |
| 77 const std::string& audio_source_id, | |
| 78 const std::string& video_source_id) { | |
| 79 const std::string audio_constraint = | |
| 80 "audio: {optional: [{sourceId:\"" + audio_source_id + "\"}]}, "; | |
| 81 | |
| 82 const std::string video_constraint = | |
| 83 "video: {optional: [{ sourceId:\"" + video_source_id + "\"}]}"; | |
| 84 return function_name + "({" + audio_constraint + video_constraint + "});"; | |
| 85 } | |
| 86 | |
| 87 } | |
| 88 | |
| 89 namespace content { | 23 namespace content { |
| 90 | 24 |
| 91 class WebrtcBrowserTest: public ContentBrowserTest { | 25 class WebRtcBrowserTest : public WebRtcContentBrowserTest { |
| 92 public: | 26 public: |
| 93 WebrtcBrowserTest() : trace_log_(NULL) {} | 27 WebRtcBrowserTest() {} |
| 94 virtual ~WebrtcBrowserTest() {} | 28 virtual ~WebRtcBrowserTest() {} |
| 95 | |
| 96 virtual void SetUp() OVERRIDE { | |
| 97 // These tests require pixel output. | |
| 98 UseRealGLContexts(); | |
| 99 ContentBrowserTest::SetUp(); | |
| 100 } | |
| 101 | |
| 102 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
| 103 // We need fake devices in this test since we want to run on naked VMs. We | |
| 104 // assume these switches are set by default in content_browsertests. | |
| 105 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | |
| 106 switches::kUseFakeDeviceForMediaStream)); | |
| 107 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | |
| 108 switches::kUseFakeUIForMediaStream)); | |
| 109 } | |
| 110 | |
| 111 void StartTracing() { | |
| 112 CHECK(trace_log_ == NULL) << "Can only can start tracing once"; | |
| 113 trace_log_ = base::debug::TraceLog::GetInstance(); | |
| 114 trace_log_->SetEnabled(base::debug::CategoryFilter("video"), | |
| 115 base::debug::TraceLog::RECORDING_MODE, | |
| 116 base::debug::TraceLog::ENABLE_SAMPLING); | |
| 117 // Check that we are indeed recording. | |
| 118 EXPECT_EQ(trace_log_->GetNumTracesRecorded(), 1); | |
| 119 } | |
| 120 | |
| 121 void StopTracing() { | |
| 122 CHECK(message_loop_runner_ == NULL) << "Calling StopTracing more than once"; | |
| 123 trace_log_->SetDisabled(); | |
| 124 message_loop_runner_ = new MessageLoopRunner; | |
| 125 trace_log_->Flush(base::Bind(&WebrtcBrowserTest::OnTraceDataCollected, | |
| 126 base::Unretained(this))); | |
| 127 message_loop_runner_->Run(); | |
| 128 } | |
| 129 | |
| 130 void OnTraceDataCollected( | |
| 131 const scoped_refptr<base::RefCountedString>& events_str_ptr, | |
| 132 bool has_more_events) { | |
| 133 CHECK(!has_more_events); | |
| 134 recorded_trace_data_ = events_str_ptr; | |
| 135 message_loop_runner_->Quit(); | |
| 136 } | |
| 137 | |
| 138 TraceAnalyzer* CreateTraceAnalyzer() { | |
| 139 return TraceAnalyzer::Create("[" + recorded_trace_data_->data() + "]"); | |
| 140 } | |
| 141 | |
| 142 void GetSources(std::vector<std::string>* audio_ids, | |
| 143 std::vector<std::string>* video_ids) { | |
| 144 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 145 NavigateToURL(shell(), url); | |
| 146 | |
| 147 std::string sources_as_json = ExecuteJavascriptAndReturnResult( | |
| 148 "getSources()"); | |
| 149 EXPECT_FALSE(sources_as_json.empty()); | |
| 150 | |
| 151 int error_code; | |
| 152 std::string error_message; | |
| 153 scoped_ptr<base::Value> value( | |
| 154 base::JSONReader::ReadAndReturnError(sources_as_json, | |
| 155 base::JSON_ALLOW_TRAILING_COMMAS, | |
| 156 &error_code, | |
| 157 &error_message)); | |
| 158 | |
| 159 ASSERT_TRUE(value.get() != NULL) << error_message; | |
| 160 EXPECT_EQ(value->GetType(), base::Value::TYPE_LIST); | |
| 161 | |
| 162 base::ListValue* values; | |
| 163 ASSERT_TRUE(value->GetAsList(&values)); | |
| 164 | |
| 165 for (base::ListValue::iterator it = values->begin(); | |
| 166 it != values->end(); ++it) { | |
| 167 const base::DictionaryValue* dict; | |
| 168 std::string kind; | |
| 169 std::string id; | |
| 170 ASSERT_TRUE((*it)->GetAsDictionary(&dict)); | |
| 171 ASSERT_TRUE(dict->GetString("kind", &kind)); | |
| 172 ASSERT_TRUE(dict->GetString("id", &id)); | |
| 173 ASSERT_FALSE(id.empty()); | |
| 174 EXPECT_TRUE(kind == "audio" || kind == "video"); | |
| 175 if (kind == "audio") { | |
| 176 audio_ids->push_back(id); | |
| 177 } else if (kind == "video") { | |
| 178 video_ids->push_back(id); | |
| 179 } | |
| 180 } | |
| 181 ASSERT_FALSE(audio_ids->empty()); | |
| 182 ASSERT_FALSE(video_ids->empty()); | |
| 183 } | |
| 184 | |
| 185 protected: | |
| 186 bool ExecuteJavascript(const std::string& javascript) { | |
| 187 return ExecuteScript(shell()->web_contents(), javascript); | |
| 188 } | |
| 189 | |
| 190 // Executes |javascript|. The script is required to use | |
| 191 // window.domAutomationController.send to send a string value back to here. | |
| 192 std::string ExecuteJavascriptAndReturnResult(const std::string& javascript) { | |
| 193 std::string result; | |
| 194 EXPECT_TRUE(ExecuteScriptAndExtractString(shell()->web_contents(), | |
| 195 javascript, | |
| 196 &result)); | |
| 197 return result; | |
| 198 } | |
| 199 | |
| 200 void ExpectTitle(const std::string& expected_title) const { | |
| 201 base::string16 expected_title16(base::ASCIIToUTF16(expected_title)); | |
| 202 TitleWatcher title_watcher(shell()->web_contents(), expected_title16); | |
| 203 EXPECT_EQ(expected_title16, title_watcher.WaitAndGetTitle()); | |
| 204 } | |
| 205 | 29 |
| 206 // Convenience function since most peerconnection-call.html tests just load | 30 // Convenience function since most peerconnection-call.html tests just load |
| 207 // the page, kick off some javascript and wait for the title to change to OK. | 31 // the page, kick off some javascript and wait for the title to change to OK. |
| 208 void MakeTypicalPeerConnectionCall(const std::string& javascript) { | 32 void MakeTypicalPeerConnectionCall(const std::string& javascript) { |
| 209 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 33 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 210 | 34 |
| 211 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); | 35 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); |
| 212 NavigateToURL(shell(), url); | 36 NavigateToURL(shell(), url); |
| 213 ExecuteTestAndWaitForOk(javascript); | 37 ExecuteTestAndWaitForOk(javascript); |
| 214 } | 38 } |
| 215 | 39 |
| 216 void ExecuteTestAndWaitForOk(const std::string& javascript) { | 40 void ExecuteTestAndWaitForOk(const std::string& javascript) { |
| 217 #if defined (OS_ANDROID) | 41 #if defined (OS_ANDROID) |
| 218 // Always force iSAC 16K on Android for now (Opus is broken). | 42 // Always force iSAC 16K on Android for now (Opus is broken). |
| 219 ASSERT_TRUE(ExecuteJavascript("forceIsac16KInSdp();")); | 43 ASSERT_TRUE(ExecuteJavascript("forceIsac16KInSdp();")); |
| 220 #endif | 44 #endif |
| 221 | 45 |
| 222 ASSERT_TRUE(ExecuteJavascript(javascript)); | 46 ASSERT_TRUE(ExecuteJavascript(javascript)); |
| 223 ExpectTitle("OK"); | 47 ExpectTitle("OK"); |
| 224 } | 48 } |
| 225 | |
| 226 private: | |
| 227 base::debug::TraceLog* trace_log_; | |
| 228 scoped_refptr<base::RefCountedString> recorded_trace_data_; | |
| 229 scoped_refptr<MessageLoopRunner> message_loop_runner_; | |
| 230 }; | 49 }; |
| 231 | 50 |
| 232 // These tests will all make a getUserMedia call with different constraints and | |
| 233 // see that the success callback is called. If the error callback is called or | |
| 234 // none of the callbacks are called the tests will simply time out and fail. | |
| 235 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetVideoStreamAndStop) { | |
| 236 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 237 | |
| 238 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 239 NavigateToURL(shell(), url); | |
| 240 | |
| 241 ASSERT_TRUE(ExecuteJavascript( | |
| 242 base::StringPrintf("%s({video: true});", kGetUserMediaAndStop))); | |
| 243 | |
| 244 ExpectTitle("OK"); | |
| 245 } | |
| 246 | |
| 247 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndStop) { | |
| 248 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 249 | |
| 250 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 251 NavigateToURL(shell(), url); | |
| 252 | |
| 253 ASSERT_TRUE(ExecuteJavascript(base::StringPrintf( | |
| 254 "%s({video: true, audio: true});", kGetUserMediaAndStop))); | |
| 255 | |
| 256 ExpectTitle("OK"); | |
| 257 } | |
| 258 | |
| 259 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetAudioAndVideoStreamAndClone) { | |
| 260 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 261 | |
| 262 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 263 NavigateToURL(shell(), url); | |
| 264 | |
| 265 ASSERT_TRUE(ExecuteJavascript("getUserMediaAndClone();")); | |
| 266 | |
| 267 ExpectTitle("OK"); | |
| 268 } | |
| 269 | |
| 270 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TwoGetUserMediaAndStop) { | |
| 271 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 272 | |
| 273 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 274 NavigateToURL(shell(), url); | |
| 275 | |
| 276 ASSERT_TRUE(ExecuteJavascript( | |
| 277 "twoGetUserMediaAndStop({video: true, audio: true});")); | |
| 278 | |
| 279 ExpectTitle("OK"); | |
| 280 } | |
| 281 | |
| 282 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetUserMediaWithMandatorySourceID_1) { | |
| 283 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 284 | |
| 285 std::vector<std::string> audio_ids; | |
| 286 std::vector<std::string> video_ids; | |
| 287 GetSources(&audio_ids, &video_ids); | |
| 288 | |
| 289 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 290 NavigateToURL(shell(), url); | |
| 291 | |
| 292 for (size_t j = 0; j < video_ids.size() / 2; ++j) { | |
| 293 for (size_t i = 0; i < audio_ids.size(); ++i) { | |
| 294 EXPECT_EQ(kOK, | |
| 295 ExecuteJavascriptAndReturnResult( | |
| 296 GenerateGetUserMediaWithMandatorySourceID( | |
| 297 kGetUserMediaAndStop, audio_ids[i], video_ids[j]))); | |
| 298 } | |
| 299 } | |
| 300 } | |
| 301 | |
| 302 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetUserMediaWithMandatorySourceID_2) { | |
| 303 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 304 | |
| 305 std::vector<std::string> audio_ids; | |
| 306 std::vector<std::string> video_ids; | |
| 307 GetSources(&audio_ids, &video_ids); | |
| 308 | |
| 309 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 310 NavigateToURL(shell(), url); | |
| 311 | |
| 312 for (size_t j = video_ids.size() / 2; j < video_ids.size(); ++j) { | |
| 313 for (size_t i = 0; i < audio_ids.size(); ++i) { | |
| 314 EXPECT_EQ(kOK, | |
| 315 ExecuteJavascriptAndReturnResult( | |
| 316 GenerateGetUserMediaWithMandatorySourceID( | |
| 317 kGetUserMediaAndStop, audio_ids[i], video_ids[j]))); | |
| 318 } | |
| 319 } | |
| 320 } | |
| 321 | |
| 322 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | |
| 323 GetUserMediaWithInvalidMandatorySourceID) { | |
| 324 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 325 | |
| 326 std::vector<std::string> audio_ids; | |
| 327 std::vector<std::string> video_ids; | |
| 328 GetSources(&audio_ids, &video_ids); | |
| 329 | |
| 330 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 331 | |
| 332 // Test with invalid mandatory audio sourceID. | |
| 333 NavigateToURL(shell(), url); | |
| 334 EXPECT_EQ(kGetUserMediaFailed, | |
| 335 ExecuteJavascriptAndReturnResult( | |
| 336 GenerateGetUserMediaWithMandatorySourceID( | |
| 337 kGetUserMediaAndStop, "something invalid", video_ids[0]))); | |
| 338 | |
| 339 // Test with invalid mandatory video sourceID. | |
| 340 EXPECT_EQ(kGetUserMediaFailed, | |
| 341 ExecuteJavascriptAndReturnResult( | |
| 342 GenerateGetUserMediaWithMandatorySourceID( | |
| 343 kGetUserMediaAndStop, audio_ids[0], "something invalid"))); | |
| 344 | |
| 345 // Test with empty mandatory audio sourceID. | |
| 346 EXPECT_EQ(kGetUserMediaFailed, | |
| 347 ExecuteJavascriptAndReturnResult( | |
| 348 GenerateGetUserMediaWithMandatorySourceID( | |
| 349 kGetUserMediaAndStop, "", video_ids[0]))); | |
| 350 } | |
| 351 | |
| 352 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetUserMediaWithOptionalSourceID_1) { | |
| 353 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 354 | |
| 355 std::vector<std::string> audio_ids; | |
| 356 std::vector<std::string> video_ids; | |
| 357 GetSources(&audio_ids, &video_ids); | |
| 358 | |
| 359 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 360 NavigateToURL(shell(), url); | |
| 361 | |
| 362 // Test all combinations of mandatory sourceID. | |
| 363 for (size_t j = 0; j < video_ids.size() / 2; ++j) { | |
| 364 for (size_t i = 0; i < audio_ids.size(); ++i) { | |
| 365 EXPECT_EQ(kOK, | |
| 366 ExecuteJavascriptAndReturnResult( | |
| 367 GenerateGetUserMediaWithOptionalSourceID( | |
| 368 kGetUserMediaAndStop, audio_ids[i], video_ids[j]))); | |
| 369 } | |
| 370 } | |
| 371 } | |
| 372 | |
| 373 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, GetUserMediaWithOptionalSourceID_2) { | |
| 374 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 375 | |
| 376 std::vector<std::string> audio_ids; | |
| 377 std::vector<std::string> video_ids; | |
| 378 GetSources(&audio_ids, &video_ids); | |
| 379 | |
| 380 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 381 NavigateToURL(shell(), url); | |
| 382 | |
| 383 // Test all combinations of mandatory sourceID. | |
| 384 for (size_t j = video_ids.size() / 2; j < video_ids.size(); ++j) { | |
| 385 for (size_t i = 0; i < audio_ids.size(); ++i) { | |
| 386 EXPECT_EQ(kOK, | |
| 387 ExecuteJavascriptAndReturnResult( | |
| 388 GenerateGetUserMediaWithOptionalSourceID( | |
| 389 kGetUserMediaAndStop, audio_ids[i], video_ids[j]))); | |
| 390 } | |
| 391 } | |
| 392 } | |
| 393 | |
| 394 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | |
| 395 GetUserMediaWithInvalidOptionalSourceID) { | |
| 396 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 397 | |
| 398 std::vector<std::string> audio_ids; | |
| 399 std::vector<std::string> video_ids; | |
| 400 GetSources(&audio_ids, &video_ids); | |
| 401 | |
| 402 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 403 | |
| 404 // Test with invalid optional audio sourceID. | |
| 405 NavigateToURL(shell(), url); | |
| 406 EXPECT_EQ( | |
| 407 kOK, | |
| 408 ExecuteJavascriptAndReturnResult(GenerateGetUserMediaWithOptionalSourceID( | |
| 409 kGetUserMediaAndStop, "something invalid", video_ids[0]))); | |
| 410 | |
| 411 // Test with invalid optional video sourceID. | |
| 412 EXPECT_EQ( | |
| 413 kOK, | |
| 414 ExecuteJavascriptAndReturnResult(GenerateGetUserMediaWithOptionalSourceID( | |
| 415 kGetUserMediaAndStop, audio_ids[0], "something invalid"))); | |
| 416 | |
| 417 // Test with empty optional audio sourceID. | |
| 418 EXPECT_EQ( | |
| 419 kOK, | |
| 420 ExecuteJavascriptAndReturnResult(GenerateGetUserMediaWithOptionalSourceID( | |
| 421 kGetUserMediaAndStop, "", video_ids[0]))); | |
| 422 } | |
| 423 | |
| 424 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 51 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 425 // Timing out on ARM linux bot: http://crbug.com/238490 | 52 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 426 #define MAYBE_CanSetupVideoCall DISABLED_CanSetupVideoCall | 53 #define MAYBE_CanSetupVideoCall DISABLED_CanSetupVideoCall |
| 427 #else | 54 #else |
| 428 #define MAYBE_CanSetupVideoCall CanSetupVideoCall | 55 #define MAYBE_CanSetupVideoCall CanSetupVideoCall |
| 429 #endif | 56 #endif |
| 430 | 57 |
| 431 // These tests will make a complete PeerConnection-based call and verify that | 58 // These tests will make a complete PeerConnection-based call and verify that |
| 432 // video is playing for the call. | 59 // video is playing for the call. |
| 433 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupVideoCall) { | 60 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_CanSetupVideoCall) { |
| 434 MakeTypicalPeerConnectionCall("call({video: true});"); | 61 MakeTypicalPeerConnectionCall("call({video: true});"); |
| 435 } | 62 } |
| 436 | 63 |
| 437 // This test will make a simple getUserMedia page, verify that video is playing | |
| 438 // in a simple local <video>, and for a couple of seconds, collect some | |
| 439 // performance traces. | |
| 440 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TracePerformanceDuringGetUserMedia) { | |
| 441 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 442 | |
| 443 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 444 NavigateToURL(shell(), url); | |
| 445 // Put getUserMedia to work and let it run for a couple of seconds. | |
| 446 ASSERT_TRUE(ExecuteJavascript(base::StringPrintf( | |
| 447 "%s({video: true}, 10);", kGetUserMediaAndWaitAndStop))); | |
| 448 | |
| 449 // Make sure the stream is up and running, then start collecting traces. | |
| 450 ExpectTitle("Running..."); | |
| 451 StartTracing(); | |
| 452 | |
| 453 // Wait until the page title changes to "OK". Do not sleep() here since that | |
| 454 // would stop both this code and the browser underneath. | |
| 455 ExpectTitle("OK"); | |
| 456 StopTracing(); | |
| 457 | |
| 458 scoped_ptr<TraceAnalyzer> analyzer(CreateTraceAnalyzer()); | |
| 459 analyzer->AssociateBeginEndEvents(); | |
| 460 trace_analyzer::TraceEventVector events; | |
| 461 analyzer->FindEvents( | |
| 462 Query::EventNameIs("VideoCaptureController::OnIncomingCapturedFrame"), | |
| 463 &events); | |
| 464 ASSERT_GT(events.size(), 0u) | |
| 465 << "Could not collect any samples during test, this is bad"; | |
| 466 | |
| 467 std::string duration_us; | |
| 468 std::string interarrival_us; | |
| 469 for (size_t i = 0; i != events.size(); ++i) { | |
| 470 duration_us.append( | |
| 471 base::StringPrintf("%d,", static_cast<int>(events[i]->duration))); | |
| 472 } | |
| 473 | |
| 474 for (size_t i = 1; i < events.size(); ++i) { | |
| 475 interarrival_us.append(base::StringPrintf( | |
| 476 "%d,", | |
| 477 static_cast<int>(events[i]->timestamp - events[i - 1]->timestamp))); | |
| 478 } | |
| 479 | |
| 480 perf_test::PrintResultList( | |
| 481 "video_capture", "", "sample_duration", duration_us, "us", true); | |
| 482 | |
| 483 perf_test::PrintResultList( | |
| 484 "video_capture", "", "interarrival_time", interarrival_us, "us", true); | |
| 485 } | |
| 486 | |
| 487 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 64 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 488 // Timing out on ARM linux, see http://crbug.com/240376 | 65 // Timing out on ARM linux, see http://crbug.com/240376 |
| 489 #define MAYBE_CanSetupAudioAndVideoCall DISABLED_CanSetupAudioAndVideoCall | 66 #define MAYBE_CanSetupAudioAndVideoCall DISABLED_CanSetupAudioAndVideoCall |
| 490 #else | 67 #else |
| 491 #define MAYBE_CanSetupAudioAndVideoCall CanSetupAudioAndVideoCall | 68 #define MAYBE_CanSetupAudioAndVideoCall CanSetupAudioAndVideoCall |
| 492 #endif | 69 #endif |
| 493 | 70 |
| 494 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupAudioAndVideoCall) { | 71 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_CanSetupAudioAndVideoCall) { |
| 495 MakeTypicalPeerConnectionCall("call({video: true, audio: true});"); | 72 MakeTypicalPeerConnectionCall("call({video: true, audio: true});"); |
| 496 } | 73 } |
| 497 | 74 |
| 498 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CanSetupCallAndSendDtmf) { | 75 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MANUAL_CanSetupCallAndSendDtmf) { |
| 499 MakeTypicalPeerConnectionCall("callAndSendDtmf(\'123,abc\');"); | 76 MakeTypicalPeerConnectionCall("callAndSendDtmf(\'123,abc\');"); |
| 500 } | 77 } |
| 501 | 78 |
| 502 // TODO(phoglund): this test fails because the peer connection state will be | 79 // TODO(phoglund): this test fails because the peer connection state will be |
| 503 // stable in the second negotiation round rather than have-local-offer. | 80 // stable in the second negotiation round rather than have-local-offer. |
| 504 // http://crbug.com/293125. | 81 // http://crbug.com/293125. |
| 505 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | 82 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 506 DISABLED_CanMakeEmptyCallThenAddStreamsAndRenegotiate) { | 83 DISABLED_CanMakeEmptyCallThenAddStreamsAndRenegotiate) { |
| 507 const char* kJavascript = | 84 const char* kJavascript = |
| 508 "callEmptyThenAddOneStreamAndRenegotiate({video: true, audio: true});"; | 85 "callEmptyThenAddOneStreamAndRenegotiate({video: true, audio: true});"; |
| 509 MakeTypicalPeerConnectionCall(kJavascript); | 86 MakeTypicalPeerConnectionCall(kJavascript); |
| 510 } | 87 } |
| 511 | 88 |
| 512 // Below 2 test will make a complete PeerConnection-based call between pc1 and | 89 // Below 2 test will make a complete PeerConnection-based call between pc1 and |
| 513 // pc2, and then use the remote stream to setup a call between pc3 and pc4, and | 90 // pc2, and then use the remote stream to setup a call between pc3 and pc4, and |
| 514 // then verify that video is received on pc3 and pc4. | 91 // then verify that video is received on pc3 and pc4. |
| 515 // Flaky on win xp. http://crbug.com/304775 | 92 // Flaky on win xp. http://crbug.com/304775 |
| 516 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
| 517 #define MAYBE_CanForwardRemoteStream DISABLED_CanForwardRemoteStream | 94 #define MAYBE_CanForwardRemoteStream DISABLED_CanForwardRemoteStream |
| 518 #define MAYBE_CanForwardRemoteStream720p DISABLED_CanForwardRemoteStream720p | 95 #define MAYBE_CanForwardRemoteStream720p DISABLED_CanForwardRemoteStream720p |
| 519 #else | 96 #else |
| 520 #define MAYBE_CanForwardRemoteStream CanForwardRemoteStream | 97 #define MAYBE_CanForwardRemoteStream CanForwardRemoteStream |
| 521 #define MAYBE_CanForwardRemoteStream720p CanForwardRemoteStream720p | 98 #define MAYBE_CanForwardRemoteStream720p CanForwardRemoteStream720p |
| 522 #endif | 99 #endif |
| 523 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanForwardRemoteStream) { | 100 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_CanForwardRemoteStream) { |
| 524 MakeTypicalPeerConnectionCall( | 101 MakeTypicalPeerConnectionCall( |
| 525 "callAndForwardRemoteStream({video: true, audio: true});"); | 102 "callAndForwardRemoteStream({video: true, audio: true});"); |
| 526 } | 103 } |
| 527 | 104 |
| 528 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanForwardRemoteStream720p) { | 105 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_CanForwardRemoteStream720p) { |
| 529 const std::string javascript = GenerateGetUserMediaCall( | 106 const std::string javascript = GenerateGetUserMediaCall( |
| 530 "callAndForwardRemoteStream", 1280, 1280, 720, 720, 30, 30); | 107 "callAndForwardRemoteStream", 1280, 1280, 720, 720, 30, 30); |
| 531 MakeTypicalPeerConnectionCall(javascript); | 108 MakeTypicalPeerConnectionCall(javascript); |
| 532 } | 109 } |
| 533 | 110 |
| 534 // This test will make a complete PeerConnection-based call but remove the | 111 // This test will make a complete PeerConnection-based call but remove the |
| 535 // MSID and bundle attribute from the initial offer to verify that | 112 // MSID and bundle attribute from the initial offer to verify that |
| 536 // video is playing for the call even if the initiating client don't support | 113 // video is playing for the call even if the initiating client don't support |
| 537 // MSID. http://tools.ietf.org/html/draft-alvestrand-rtcweb-msid-02 | 114 // MSID. http://tools.ietf.org/html/draft-alvestrand-rtcweb-msid-02 |
| 538 #if defined(OS_WIN) | 115 #if defined(OS_WIN) |
| 539 // Disabled for win, see http://crbug.com/235089. | 116 // Disabled for win, see http://crbug.com/235089. |
| 540 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\ | 117 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\ |
| 541 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle | 118 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle |
| 542 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 119 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 543 // Timing out on ARM linux, see http://crbug.com/240373 | 120 // Timing out on ARM linux, see http://crbug.com/240373 |
| 544 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\ | 121 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\ |
| 545 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle | 122 DISABLED_CanSetupAudioAndVideoCallWithoutMsidAndBundle |
| 546 #else | 123 #else |
| 547 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\ | 124 #define MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle\ |
| 548 CanSetupAudioAndVideoCallWithoutMsidAndBundle | 125 CanSetupAudioAndVideoCallWithoutMsidAndBundle |
| 549 #endif | 126 #endif |
| 550 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | 127 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 551 MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle) { | 128 MAYBE_CanSetupAudioAndVideoCallWithoutMsidAndBundle) { |
| 552 MakeTypicalPeerConnectionCall("callWithoutMsidAndBundle();"); | 129 MakeTypicalPeerConnectionCall("callWithoutMsidAndBundle();"); |
| 553 } | 130 } |
| 554 | 131 |
| 555 // This test will modify the SDP offer to an unsupported codec, which should | 132 // This test will modify the SDP offer to an unsupported codec, which should |
| 556 // cause SetLocalDescription to fail. | 133 // cause SetLocalDescription to fail. |
| 557 #if defined(USE_OZONE) | 134 #if defined(USE_OZONE) |
| 558 // Disabled for Ozone, see http://crbug.com/315392#c15 | 135 // Disabled for Ozone, see http://crbug.com/315392#c15 |
| 559 #define MAYBE_NegotiateUnsupportedVideoCodec\ | 136 #define MAYBE_NegotiateUnsupportedVideoCodec\ |
| 560 DISABLED_NegotiateUnsupportedVideoCodec | 137 DISABLED_NegotiateUnsupportedVideoCodec |
| 561 #else | 138 #else |
| 562 #define MAYBE_NegotiateUnsupportedVideoCodec NegotiateUnsupportedVideoCodec | 139 #define MAYBE_NegotiateUnsupportedVideoCodec NegotiateUnsupportedVideoCodec |
| 563 #endif | 140 #endif |
| 564 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | 141 |
| 142 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 565 MAYBE_NegotiateUnsupportedVideoCodec) { | 143 MAYBE_NegotiateUnsupportedVideoCodec) { |
| 566 MakeTypicalPeerConnectionCall("negotiateUnsupportedVideoCodec();"); | 144 MakeTypicalPeerConnectionCall("negotiateUnsupportedVideoCodec();"); |
| 567 } | 145 } |
| 568 | 146 |
| 569 // This test will modify the SDP offer to use no encryption, which should | 147 // This test will modify the SDP offer to use no encryption, which should |
| 570 // cause SetLocalDescription to fail. | 148 // cause SetLocalDescription to fail. |
| 571 #if defined(USE_OZONE) | 149 #if defined(USE_OZONE) |
| 572 // Disabled for Ozone, see http://crbug.com/315392#c15 | 150 // Disabled for Ozone, see http://crbug.com/315392#c15 |
| 573 #define MAYBE_NegotiateNonCryptoCall DISABLED_NegotiateNonCryptoCall | 151 #define MAYBE_NegotiateNonCryptoCall DISABLED_NegotiateNonCryptoCall |
| 574 #else | 152 #else |
| 575 #define MAYBE_NegotiateNonCryptoCall NegotiateNonCryptoCall | 153 #define MAYBE_NegotiateNonCryptoCall NegotiateNonCryptoCall |
| 576 #endif | 154 #endif |
| 577 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_NegotiateNonCryptoCall) { | 155 |
| 156 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_NegotiateNonCryptoCall) { |
| 578 MakeTypicalPeerConnectionCall("negotiateNonCryptoCall();"); | 157 MakeTypicalPeerConnectionCall("negotiateNonCryptoCall();"); |
| 579 } | 158 } |
| 580 | 159 |
| 581 // This test can negotiate an SDP offer that includes a b=AS:xx to control | 160 // This test can negotiate an SDP offer that includes a b=AS:xx to control |
| 582 // the bandwidth for audio and video | 161 // the bandwidth for audio and video |
| 583 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, NegotiateOfferWithBLine) { | 162 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, NegotiateOfferWithBLine) { |
| 584 MakeTypicalPeerConnectionCall("negotiateOfferWithBLine();"); | 163 MakeTypicalPeerConnectionCall("negotiateOfferWithBLine();"); |
| 585 } | 164 } |
| 586 | 165 |
| 587 // This test will make a complete PeerConnection-based call using legacy SDP | 166 // This test will make a complete PeerConnection-based call using legacy SDP |
| 588 // settings: GIce, external SDES, and no BUNDLE. | 167 // settings: GIce, external SDES, and no BUNDLE. |
| 589 #if defined(OS_WIN) | 168 #if defined(OS_WIN) |
| 590 // Disabled for win7, see http://crbug.com/235089. | 169 // Disabled for win7, see http://crbug.com/235089. |
| 591 #define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall | 170 #define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall |
| 592 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 171 #elif defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 593 // Timing out on ARM linux, see http://crbug.com/240373 | 172 // Timing out on ARM linux, see http://crbug.com/240373 |
| 594 #define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall | 173 #define MAYBE_CanSetupLegacyCall DISABLED_CanSetupLegacyCall |
| 595 #else | 174 #else |
| 596 #define MAYBE_CanSetupLegacyCall CanSetupLegacyCall | 175 #define MAYBE_CanSetupLegacyCall CanSetupLegacyCall |
| 597 #endif | 176 #endif |
| 598 | 177 |
| 599 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CanSetupLegacyCall) { | 178 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_CanSetupLegacyCall) { |
| 600 MakeTypicalPeerConnectionCall("callWithLegacySdp();"); | 179 MakeTypicalPeerConnectionCall("callWithLegacySdp();"); |
| 601 } | 180 } |
| 602 | 181 |
| 603 // This test will make a PeerConnection-based call and test an unreliable text | 182 // This test will make a PeerConnection-based call and test an unreliable text |
| 604 // dataChannel. | 183 // dataChannel. |
| 605 // TODO(mallinath) - Remove this test after rtp based data channel is disabled. | 184 // TODO(mallinath) - Remove this test after rtp based data channel is disabled. |
| 606 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithDataOnly) { | 185 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, CallWithDataOnly) { |
| 607 MakeTypicalPeerConnectionCall("callWithDataOnly();"); | 186 MakeTypicalPeerConnectionCall("callWithDataOnly();"); |
| 608 } | 187 } |
| 609 | 188 |
| 610 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallWithSctpDataOnly) { | 189 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, CallWithSctpDataOnly) { |
| 611 MakeTypicalPeerConnectionCall("callWithSctpDataOnly();"); | 190 MakeTypicalPeerConnectionCall("callWithSctpDataOnly();"); |
| 612 } | 191 } |
| 613 | 192 |
| 614 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 193 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 615 // Timing out on ARM linux bot: http://crbug.com/238490 | 194 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 616 #define MAYBE_CallWithDataAndMedia DISABLED_CallWithDataAndMedia | 195 #define MAYBE_CallWithDataAndMedia DISABLED_CallWithDataAndMedia |
| 617 #else | 196 #else |
| 618 #define MAYBE_CallWithDataAndMedia CallWithDataAndMedia | 197 #define MAYBE_CallWithDataAndMedia CallWithDataAndMedia |
| 619 #endif | 198 #endif |
| 620 | 199 |
| 621 // This test will make a PeerConnection-based call and test an unreliable text | 200 // This test will make a PeerConnection-based call and test an unreliable text |
| 622 // dataChannel and audio and video tracks. | 201 // dataChannel and audio and video tracks. |
| 623 // TODO(mallinath) - Remove this test after rtp based data channel is disabled. | 202 // TODO(mallinath) - Remove this test after rtp based data channel is disabled. |
| 624 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndMedia) { | 203 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_CallWithDataAndMedia) { |
| 625 MakeTypicalPeerConnectionCall("callWithDataAndMedia();"); | 204 MakeTypicalPeerConnectionCall("callWithDataAndMedia();"); |
| 626 } | 205 } |
| 627 | 206 |
| 628 | 207 |
| 629 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 208 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 630 // Timing out on ARM linux bot: http://crbug.com/238490 | 209 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 631 #define MAYBE_CallWithSctpDataAndMedia DISABLED_CallWithSctpDataAndMedia | 210 #define MAYBE_CallWithSctpDataAndMedia DISABLED_CallWithSctpDataAndMedia |
| 632 #else | 211 #else |
| 633 #define MAYBE_CallWithSctpDataAndMedia CallWithSctpDataAndMedia | 212 #define MAYBE_CallWithSctpDataAndMedia CallWithSctpDataAndMedia |
| 634 #endif | 213 #endif |
| 635 | 214 |
| 636 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | 215 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 637 MAYBE_CallWithSctpDataAndMedia) { | 216 MAYBE_CallWithSctpDataAndMedia) { |
| 638 MakeTypicalPeerConnectionCall("callWithSctpDataAndMedia();"); | 217 MakeTypicalPeerConnectionCall("callWithSctpDataAndMedia();"); |
| 639 } | 218 } |
| 640 | 219 |
| 641 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 220 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 642 // Timing out on ARM linux bot: http://crbug.com/238490 | 221 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 643 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia | 222 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia |
| 644 #else | 223 #else |
| 645 // Temporarily disable the test on all platforms. http://crbug.com/293252 | 224 // Temporarily disable the test on all platforms. http://crbug.com/293252 |
| 646 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia | 225 #define MAYBE_CallWithDataAndLaterAddMedia DISABLED_CallWithDataAndLaterAddMedia |
| 647 #endif | 226 #endif |
| 648 | 227 |
| 649 // This test will make a PeerConnection-based call and test an unreliable text | 228 // This test will make a PeerConnection-based call and test an unreliable text |
| 650 // dataChannel and later add an audio and video track. | 229 // dataChannel and later add an audio and video track. |
| 651 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithDataAndLaterAddMedia) { | 230 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_CallWithDataAndLaterAddMedia) { |
| 652 MakeTypicalPeerConnectionCall("callWithDataAndLaterAddMedia();"); | 231 MakeTypicalPeerConnectionCall("callWithDataAndLaterAddMedia();"); |
| 653 } | 232 } |
| 654 | 233 |
| 655 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 234 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 656 // Timing out on ARM linux bot: http://crbug.com/238490 | 235 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 657 #define MAYBE_CallWithNewVideoMediaStream DISABLED_CallWithNewVideoMediaStream | 236 #define MAYBE_CallWithNewVideoMediaStream DISABLED_CallWithNewVideoMediaStream |
| 658 #else | 237 #else |
| 659 #define MAYBE_CallWithNewVideoMediaStream CallWithNewVideoMediaStream | 238 #define MAYBE_CallWithNewVideoMediaStream CallWithNewVideoMediaStream |
| 660 #endif | 239 #endif |
| 661 | 240 |
| 662 // This test will make a PeerConnection-based call and send a new Video | 241 // This test will make a PeerConnection-based call and send a new Video |
| 663 // MediaStream that has been created based on a MediaStream created with | 242 // MediaStream that has been created based on a MediaStream created with |
| 664 // getUserMedia. | 243 // getUserMedia. |
| 665 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithNewVideoMediaStream) { | 244 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_CallWithNewVideoMediaStream) { |
| 666 MakeTypicalPeerConnectionCall("callWithNewVideoMediaStream();"); | 245 MakeTypicalPeerConnectionCall("callWithNewVideoMediaStream();"); |
| 667 } | 246 } |
| 668 | 247 |
| 669 // This test will make a PeerConnection-based call and send a new Video | 248 // This test will make a PeerConnection-based call and send a new Video |
| 670 // MediaStream that has been created based on a MediaStream created with | 249 // MediaStream that has been created based on a MediaStream created with |
| 671 // getUserMedia. When video is flowing, the VideoTrack is removed and an | 250 // getUserMedia. When video is flowing, the VideoTrack is removed and an |
| 672 // AudioTrack is added instead. | 251 // AudioTrack is added instead. |
| 673 // TODO(phoglund): This test is manual since not all buildbots has an audio | 252 // TODO(phoglund): This test is manual since not all buildbots has an audio |
| 674 // input. | 253 // input. |
| 675 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MANUAL_CallAndModifyStream) { | 254 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MANUAL_CallAndModifyStream) { |
| 676 MakeTypicalPeerConnectionCall( | 255 MakeTypicalPeerConnectionCall( |
| 677 "callWithNewVideoMediaStreamLaterSwitchToAudio();"); | 256 "callWithNewVideoMediaStreamLaterSwitchToAudio();"); |
| 678 } | 257 } |
| 679 | 258 |
| 680 namespace { | 259 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, AddTwoMediaStreamsToOnePC) { |
| 681 | |
| 682 struct UserMediaSizes { | |
| 683 int min_width; | |
| 684 int max_width; | |
| 685 int min_height; | |
| 686 int max_height; | |
| 687 int min_frame_rate; | |
| 688 int max_frame_rate; | |
| 689 }; | |
| 690 | |
| 691 } // namespace | |
| 692 | |
| 693 class WebrtcUserMediaBrowserTest | |
| 694 : public WebrtcBrowserTest, | |
| 695 public testing::WithParamInterface<UserMediaSizes> { | |
| 696 public: | |
| 697 WebrtcUserMediaBrowserTest() : user_media_(GetParam()) {} | |
| 698 const UserMediaSizes& user_media() const { return user_media_; } | |
| 699 | |
| 700 private: | |
| 701 UserMediaSizes user_media_; | |
| 702 }; | |
| 703 | |
| 704 // This test calls getUserMedia in sequence with different constraints. | |
| 705 IN_PROC_BROWSER_TEST_P(WebrtcUserMediaBrowserTest, GetUserMediaConstraints) { | |
| 706 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 707 | |
| 708 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 709 | |
| 710 std::string call = GenerateGetUserMediaCall(kGetUserMediaAndStop, | |
| 711 user_media().min_width, | |
| 712 user_media().max_width, | |
| 713 user_media().min_height, | |
| 714 user_media().max_height, | |
| 715 user_media().min_frame_rate, | |
| 716 user_media().max_frame_rate); | |
| 717 DVLOG(1) << "Calling getUserMedia: " << call; | |
| 718 NavigateToURL(shell(), url); | |
| 719 ASSERT_TRUE(ExecuteJavascript(call)); | |
| 720 ExpectTitle("OK"); | |
| 721 } | |
| 722 | |
| 723 static const UserMediaSizes kAllUserMediaSizes[] = { | |
| 724 {320, 320, 180, 180, 30, 30}, | |
| 725 {320, 320, 240, 240, 30, 30}, | |
| 726 {640, 640, 360, 360, 30, 30}, | |
| 727 {640, 640, 480, 480, 30, 30}, | |
| 728 {960, 960, 720, 720, 30, 30}, | |
| 729 {1280, 1280, 720, 720, 30, 30}, | |
| 730 {1920, 1920, 1080, 1080, 30, 30}}; | |
| 731 | |
| 732 INSTANTIATE_TEST_CASE_P(UserMedia, | |
| 733 WebrtcUserMediaBrowserTest, | |
| 734 testing::ValuesIn(kAllUserMediaSizes)); | |
| 735 | |
| 736 // This test calls getUserMedia and checks for aspect ratio behavior. | |
| 737 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, TestGetUserMediaAspectRatio) { | |
| 738 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | |
| 739 | |
| 740 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 741 | |
| 742 std::string constraints_4_3 = GenerateGetUserMediaCall( | |
| 743 kGetUserMediaAndAnalyseAndStop, 640, 640, 480, 480, 30, 30); | |
| 744 std::string constraints_16_9 = GenerateGetUserMediaCall( | |
| 745 kGetUserMediaAndAnalyseAndStop, 640, 640, 360, 360, 30, 30); | |
| 746 | |
| 747 // TODO(mcasas): add more aspect ratios, in particular 16:10 crbug.com/275594. | |
| 748 | |
| 749 NavigateToURL(shell(), url); | |
| 750 ASSERT_TRUE(ExecuteJavascript(constraints_4_3)); | |
| 751 ExpectTitle("4:3 letterbox"); | |
| 752 | |
| 753 NavigateToURL(shell(), url); | |
| 754 ASSERT_TRUE(ExecuteJavascript(constraints_16_9)); | |
| 755 ExpectTitle("16:9 letterbox"); | |
| 756 } | |
| 757 | |
| 758 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, AddTwoMediaStreamsToOnePC) { | |
| 759 MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();"); | 260 MakeTypicalPeerConnectionCall("addTwoMediaStreamsToOneConnection();"); |
| 760 } | 261 } |
| 761 | 262 |
| 762 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | 263 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 763 EstablishAudioVideoCallAndMeasureOutputLevel) { | 264 EstablishAudioVideoCallAndMeasureOutputLevel) { |
| 764 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { | 265 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { |
| 765 // Bots with no output devices will force the audio code into a different | 266 // Bots with no output devices will force the audio code into a different |
| 766 // path where it doesn't manage to set either the low or high latency path. | 267 // path where it doesn't manage to set either the low or high latency path. |
| 767 // This test will compute useless values in that case, so skip running on | 268 // This test will compute useless values in that case, so skip running on |
| 768 // such bots (see crbug.com/326338). | 269 // such bots (see crbug.com/326338). |
| 769 LOG(INFO) << "Missing output devices: skipping test..."; | 270 LOG(INFO) << "Missing output devices: skipping test..."; |
| 770 return; | 271 return; |
| 771 } | 272 } |
| 772 | 273 |
| 773 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | 274 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( |
| 774 switches::kUseFakeDeviceForMediaStream)) | 275 switches::kUseFakeDeviceForMediaStream)) |
| 775 << "Must run with fake devices since the test will explicitly look " | 276 << "Must run with fake devices since the test will explicitly look " |
| 776 << "for the fake device signal."; | 277 << "for the fake device signal."; |
| 777 | 278 |
| 778 MakeTypicalPeerConnectionCall("callAndEnsureAudioIsPlaying();"); | 279 MakeTypicalPeerConnectionCall("callAndEnsureAudioIsPlaying();"); |
| 779 } | 280 } |
| 780 | 281 |
| 781 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | 282 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 782 EstablishAudioVideoCallAndVerifyMutingWorks) { | 283 EstablishAudioVideoCallAndVerifyMutingWorks) { |
| 783 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { | 284 if (!media::AudioManager::Get()->HasAudioOutputDevices()) { |
| 784 // Bots with no output devices will force the audio code into a different | 285 // Bots with no output devices will force the audio code into a different |
| 785 // path where it doesn't manage to set either the low or high latency path. | 286 // path where it doesn't manage to set either the low or high latency path. |
| 786 // This test will compute useless values in that case, so skip running on | 287 // This test will compute useless values in that case, so skip running on |
| 787 // such bots (see crbug.com/326338). | 288 // such bots (see crbug.com/326338). |
| 788 LOG(INFO) << "Missing output devices: skipping test..."; | 289 LOG(INFO) << "Missing output devices: skipping test..."; |
| 789 return; | 290 return; |
| 790 } | 291 } |
| 791 | 292 |
| 792 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( | 293 ASSERT_TRUE(CommandLine::ForCurrentProcess()->HasSwitch( |
| 793 switches::kUseFakeDeviceForMediaStream)) | 294 switches::kUseFakeDeviceForMediaStream)) |
| 794 << "Must run with fake devices since the test will explicitly look " | 295 << "Must run with fake devices since the test will explicitly look " |
| 795 << "for the fake device signal."; | 296 << "for the fake device signal."; |
| 796 | 297 |
| 797 MakeTypicalPeerConnectionCall("callAndEnsureAudioMutingWorks();"); | 298 MakeTypicalPeerConnectionCall("callAndEnsureAudioMutingWorks();"); |
| 798 } | 299 } |
| 799 | 300 |
| 800 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, CallAndVerifyVideoMutingWorks) { | 301 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, CallAndVerifyVideoMutingWorks) { |
| 801 MakeTypicalPeerConnectionCall("callAndEnsureVideoMutingWorks();"); | 302 MakeTypicalPeerConnectionCall("callAndEnsureVideoMutingWorks();"); |
| 802 } | 303 } |
| 803 | 304 |
| 804 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(AR
CH_CPU_ARM_FAMILY)) | 305 #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(AR
CH_CPU_ARM_FAMILY)) |
| 805 // Timing out on ARM linux bot: http://crbug.com/238490 | 306 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 806 // Failing on Windows: http://crbug.com/331035 | 307 // Failing on Windows: http://crbug.com/331035 |
| 807 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump | 308 #define MAYBE_CallWithAecDump DISABLED_CallWithAecDump |
| 808 #else | 309 #else |
| 809 #define MAYBE_CallWithAecDump CallWithAecDump | 310 #define MAYBE_CallWithAecDump CallWithAecDump |
| 810 #endif | 311 #endif |
| 811 | 312 |
| 812 // This tests will make a complete PeerConnection-based call, verify that | 313 // This tests will make a complete PeerConnection-based call, verify that |
| 813 // video is playing for the call, and verify that a non-empty AEC dump file | 314 // video is playing for the call, and verify that a non-empty AEC dump file |
| 814 // exists. The AEC dump is enabled through webrtc-internals, in contrast to | 315 // exists. The AEC dump is enabled through webrtc-internals, in contrast to |
| 815 // using a command line flag (tested in webrtc_aecdump_browsertest.cc). The HTML | 316 // using a command line flag (tested in webrtc_aecdump_browsertest.cc). The HTML |
| 816 // and Javascript is bypassed since it would trigger a file picker dialog. | 317 // and Javascript is bypassed since it would trigger a file picker dialog. |
| 817 // Instead, the dialog callback FileSelected() is invoked directly. In fact, | 318 // Instead, the dialog callback FileSelected() is invoked directly. In fact, |
| 818 // there's never a webrtc-internals page opened at all since that's not needed. | 319 // there's never a webrtc-internals page opened at all since that's not needed. |
| 819 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, MAYBE_CallWithAecDump) { | 320 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, MAYBE_CallWithAecDump) { |
| 820 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 321 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 821 | 322 |
| 822 // We must navigate somewhere first so that the render process is created. | 323 // We must navigate somewhere first so that the render process is created. |
| 823 NavigateToURL(shell(), GURL("")); | 324 NavigateToURL(shell(), GURL("")); |
| 824 | 325 |
| 825 base::FilePath dump_file; | 326 base::FilePath dump_file; |
| 826 ASSERT_TRUE(CreateTemporaryFile(&dump_file)); | 327 ASSERT_TRUE(CreateTemporaryFile(&dump_file)); |
| 827 | 328 |
| 828 // This fakes the behavior of another open tab with webrtc-internals, and | 329 // This fakes the behavior of another open tab with webrtc-internals, and |
| 829 // enabling AEC dump in that tab. | 330 // enabling AEC dump in that tab. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 843 | 344 |
| 844 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) | 345 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) |
| 845 // Timing out on ARM linux bot: http://crbug.com/238490 | 346 // Timing out on ARM linux bot: http://crbug.com/238490 |
| 846 #define MAYBE_CallWithAecDumpEnabledThenDisabled DISABLED_CallWithAecDumpEnabled
ThenDisabled | 347 #define MAYBE_CallWithAecDumpEnabledThenDisabled DISABLED_CallWithAecDumpEnabled
ThenDisabled |
| 847 #else | 348 #else |
| 848 #define MAYBE_CallWithAecDumpEnabledThenDisabled CallWithAecDumpEnabledThenDisab
led | 349 #define MAYBE_CallWithAecDumpEnabledThenDisabled CallWithAecDumpEnabledThenDisab
led |
| 849 #endif | 350 #endif |
| 850 | 351 |
| 851 // As above, but enable and disable dump before starting a call. The file should | 352 // As above, but enable and disable dump before starting a call. The file should |
| 852 // be created, but should be empty. | 353 // be created, but should be empty. |
| 853 IN_PROC_BROWSER_TEST_F(WebrtcBrowserTest, | 354 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, |
| 854 MAYBE_CallWithAecDumpEnabledThenDisabled) { | 355 MAYBE_CallWithAecDumpEnabledThenDisabled) { |
| 855 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 356 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 856 | 357 |
| 857 // We must navigate somewhere first so that the render process is created. | 358 // We must navigate somewhere first so that the render process is created. |
| 858 NavigateToURL(shell(), GURL("")); | 359 NavigateToURL(shell(), GURL("")); |
| 859 | 360 |
| 860 base::FilePath dump_file; | 361 base::FilePath dump_file; |
| 861 ASSERT_TRUE(CreateTemporaryFile(&dump_file)); | 362 ASSERT_TRUE(CreateTemporaryFile(&dump_file)); |
| 862 | 363 |
| 863 // This fakes the behavior of another open tab with webrtc-internals, and | 364 // This fakes the behavior of another open tab with webrtc-internals, and |
| 864 // enabling AEC dump in that tab, then disabling it. | 365 // enabling AEC dump in that tab, then disabling it. |
| 865 WebRTCInternals::GetInstance()->FileSelected(dump_file, -1, NULL); | 366 WebRTCInternals::GetInstance()->FileSelected(dump_file, -1, NULL); |
| 866 WebRTCInternals::GetInstance()->DisableAecDump(); | 367 WebRTCInternals::GetInstance()->DisableAecDump(); |
| 867 | 368 |
| 868 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); | 369 GURL url(embedded_test_server()->GetURL("/media/peerconnection-call.html")); |
| 869 NavigateToURL(shell(), url); | 370 NavigateToURL(shell(), url); |
| 870 ExecuteTestAndWaitForOk("call({video: true, audio: true});"); | 371 ExecuteTestAndWaitForOk("call({video: true, audio: true});"); |
| 871 | 372 |
| 872 EXPECT_TRUE(base::PathExists(dump_file)); | 373 EXPECT_TRUE(base::PathExists(dump_file)); |
| 873 int64 file_size = 0; | 374 int64 file_size = 0; |
| 874 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size)); | 375 EXPECT_TRUE(base::GetFileSize(dump_file, &file_size)); |
| 875 EXPECT_EQ(0, file_size); | 376 EXPECT_EQ(0, file_size); |
| 876 | 377 |
| 877 base::DeleteFile(dump_file, false); | 378 base::DeleteFile(dump_file, false); |
| 878 } | 379 } |
| 879 | 380 |
| 880 | |
| 881 } // namespace content | 381 } // namespace content |
| OLD | NEW |