| 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/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/memory/ref_counted_memory.h" | 9 #include "base/memory/ref_counted_memory.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | 717 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
| 718 | 718 |
| 719 std::string call = | 719 std::string call = |
| 720 GenerateGetUserMediaWithMandatorySourceID( | 720 GenerateGetUserMediaWithMandatorySourceID( |
| 721 "getUserMediaInIframeAndCloseInFailureCb", "invalid", "invalid"); | 721 "getUserMediaInIframeAndCloseInFailureCb", "invalid", "invalid"); |
| 722 NavigateToURL(shell(), url); | 722 NavigateToURL(shell(), url); |
| 723 | 723 |
| 724 ExecuteJavascriptAndWaitForOk(call); | 724 ExecuteJavascriptAndWaitForOk(call); |
| 725 } | 725 } |
| 726 | 726 |
| 727 namespace { | |
| 728 | |
| 729 struct UserMediaSizes { | |
| 730 int min_width; | |
| 731 int max_width; | |
| 732 int min_height; | |
| 733 int max_height; | |
| 734 int min_frame_rate; | |
| 735 int max_frame_rate; | |
| 736 }; | |
| 737 | |
| 738 } // namespace | |
| 739 | |
| 740 class WebRtcConstraintsBrowserTest | |
| 741 : public WebRtcContentBrowserTestBase, | |
| 742 public testing::WithParamInterface<UserMediaSizes> { | |
| 743 public: | |
| 744 WebRtcConstraintsBrowserTest() : user_media_(GetParam()) { | |
| 745 // Automatically grant device permission. | |
| 746 AppendUseFakeUIForMediaStreamFlag(); | |
| 747 } | |
| 748 const UserMediaSizes& user_media() const { return user_media_; } | |
| 749 | |
| 750 private: | |
| 751 UserMediaSizes user_media_; | |
| 752 }; | |
| 753 | |
| 754 // Test fails under MSan, http://crbug.com/445745 | |
| 755 #if defined(MEMORY_SANITIZER) | |
| 756 #define MAYBE_GetUserMediaConstraints DISABLED_GetUserMediaConstraints | |
| 757 #else | |
| 758 #define MAYBE_GetUserMediaConstraints GetUserMediaConstraints | |
| 759 #endif | |
| 760 // This test calls getUserMedia in sequence with different constraints. | |
| 761 IN_PROC_BROWSER_TEST_P(WebRtcConstraintsBrowserTest, | |
| 762 MAYBE_GetUserMediaConstraints) { | |
| 763 ASSERT_TRUE(embedded_test_server()->Start()); | |
| 764 | |
| 765 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); | |
| 766 | |
| 767 std::string call = GenerateGetUserMediaCall(kGetUserMediaAndStop, | |
| 768 user_media().min_width, | |
| 769 user_media().max_width, | |
| 770 user_media().min_height, | |
| 771 user_media().max_height, | |
| 772 user_media().min_frame_rate, | |
| 773 user_media().max_frame_rate); | |
| 774 DVLOG(1) << "Calling getUserMedia: " << call; | |
| 775 NavigateToURL(shell(), url); | |
| 776 ExecuteJavascriptAndWaitForOk(call); | |
| 777 } | |
| 778 | |
| 779 static const UserMediaSizes kAllUserMediaSizes[] = { | |
| 780 {320, 320, 180, 180, 10, 30}, | |
| 781 {320, 320, 240, 240, 10, 30}, | |
| 782 {640, 640, 360, 360, 10, 30}, | |
| 783 {640, 640, 480, 480, 10, 30}, | |
| 784 {960, 960, 720, 720, 10, 30}, | |
| 785 {1280, 1280, 720, 720, 10, 30}}; | |
| 786 | |
| 787 INSTANTIATE_TEST_CASE_P(UserMedia, | |
| 788 WebRtcConstraintsBrowserTest, | |
| 789 testing::ValuesIn(kAllUserMediaSizes)); | |
| 790 | |
| 791 } // namespace content | 727 } // namespace content |
| OLD | NEW |