| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/feature_list.h" | 8 #include "base/feature_list.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/memory/ref_counted_memory.h" | 10 #include "base/memory/ref_counted_memory.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 return expect_value == controls.disable_local_echo; | 99 return expect_value == controls.disable_local_echo; |
| 100 } | 100 } |
| 101 | 101 |
| 102 } // namespace | 102 } // namespace |
| 103 | 103 |
| 104 namespace content { | 104 namespace content { |
| 105 | 105 |
| 106 class WebRtcGetUserMediaBrowserTest : public WebRtcContentBrowserTestBase { | 106 class WebRtcGetUserMediaBrowserTest : public WebRtcContentBrowserTestBase { |
| 107 public: | 107 public: |
| 108 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) { | 108 WebRtcGetUserMediaBrowserTest() : trace_log_(NULL) { |
| 109 scoped_feature_list_.InitAndDisableFeature( | 109 scoped_feature_list_.InitWithFeatures( |
| 110 features::kMediaStreamOldVideoConstraints); | 110 {}, {features::kMediaStreamOldVideoConstraints, |
| 111 features::kMediaStreamOldAudioConstraints}); |
| 111 // Automatically grant device permission. | 112 // Automatically grant device permission. |
| 112 AppendUseFakeUIForMediaStreamFlag(); | 113 AppendUseFakeUIForMediaStreamFlag(); |
| 113 } | 114 } |
| 114 ~WebRtcGetUserMediaBrowserTest() override {} | 115 ~WebRtcGetUserMediaBrowserTest() override {} |
| 115 | 116 |
| 116 void StartTracing() { | 117 void StartTracing() { |
| 117 CHECK(trace_log_ == NULL) << "Can only can start tracing once"; | 118 CHECK(trace_log_ == NULL) << "Can only can start tracing once"; |
| 118 trace_log_ = base::trace_event::TraceLog::GetInstance(); | 119 trace_log_ = base::trace_event::TraceLog::GetInstance(); |
| 119 base::trace_event::TraceConfig trace_config( | 120 base::trace_event::TraceConfig trace_config( |
| 120 "video", base::trace_event::RECORD_UNTIL_FULL); | 121 "video", base::trace_event::RECORD_UNTIL_FULL); |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 GetUserMediaWithInvalidMandatorySourceID) { | 414 GetUserMediaWithInvalidMandatorySourceID) { |
| 414 ASSERT_TRUE(embedded_test_server()->Start()); | 415 ASSERT_TRUE(embedded_test_server()->Start()); |
| 415 | 416 |
| 416 std::vector<std::string> audio_ids; | 417 std::vector<std::string> audio_ids; |
| 417 std::vector<std::string> video_ids; | 418 std::vector<std::string> video_ids; |
| 418 GetInputDevices(&audio_ids, &video_ids); | 419 GetInputDevices(&audio_ids, &video_ids); |
| 419 | 420 |
| 420 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | 421 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
| 421 | 422 |
| 422 // Test with invalid mandatory audio sourceID. | 423 // Test with invalid mandatory audio sourceID. |
| 423 // TODO(guidou): Update error string when spec-compliant constraint resolution | |
| 424 // for audio is implemented. See http://crbug.com/657733. | |
| 425 NavigateToURL(shell(), url); | 424 NavigateToURL(shell(), url); |
| 426 EXPECT_EQ("DevicesNotFoundError", ExecuteJavascriptAndReturnResult( | 425 EXPECT_EQ("ConstraintNotSatisfiedError", |
| 427 GenerateGetUserMediaWithMandatorySourceID( | 426 ExecuteJavascriptAndReturnResult( |
| 428 kGetUserMediaAndExpectFailure, | 427 GenerateGetUserMediaWithMandatorySourceID( |
| 429 "something invalid", | 428 kGetUserMediaAndExpectFailure, "something invalid", |
| 430 video_ids[0]))); | 429 video_ids[0]))); |
| 431 | 430 |
| 432 // Test with invalid mandatory video sourceID. | 431 // Test with invalid mandatory video sourceID. |
| 433 EXPECT_EQ("ConstraintNotSatisfiedError", | 432 EXPECT_EQ("ConstraintNotSatisfiedError", |
| 434 ExecuteJavascriptAndReturnResult( | 433 ExecuteJavascriptAndReturnResult( |
| 435 GenerateGetUserMediaWithMandatorySourceID( | 434 GenerateGetUserMediaWithMandatorySourceID( |
| 436 kGetUserMediaAndExpectFailure, audio_ids[0], | 435 kGetUserMediaAndExpectFailure, audio_ids[0], |
| 437 "something invalid"))); | 436 "something invalid"))); |
| 438 | 437 |
| 439 // Test with empty mandatory audio sourceID. | 438 // Test with empty mandatory audio sourceID. |
| 440 // TODO(guidou): Update error string when spec-compliant constraint resolution | 439 EXPECT_EQ("ConstraintNotSatisfiedError", |
| 441 // for audio is implemented. See http://crbug.com/657733. | 440 ExecuteJavascriptAndReturnResult( |
| 442 EXPECT_EQ("DevicesNotFoundError", ExecuteJavascriptAndReturnResult( | 441 GenerateGetUserMediaWithMandatorySourceID( |
| 443 GenerateGetUserMediaWithMandatorySourceID( | 442 kGetUserMediaAndExpectFailure, "", video_ids[0]))); |
| 444 kGetUserMediaAndExpectFailure, | |
| 445 "", | |
| 446 video_ids[0]))); | |
| 447 } | 443 } |
| 448 | 444 |
| 449 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, | 445 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaBrowserTest, |
| 450 GetUserMediaWithInvalidOptionalSourceID) { | 446 GetUserMediaWithInvalidOptionalSourceID) { |
| 451 ASSERT_TRUE(embedded_test_server()->Start()); | 447 ASSERT_TRUE(embedded_test_server()->Start()); |
| 452 | 448 |
| 453 std::vector<std::string> audio_ids; | 449 std::vector<std::string> audio_ids; |
| 454 std::vector<std::string> video_ids; | 450 std::vector<std::string> video_ids; |
| 455 GetInputDevices(&audio_ids, &video_ids); | 451 GetInputDevices(&audio_ids, &video_ids); |
| 456 | 452 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 | 787 |
| 792 manager->SetGenerateStreamCallbackForTesting( | 788 manager->SetGenerateStreamCallbackForTesting( |
| 793 MediaStreamManager::GenerateStreamTestCallback()); | 789 MediaStreamManager::GenerateStreamTestCallback()); |
| 794 } | 790 } |
| 795 | 791 |
| 796 // TODO(guidou): Remove this test. http://crbug.com/706408 | 792 // TODO(guidou): Remove this test. http://crbug.com/706408 |
| 797 class WebRtcGetUserMediaOldConstraintsBrowserTest | 793 class WebRtcGetUserMediaOldConstraintsBrowserTest |
| 798 : public WebRtcContentBrowserTestBase { | 794 : public WebRtcContentBrowserTestBase { |
| 799 public: | 795 public: |
| 800 WebRtcGetUserMediaOldConstraintsBrowserTest() : trace_log_(NULL) { | 796 WebRtcGetUserMediaOldConstraintsBrowserTest() : trace_log_(NULL) { |
| 801 scoped_feature_list_.InitAndEnableFeature( | 797 scoped_feature_list_.InitWithFeatures( |
| 802 features::kMediaStreamOldVideoConstraints); | 798 {features::kMediaStreamOldVideoConstraints, |
| 799 features::kMediaStreamOldAudioConstraints}, |
| 800 {}); |
| 803 // Automatically grant device permission. | 801 // Automatically grant device permission. |
| 804 AppendUseFakeUIForMediaStreamFlag(); | 802 AppendUseFakeUIForMediaStreamFlag(); |
| 805 } | 803 } |
| 806 ~WebRtcGetUserMediaOldConstraintsBrowserTest() override {} | 804 ~WebRtcGetUserMediaOldConstraintsBrowserTest() override {} |
| 807 | 805 |
| 808 void StartTracing() { | 806 void StartTracing() { |
| 809 CHECK(trace_log_ == NULL) << "Can only can start tracing once"; | 807 CHECK(trace_log_ == NULL) << "Can only can start tracing once"; |
| 810 trace_log_ = base::trace_event::TraceLog::GetInstance(); | 808 trace_log_ = base::trace_event::TraceLog::GetInstance(); |
| 811 base::trace_event::TraceConfig trace_config( | 809 base::trace_event::TraceConfig trace_config( |
| 812 "video", base::trace_event::RECORD_UNTIL_FULL); | 810 "video", base::trace_event::RECORD_UNTIL_FULL); |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1096 GetUserMediaWithInvalidMandatorySourceID) { | 1094 GetUserMediaWithInvalidMandatorySourceID) { |
| 1097 ASSERT_TRUE(embedded_test_server()->Start()); | 1095 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1098 | 1096 |
| 1099 std::vector<std::string> audio_ids; | 1097 std::vector<std::string> audio_ids; |
| 1100 std::vector<std::string> video_ids; | 1098 std::vector<std::string> video_ids; |
| 1101 GetInputDevices(&audio_ids, &video_ids); | 1099 GetInputDevices(&audio_ids, &video_ids); |
| 1102 | 1100 |
| 1103 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | 1101 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
| 1104 | 1102 |
| 1105 // Test with invalid mandatory audio sourceID. | 1103 // Test with invalid mandatory audio sourceID. |
| 1106 // TODO(guidou): Update error string when spec-compliant constraint resolution | |
| 1107 // for audio is implemented. See http://crbug.com/657733. | |
| 1108 NavigateToURL(shell(), url); | 1104 NavigateToURL(shell(), url); |
| 1109 EXPECT_EQ("DevicesNotFoundError", | 1105 EXPECT_EQ("DevicesNotFoundError", |
| 1110 ExecuteJavascriptAndReturnResult( | 1106 ExecuteJavascriptAndReturnResult( |
| 1111 GenerateGetUserMediaWithMandatorySourceID( | 1107 GenerateGetUserMediaWithMandatorySourceID( |
| 1112 kGetUserMediaAndExpectFailure, "something invalid", | 1108 kGetUserMediaAndExpectFailure, "something invalid", |
| 1113 video_ids[0]))); | 1109 video_ids[0]))); |
| 1114 | 1110 |
| 1115 // Test with invalid mandatory video sourceID. | 1111 // Test with invalid mandatory video sourceID. |
| 1116 EXPECT_EQ("ConstraintNotSatisfiedError", | 1112 EXPECT_EQ("ConstraintNotSatisfiedError", |
| 1117 ExecuteJavascriptAndReturnResult( | 1113 ExecuteJavascriptAndReturnResult( |
| 1118 GenerateGetUserMediaWithMandatorySourceID( | 1114 GenerateGetUserMediaWithMandatorySourceID( |
| 1119 kGetUserMediaAndExpectFailure, audio_ids[0], | 1115 kGetUserMediaAndExpectFailure, audio_ids[0], |
| 1120 "something invalid"))); | 1116 "something invalid"))); |
| 1121 | 1117 |
| 1122 // Test with empty mandatory audio sourceID. | 1118 // Test with empty mandatory audio sourceID. |
| 1123 // TODO(guidou): Update error string when spec-compliant constraint resolution | |
| 1124 // for audio is implemented. See http://crbug.com/657733. | |
| 1125 EXPECT_EQ("DevicesNotFoundError", | 1119 EXPECT_EQ("DevicesNotFoundError", |
| 1126 ExecuteJavascriptAndReturnResult( | 1120 ExecuteJavascriptAndReturnResult( |
| 1127 GenerateGetUserMediaWithMandatorySourceID( | 1121 GenerateGetUserMediaWithMandatorySourceID( |
| 1128 kGetUserMediaAndExpectFailure, "", video_ids[0]))); | 1122 kGetUserMediaAndExpectFailure, "", video_ids[0]))); |
| 1129 } | 1123 } |
| 1130 | 1124 |
| 1131 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaOldConstraintsBrowserTest, | 1125 IN_PROC_BROWSER_TEST_F(WebRtcGetUserMediaOldConstraintsBrowserTest, |
| 1132 GetUserMediaWithInvalidOptionalSourceID) { | 1126 GetUserMediaWithInvalidOptionalSourceID) { |
| 1133 ASSERT_TRUE(embedded_test_server()->Start()); | 1127 ASSERT_TRUE(embedded_test_server()->Start()); |
| 1134 | 1128 |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1445 base::Bind(&VerifyDisableLocalEcho, true)); | 1439 base::Bind(&VerifyDisableLocalEcho, true)); |
| 1446 call = GenerateGetUserMediaWithDisableLocalEcho( | 1440 call = GenerateGetUserMediaWithDisableLocalEcho( |
| 1447 "getUserMediaAndExpectSuccess", "true"); | 1441 "getUserMediaAndExpectSuccess", "true"); |
| 1448 ExecuteJavascriptAndWaitForOk(call); | 1442 ExecuteJavascriptAndWaitForOk(call); |
| 1449 | 1443 |
| 1450 manager->SetGenerateStreamCallbackForTesting( | 1444 manager->SetGenerateStreamCallbackForTesting( |
| 1451 MediaStreamManager::GenerateStreamTestCallback()); | 1445 MediaStreamManager::GenerateStreamTestCallback()); |
| 1452 } | 1446 } |
| 1453 | 1447 |
| 1454 } // namespace content | 1448 } // namespace content |
| OLD | NEW |