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