OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" | 10 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 return value.find(switch_string) != std::string::npos; | 40 return value.find(switch_string) != std::string::npos; |
41 }), | 41 }), |
42 argv.end()); | 42 argv.end()); |
43 command_line->InitFromArgv(argv); | 43 command_line->InitFromArgv(argv); |
44 } | 44 } |
45 | 45 |
46 } // namespace | 46 } // namespace |
47 | 47 |
48 namespace content { | 48 namespace content { |
49 | 49 |
| 50 template <int device_count> |
50 class WebRtcDepthCaptureBrowserTest : public WebRtcContentBrowserTestBase { | 51 class WebRtcDepthCaptureBrowserTest : public WebRtcContentBrowserTestBase { |
51 public: | 52 public: |
52 WebRtcDepthCaptureBrowserTest() { | 53 WebRtcDepthCaptureBrowserTest() { |
53 // Automatically grant device permission. | 54 // Automatically grant device permission. |
54 AppendUseFakeUIForMediaStreamFlag(); | 55 AppendUseFakeUIForMediaStreamFlag(); |
55 } | 56 } |
56 ~WebRtcDepthCaptureBrowserTest() override {} | 57 ~WebRtcDepthCaptureBrowserTest() override {} |
57 | 58 |
58 void SetUpCommandLine(base::CommandLine* command_line) override { | 59 void SetUpCommandLine(base::CommandLine* command_line) override { |
59 // Test using two video capture devices - a color and a 16-bit depth device. | |
60 // By default, command line argument is present with no value. We need to | 60 // By default, command line argument is present with no value. We need to |
61 // remove it and then add the value defining two video capture devices. | 61 // remove it and then add the value defining two video capture devices. |
62 const std::string fake_device_switch = | 62 const std::string fake_device_switch = |
63 switches::kUseFakeDeviceForMediaStream; | 63 switches::kUseFakeDeviceForMediaStream; |
64 ASSERT_TRUE(command_line->HasSwitch(fake_device_switch) && | 64 ASSERT_TRUE(command_line->HasSwitch(fake_device_switch) && |
65 command_line->GetSwitchValueASCII(fake_device_switch).empty()); | 65 command_line->GetSwitchValueASCII(fake_device_switch).empty()); |
66 RemoveSwitchFromCommandLine(command_line, fake_device_switch); | 66 RemoveSwitchFromCommandLine(command_line, fake_device_switch); |
67 command_line->AppendSwitchASCII(fake_device_switch, "device-count=2"); | 67 command_line->AppendSwitchASCII( |
| 68 fake_device_switch, |
| 69 base::StringPrintf("device-count=%d", device_count)); |
68 WebRtcContentBrowserTestBase::SetUpCommandLine(command_line); | 70 WebRtcContentBrowserTestBase::SetUpCommandLine(command_line); |
69 } | 71 } |
70 }; | 72 }; |
71 | 73 |
72 IN_PROC_BROWSER_TEST_F(WebRtcDepthCaptureBrowserTest, | 74 // Test using two video capture devices - a color and a 16-bit depth device. |
| 75 using WebRtcTwoDeviceDepthCaptureBrowserTest = WebRtcDepthCaptureBrowserTest<2>; |
| 76 |
| 77 // Test using only a color device. |
| 78 using WebRtcOneDeviceDepthCaptureBrowserTest = WebRtcDepthCaptureBrowserTest<1>; |
| 79 |
| 80 IN_PROC_BROWSER_TEST_F(WebRtcTwoDeviceDepthCaptureBrowserTest, |
73 GetDepthStreamAndCallCreateImageBitmap) { | 81 GetDepthStreamAndCallCreateImageBitmap) { |
74 ASSERT_TRUE(embedded_test_server()->Start()); | 82 ASSERT_TRUE(embedded_test_server()->Start()); |
75 | 83 |
76 GURL url( | 84 GURL url( |
77 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); | 85 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); |
78 NavigateToURL(shell(), url); | 86 NavigateToURL(shell(), url); |
79 | 87 |
80 ExecuteJavascriptAndWaitForOk(base::StringPrintf( | 88 ExecuteJavascriptAndWaitForOk(base::StringPrintf( |
81 "%s({video: true});", kGetDepthStreamAndCallCreateImageBitmap)); | 89 "%s({video: true});", kGetDepthStreamAndCallCreateImageBitmap)); |
82 } | 90 } |
83 | 91 |
84 IN_PROC_BROWSER_TEST_F(WebRtcDepthCaptureBrowserTest, | 92 IN_PROC_BROWSER_TEST_F(WebRtcTwoDeviceDepthCaptureBrowserTest, |
85 GetDepthStreamAndCameraCalibration) { | 93 GetDepthStreamAndCameraCalibration) { |
86 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 94 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
87 command_line->AppendSwitchASCII("--enable-blink-features", | 95 command_line->AppendSwitchASCII("--enable-blink-features", |
88 "MediaGetSettings,MediaCaptureDepth"); | 96 "MediaGetSettings,MediaCaptureDepth"); |
89 | 97 |
90 ASSERT_TRUE(embedded_test_server()->Start()); | 98 ASSERT_TRUE(embedded_test_server()->Start()); |
91 | 99 |
92 GURL url( | 100 GURL url( |
93 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); | 101 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); |
94 NavigateToURL(shell(), url); | 102 NavigateToURL(shell(), url); |
95 | 103 |
96 ExecuteJavascriptAndWaitForOk(base::StringPrintf( | 104 ExecuteJavascriptAndWaitForOk(base::StringPrintf( |
97 "%s({video: true});", kGetDepthStreamAndCameraCalibration)); | 105 "%s({video: true});", kGetDepthStreamAndCameraCalibration)); |
98 } | 106 } |
99 | 107 |
100 IN_PROC_BROWSER_TEST_F(WebRtcDepthCaptureBrowserTest, | 108 IN_PROC_BROWSER_TEST_F(WebRtcTwoDeviceDepthCaptureBrowserTest, |
101 GetBothStreamsAndCheckForFeaturesPresence) { | 109 GetBothStreamsAndCheckForFeaturesPresence) { |
102 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 110 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
103 command_line->AppendSwitchASCII("--enable-blink-features", | 111 command_line->AppendSwitchASCII("--enable-blink-features", |
104 "MediaGetSettings,MediaCaptureDepth"); | 112 "MediaGetSettings,MediaCaptureDepth"); |
105 | 113 |
106 ASSERT_TRUE(embedded_test_server()->Start()); | 114 ASSERT_TRUE(embedded_test_server()->Start()); |
107 | 115 |
108 GURL url( | 116 GURL url( |
109 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); | 117 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); |
110 NavigateToURL(shell(), url); | 118 NavigateToURL(shell(), url); |
111 | 119 |
112 ExecuteJavascriptAndWaitForOk(base::StringPrintf( | 120 ExecuteJavascriptAndWaitForOk(base::StringPrintf( |
113 "%s({video: true});", kGetBothStreamsAndCheckForFeaturesPresence)); | 121 "%s({video: true});", kGetBothStreamsAndCheckForFeaturesPresence)); |
114 } | 122 } |
115 | 123 |
116 IN_PROC_BROWSER_TEST_F(WebRtcDepthCaptureBrowserTest, GetStreamsByVideoKind) { | 124 IN_PROC_BROWSER_TEST_F(WebRtcTwoDeviceDepthCaptureBrowserTest, |
| 125 GetStreamsByVideoKind) { |
117 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 126 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
118 command_line->AppendSwitchASCII("--enable-blink-features", | 127 command_line->AppendSwitchASCII("--enable-blink-features", |
119 "MediaGetSettings,MediaCaptureDepth"); | 128 "MediaGetSettings,MediaCaptureDepth"); |
120 | 129 |
121 ASSERT_TRUE(embedded_test_server()->Start()); | 130 ASSERT_TRUE(embedded_test_server()->Start()); |
122 | 131 |
123 GURL url( | 132 GURL url( |
124 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); | 133 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); |
125 NavigateToURL(shell(), url); | 134 NavigateToURL(shell(), url); |
126 | 135 |
127 ExecuteJavascriptAndWaitForOk( | 136 ExecuteJavascriptAndWaitForOk( |
128 base::StringPrintf("%s({video: true});", kGetStreamsByVideoKind)); | 137 base::StringPrintf("%s({video: true});", kGetStreamsByVideoKind)); |
129 } | 138 } |
130 | 139 |
131 IN_PROC_BROWSER_TEST_F(WebRtcDepthCaptureBrowserTest, | 140 IN_PROC_BROWSER_TEST_F(WebRtcOneDeviceDepthCaptureBrowserTest, |
132 GetStreamsByVideoKindNoDepth) { | 141 GetStreamsByVideoKindNoDepth) { |
133 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 142 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
134 // Set fake factory to have only one device, of type "color". | |
135 RemoveSwitchFromCommandLine(command_line, | |
136 switches::kUseFakeDeviceForMediaStream); | |
137 command_line->AppendSwitchASCII(switches::kUseFakeDeviceForMediaStream, | |
138 "device-count=1"); | |
139 command_line->AppendSwitchASCII("--enable-blink-features", | 143 command_line->AppendSwitchASCII("--enable-blink-features", |
140 "MediaGetSettings,MediaCaptureDepth"); | 144 "MediaGetSettings,MediaCaptureDepth"); |
141 | 145 |
142 ASSERT_TRUE(embedded_test_server()->Start()); | 146 ASSERT_TRUE(embedded_test_server()->Start()); |
143 | 147 |
144 GURL url( | 148 GURL url( |
145 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); | 149 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); |
146 NavigateToURL(shell(), url); | 150 NavigateToURL(shell(), url); |
147 | 151 |
148 ExecuteJavascriptAndWaitForOk( | 152 ExecuteJavascriptAndWaitForOk( |
149 base::StringPrintf("%s({video: true});", kGetStreamsByVideoKindNoDepth)); | 153 base::StringPrintf("%s({video: true});", kGetStreamsByVideoKindNoDepth)); |
150 } | 154 } |
151 | 155 |
152 } // namespace content | 156 } // namespace content |
OLD | NEW |