| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <stddef.h> |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" |
| 9 #include "content/public/test/browser_test_utils.h" |
| 10 #include "content/public/test/content_browser_test_utils.h" |
| 11 #include "content/public/test/test_utils.h" |
| 12 #include "content/shell/browser/shell.h" |
| 13 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 14 |
| 15 #if defined(OS_WIN) |
| 16 #include "base/win/windows_version.h" |
| 17 #endif |
| 18 |
| 19 namespace { |
| 20 |
| 21 static const char kGetUserMediaAndStop[] = "getUserMediaAndStop"; |
| 22 |
| 23 static struct UserMediaSizes { |
| 24 int min_width; |
| 25 int max_width; |
| 26 int min_height; |
| 27 int max_height; |
| 28 int min_frame_rate; |
| 29 int max_frame_rate; |
| 30 } const kAllUserMediaSizes[] = { |
| 31 {320, 320, 180, 180, 10, 30}, |
| 32 {320, 320, 240, 240, 10, 30}, |
| 33 {640, 640, 360, 360, 10, 30}, |
| 34 {640, 640, 480, 480, 10, 30}, |
| 35 {960, 960, 720, 720, 10, 30}, |
| 36 {1280, 1280, 720, 720, 10, 30}}; |
| 37 |
| 38 } // namespace |
| 39 |
| 40 namespace content { |
| 41 |
| 42 class WebRtcConstraintsBrowserTest |
| 43 : public WebRtcContentBrowserTestBase, |
| 44 public testing::WithParamInterface<UserMediaSizes> { |
| 45 public: |
| 46 WebRtcConstraintsBrowserTest() : user_media_(GetParam()) { |
| 47 // Automatically grant device permission. |
| 48 AppendUseFakeUIForMediaStreamFlag(); |
| 49 } |
| 50 const UserMediaSizes& user_media() const { return user_media_; } |
| 51 |
| 52 private: |
| 53 const UserMediaSizes user_media_; |
| 54 }; |
| 55 |
| 56 // Test fails under MSan, http://crbug.com/445745 |
| 57 #if defined(MEMORY_SANITIZER) |
| 58 #define MAYBE_GetUserMediaConstraints DISABLED_GetUserMediaConstraints |
| 59 #else |
| 60 #define MAYBE_GetUserMediaConstraints GetUserMediaConstraints |
| 61 #endif |
| 62 // This test calls getUserMedia in sequence with different constraints. |
| 63 IN_PROC_BROWSER_TEST_P(WebRtcConstraintsBrowserTest, |
| 64 MAYBE_GetUserMediaConstraints) { |
| 65 ASSERT_TRUE(embedded_test_server()->Start()); |
| 66 |
| 67 GURL url(embedded_test_server()->GetURL("/media/getusermedia.html")); |
| 68 |
| 69 std::string call = GenerateGetUserMediaCall(kGetUserMediaAndStop, |
| 70 user_media().min_width, |
| 71 user_media().max_width, |
| 72 user_media().min_height, |
| 73 user_media().max_height, |
| 74 user_media().min_frame_rate, |
| 75 user_media().max_frame_rate); |
| 76 DVLOG(1) << "Calling getUserMedia: " << call; |
| 77 NavigateToURL(shell(), url); |
| 78 ExecuteJavascriptAndWaitForOk(call); |
| 79 } |
| 80 |
| 81 INSTANTIATE_TEST_CASE_P(UserMedia, |
| 82 WebRtcConstraintsBrowserTest, |
| 83 testing::ValuesIn(kAllUserMediaSizes)); |
| 84 |
| 85 } // namespace content |
| OLD | NEW |