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 "build/build_config.h" | 6 #include "build/build_config.h" |
7 #include "chrome/browser/media/webrtc_browsertest_base.h" | 7 #include "chrome/browser/media/webrtc_browsertest_base.h" |
8 #include "chrome/browser/media/webrtc_browsertest_common.h" | 8 #include "chrome/browser/media/webrtc_browsertest_common.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/common/content_switches.h" | 15 #include "content/public/common/content_switches.h" |
16 #include "content/public/test/browser_test_utils.h" | 16 #include "content/public/test/browser_test_utils.h" |
17 #include "media/base/media_switches.h" | 17 #include "media/base/media_switches.h" |
18 #include "net/test/embedded_test_server/embedded_test_server.h" | 18 #include "net/test/embedded_test_server/embedded_test_server.h" |
19 #include "testing/gtest/include/gtest/gtest-param-test.h" | 19 #include "testing/gtest/include/gtest/gtest-param-test.h" |
20 | 20 |
21 static const char kMainWebrtcTestHtmlPage[] = | 21 static const char kMainWebrtcTestHtmlPage[] = |
22 "/webrtc/webrtc_jsep01_test.html"; | 22 "/webrtc/webrtc_jsep01_test.html"; |
23 | 23 |
24 static const char* kTestConfigFlags[] = { | 24 static const char* kTestConfigFlags[] = { |
25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
26 NULL, | 26 NULL, |
27 // Media Foundation is only available in Windows versions >= 7, below that the | 27 // Media Foundation is only available in Windows versions >= 7, below that the |
28 // following flag has no effect; the test would run twice using DirectShow. | 28 // following flag has no effect; the test would run twice using DirectShow. |
29 switches::kForceMediaFoundationVideoCapture | 29 switches::kForceMediaFoundationVideoCapture |
30 #elif defined(OS_MACOSX) | |
31 switches::kForceQTKit, | |
32 switches::kEnableAVFoundation | |
33 #else | 30 #else |
34 NULL | 31 NULL |
35 #endif | 32 #endif |
36 }; | 33 }; |
37 | 34 |
38 // These tests runs on real webcams and ensure WebRTC can acquire webcams | 35 // These tests runs on real webcams and ensure WebRTC can acquire webcams |
39 // correctly. They will do nothing if there are no webcams on the system. | 36 // correctly. They will do nothing if there are no webcams on the system. |
40 // The webcam on the system must support up to 1080p, or the test will fail. | 37 // The webcam on the system must support up to 1080p, or the test will fail. |
41 // This test is excellent for testing the various capture paths of WebRTC | 38 // This test is excellent for testing the various capture paths of WebRTC |
42 // on all desktop platforms. | 39 // on all desktop platforms. |
(...skipping 19 matching lines...) Expand all Loading... |
62 std::string actual_stream_size; | 59 std::string actual_stream_size; |
63 if (GetUserMediaWithSpecificConstraintsAndAcceptIfPrompted(tab, | 60 if (GetUserMediaWithSpecificConstraintsAndAcceptIfPrompted(tab, |
64 constraints)) { | 61 constraints)) { |
65 StartDetectingVideo(tab, "local-view"); | 62 StartDetectingVideo(tab, "local-view"); |
66 if (WaitForVideoToPlay(tab)) | 63 if (WaitForVideoToPlay(tab)) |
67 actual_stream_size = GetStreamSize(tab, "local-view"); | 64 actual_stream_size = GetStreamSize(tab, "local-view"); |
68 CloseLastLocalStream(tab); | 65 CloseLastLocalStream(tab); |
69 } | 66 } |
70 return actual_stream_size; | 67 return actual_stream_size; |
71 } | 68 } |
72 | |
73 bool IsOnQtKit() const { | |
74 #if defined(OS_MACOSX) | |
75 return GetParam() && std::string(GetParam()) == switches::kForceQTKit; | |
76 #else | |
77 return false; | |
78 #endif | |
79 } | |
80 }; | 69 }; |
81 | 70 |
82 // This test is manual because the test results can vary heavily depending on | 71 // This test is manual because the test results can vary heavily depending on |
83 // which webcam or drivers you have on the system. | 72 // which webcam or drivers you have on the system. |
84 IN_PROC_BROWSER_TEST_P(WebRtcWebcamBrowserTest, | 73 IN_PROC_BROWSER_TEST_P(WebRtcWebcamBrowserTest, |
85 MANUAL_TestAcquiringAndReacquiringWebcam) { | 74 MANUAL_TestAcquiringAndReacquiringWebcam) { |
86 ASSERT_TRUE(embedded_test_server()->Start()); | 75 ASSERT_TRUE(embedded_test_server()->Start()); |
87 GURL url(embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage)); | 76 GURL url(embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage)); |
88 ui_test_utils::NavigateToURL(browser(), url); | 77 ui_test_utils::NavigateToURL(browser(), url); |
89 content::WebContents* tab = | 78 content::WebContents* tab = |
90 browser()->tab_strip_model()->GetActiveWebContents(); | 79 browser()->tab_strip_model()->GetActiveWebContents(); |
91 | 80 |
92 if (!HasWebcamAvailableOnSystem(tab)) { | 81 if (!HasWebcamAvailableOnSystem(tab)) { |
93 LOG(INFO) << "No webcam found on bot: skipping..."; | 82 LOG(INFO) << "No webcam found on bot: skipping..."; |
94 return; | 83 return; |
95 } | 84 } |
96 | 85 |
97 if (!IsOnQtKit()) { | 86 EXPECT_EQ("320x240", |
98 // "Temporarily" disabled on QtKit due to http://crbug.com/375185. | 87 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraintsQVGA)); |
99 EXPECT_EQ("320x240", | |
100 GetUserMediaAndGetStreamSize(tab, | |
101 kVideoCallConstraintsQVGA)); | |
102 } | |
103 | |
104 EXPECT_EQ("640x480", | 88 EXPECT_EQ("640x480", |
105 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraintsVGA)); | 89 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraintsVGA)); |
106 EXPECT_EQ("640x360", | 90 EXPECT_EQ("640x360", |
107 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints360p)); | 91 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints360p)); |
108 | |
109 // QTKit supports up to 480p (used to support 720p until crbug.com/440762). | |
110 if (IsOnQtKit()) | |
111 return; | |
112 | |
113 EXPECT_EQ("1280x720", | 92 EXPECT_EQ("1280x720", |
114 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints720p)); | 93 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints720p)); |
115 EXPECT_EQ("1920x1080", | 94 EXPECT_EQ("1920x1080", |
116 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints1080p)); | 95 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints1080p)); |
117 } | 96 } |
118 | 97 |
119 INSTANTIATE_TEST_CASE_P(WebRtcWebcamBrowserTests, | 98 INSTANTIATE_TEST_CASE_P(WebRtcWebcamBrowserTests, |
120 WebRtcWebcamBrowserTest, | 99 WebRtcWebcamBrowserTest, |
121 testing::ValuesIn(kTestConfigFlags)); | 100 testing::ValuesIn(kTestConfigFlags)); |
OLD | NEW |