Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/debug/trace_event_impl.h" | 6 #include "base/debug/trace_event_impl.h" |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/test/trace_event_analyzer.h" | 9 #include "base/test/trace_event_analyzer.h" |
| 10 #include "base/timer/elapsed_timer.h" | |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 11 #include "content/browser/media/webrtc_internals.h" | 12 #include "content/browser/media/webrtc_internals.h" |
| 12 #include "content/browser/web_contents/web_contents_impl.h" | 13 #include "content/browser/web_contents/web_contents_impl.h" |
| 13 #include "content/public/common/content_switches.h" | 14 #include "content/public/common/content_switches.h" |
| 14 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
| 15 #include "content/public/test/content_browser_test_utils.h" | 16 #include "content/public/test/content_browser_test_utils.h" |
| 16 #include "content/public/test/test_utils.h" | 17 #include "content/public/test/test_utils.h" |
| 17 #include "content/shell/browser/shell.h" | 18 #include "content/shell/browser/shell.h" |
| 18 #include "content/test/webrtc_content_browsertest_base.h" | 19 #include "content/test/webrtc_content_browsertest_base.h" |
| 19 #include "net/test/embedded_test_server/embedded_test_server.h" | 20 #include "net/test/embedded_test_server/embedded_test_server.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 } // namespace | 75 } // namespace |
| 75 | 76 |
| 76 namespace content { | 77 namespace content { |
| 77 | 78 |
| 78 class WebRtcGetUserMediaBrowserTest: public WebRtcContentBrowserTest, | 79 class WebRtcGetUserMediaBrowserTest: public WebRtcContentBrowserTest, |
| 79 public testing::WithParamInterface<bool> { | 80 public testing::WithParamInterface<bool> { |
| 80 public: | 81 public: |
| 81 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) {} | 82 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) {} |
| 82 virtual ~WebRtcGetUserMediaBrowserTest() {} | 83 virtual ~WebRtcGetUserMediaBrowserTest() {} |
| 83 | 84 |
| 85 virtual void TearDown() OVERRIDE { | |
| 86 LOG(INFO) << "Entering teardown; " << timer_.Elapsed().InSeconds() | |
|
tommi (sloooow) - chröme
2014/07/07 09:35:06
We don't use LOG(INFO) anymore. VLOG(1)?
phoglund_chromium
2014/07/07 09:48:40
VLOG(1) logs don't seem to be visible by default i
| |
| 87 << " seconds elapsed."; | |
| 88 WebRtcContentBrowserTest::TearDown(); | |
| 89 LOG(INFO) << "Exiting teardown; " << timer_.Elapsed().InSeconds() | |
| 90 << " seconds elapsed."; | |
| 91 } | |
| 92 | |
| 84 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 93 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 85 WebRtcContentBrowserTest::SetUpCommandLine(command_line); | 94 WebRtcContentBrowserTest::SetUpCommandLine(command_line); |
| 86 | 95 |
| 87 bool enable_audio_track_processing = GetParam(); | 96 bool enable_audio_track_processing = GetParam(); |
| 88 if (!enable_audio_track_processing) | 97 if (!enable_audio_track_processing) |
| 89 command_line->AppendSwitch(switches::kDisableAudioTrackProcessing); | 98 command_line->AppendSwitch(switches::kDisableAudioTrackProcessing); |
| 90 } | 99 } |
| 91 | 100 |
| 92 void StartTracing() { | 101 void StartTracing() { |
| 93 CHECK(trace_log_ == NULL) << "Can only can start tracing once"; | 102 CHECK(trace_log_ == NULL) << "Can only can start tracing once"; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 if (kind == "audio") { | 238 if (kind == "audio") { |
| 230 audio_ids->push_back(device_id); | 239 audio_ids->push_back(device_id); |
| 231 } else if (kind == "video") { | 240 } else if (kind == "video") { |
| 232 video_ids->push_back(device_id); | 241 video_ids->push_back(device_id); |
| 233 } | 242 } |
| 234 } | 243 } |
| 235 ASSERT_FALSE(audio_ids->empty()); | 244 ASSERT_FALSE(audio_ids->empty()); |
| 236 ASSERT_FALSE(video_ids->empty()); | 245 ASSERT_FALSE(video_ids->empty()); |
| 237 } | 246 } |
| 238 | 247 |
| 248 // TODO(phoglund): Remove when done debugging https://crbug.com/387895. | |
| 249 base::ElapsedTimer timer_; | |
|
tommi (sloooow) - chröme
2014/07/07 09:35:06
protected?
phoglund_chromium
2014/07/07 09:48:40
Done.
| |
| 250 | |
| 239 private: | 251 private: |
| 240 base::debug::TraceLog* trace_log_; | 252 base::debug::TraceLog* trace_log_; |
| 241 scoped_refptr<base::RefCountedString> recorded_trace_data_; | 253 scoped_refptr<base::RefCountedString> recorded_trace_data_; |
| 242 scoped_refptr<MessageLoopRunner> message_loop_runner_; | 254 scoped_refptr<MessageLoopRunner> message_loop_runner_; |
| 255 | |
|
tommi (sloooow) - chröme
2014/07/07 09:35:06
remove
phoglund_chromium
2014/07/07 09:48:40
Done.
| |
| 243 }; | 256 }; |
| 244 | 257 |
| 245 static const bool kRunTestsWithFlag[] = { false, true }; | 258 static const bool kRunTestsWithFlag[] = { false, true }; |
| 246 INSTANTIATE_TEST_CASE_P(WebRtcGetUserMediaBrowserTests, | 259 INSTANTIATE_TEST_CASE_P(WebRtcGetUserMediaBrowserTests, |
| 247 WebRtcGetUserMediaBrowserTest, | 260 WebRtcGetUserMediaBrowserTest, |
| 248 testing::ValuesIn(kRunTestsWithFlag)); | 261 testing::ValuesIn(kRunTestsWithFlag)); |
| 249 | 262 |
| 250 // These tests will all make a getUserMedia call with different constraints and | 263 // These tests will all make a getUserMedia call with different constraints and |
| 251 // see that the success callback is called. If the error callback is called or | 264 // see that the success callback is called. If the error callback is called or |
| 252 // none of the callbacks are called the tests will simply time out and fail. | 265 // none of the callbacks are called the tests will simply time out and fail. |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 346 | 359 |
| 347 ExecuteJavascriptAndWaitForOk("getUserMediaAndRenderInSeveralVideoTags();"); | 360 ExecuteJavascriptAndWaitForOk("getUserMediaAndRenderInSeveralVideoTags();"); |
| 348 } | 361 } |
| 349 | 362 |
| 350 | 363 |
| 351 | 364 |
| 352 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, | 365 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, |
| 353 GetUserMediaWithMandatorySourceID) { | 366 GetUserMediaWithMandatorySourceID) { |
| 354 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 367 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 355 | 368 |
| 369 LOG(INFO) << "HTTP server ready; " << timer_.Elapsed().InSeconds() | |
| 370 << " seconds elapsed."; | |
| 371 | |
| 356 std::vector<std::string> audio_ids; | 372 std::vector<std::string> audio_ids; |
| 357 std::vector<std::string> video_ids; | 373 std::vector<std::string> video_ids; |
| 358 GetInputDevices(&audio_ids, &video_ids); | 374 GetInputDevices(&audio_ids, &video_ids); |
| 359 | 375 |
| 360 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | 376 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
| 361 | 377 |
| 362 // Test all combinations of mandatory sourceID; | 378 // Test all combinations of mandatory sourceID; |
| 363 for (std::vector<std::string>::const_iterator video_it = video_ids.begin(); | 379 for (std::vector<std::string>::const_iterator video_it = video_ids.begin(); |
| 364 video_it != video_ids.end(); ++video_it) { | 380 video_it != video_ids.end(); ++video_it) { |
| 365 for (std::vector<std::string>::const_iterator audio_it = audio_ids.begin(); | 381 for (std::vector<std::string>::const_iterator audio_it = audio_ids.begin(); |
| 366 audio_it != audio_ids.end(); ++audio_it) { | 382 audio_it != audio_ids.end(); ++audio_it) { |
| 367 NavigateToURL(shell(), url); | 383 NavigateToURL(shell(), url); |
| 368 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult( | 384 EXPECT_EQ(kOK, ExecuteJavascriptAndReturnResult( |
| 369 GenerateGetUserMediaWithMandatorySourceID( | 385 GenerateGetUserMediaWithMandatorySourceID( |
| 370 kGetUserMediaAndStop, | 386 kGetUserMediaAndStop, |
| 371 *audio_it, | 387 *audio_it, |
| 372 *video_it))); | 388 *video_it))); |
| 373 } | 389 } |
| 390 LOG(INFO) << "Tested one combination; " << timer_.Elapsed().InSeconds() | |
| 391 << " seconds elapsed."; | |
| 374 } | 392 } |
| 393 | |
| 394 LOG(INFO) << "End test body; " << timer_.Elapsed().InSeconds() | |
| 395 << " seconds elapsed."; | |
| 375 } | 396 } |
| 376 | 397 |
| 377 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, | 398 IN_PROC_BROWSER_TEST_P(WebRtcGetUserMediaBrowserTest, |
| 378 GetUserMediaWithInvalidMandatorySourceID) { | 399 GetUserMediaWithInvalidMandatorySourceID) { |
| 379 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 400 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
| 380 | 401 |
| 381 std::vector<std::string> audio_ids; | 402 std::vector<std::string> audio_ids; |
| 382 std::vector<std::string> video_ids; | 403 std::vector<std::string> video_ids; |
| 383 GetInputDevices(&audio_ids, &video_ids); | 404 GetInputDevices(&audio_ids, &video_ids); |
| 384 | 405 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 625 {640, 640, 360, 360, 10, 30}, | 646 {640, 640, 360, 360, 10, 30}, |
| 626 {640, 640, 480, 480, 10, 30}, | 647 {640, 640, 480, 480, 10, 30}, |
| 627 {960, 960, 720, 720, 10, 30}, | 648 {960, 960, 720, 720, 10, 30}, |
| 628 {1280, 1280, 720, 720, 10, 30}}; | 649 {1280, 1280, 720, 720, 10, 30}}; |
| 629 | 650 |
| 630 INSTANTIATE_TEST_CASE_P(UserMedia, | 651 INSTANTIATE_TEST_CASE_P(UserMedia, |
| 631 WebRtcConstraintsBrowserTest, | 652 WebRtcConstraintsBrowserTest, |
| 632 testing::ValuesIn(kAllUserMediaSizes)); | 653 testing::ValuesIn(kAllUserMediaSizes)); |
| 633 | 654 |
| 634 } // namespace content | 655 } // namespace content |
| OLD | NEW |