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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/test/scoped_feature_list.h" |
6 #include "build/build_config.h" | 7 #include "build/build_config.h" |
7 #include "content/browser/webrtc/webrtc_webcam_browsertest.h" | 8 #include "content/browser/webrtc/webrtc_webcam_browsertest.h" |
8 #include "content/public/common/content_switches.h" | 9 #include "content/public/common/content_switches.h" |
9 #include "content/public/test/browser_test_utils.h" | 10 #include "content/public/test/browser_test_utils.h" |
10 #include "content/public/test/content_browser_test.h" | 11 #include "content/public/test/content_browser_test.h" |
11 #include "content/public/test/content_browser_test_utils.h" | 12 #include "content/public/test/content_browser_test_utils.h" |
12 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
13 #include "content/shell/browser/shell.h" | 14 #include "content/shell/browser/shell.h" |
14 #include "media/base/media_switches.h" | 15 #include "media/base/media_switches.h" |
15 #include "media/capture/video/fake_video_capture_device_factory.h" | 16 #include "media/capture/video/fake_video_capture_device_factory.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 DISALLOW_COPY_AND_ASSIGN(WebRtcImageCaptureBrowserTestBase); | 126 DISALLOW_COPY_AND_ASSIGN(WebRtcImageCaptureBrowserTestBase); |
126 }; | 127 }; |
127 | 128 |
128 // Test fixture for setting up a capture device (real or fake) that successfully | 129 // Test fixture for setting up a capture device (real or fake) that successfully |
129 // serves all image capture requests. | 130 // serves all image capture requests. |
130 class WebRtcImageCaptureSucceedsBrowserTest | 131 class WebRtcImageCaptureSucceedsBrowserTest |
131 : public WebRtcImageCaptureBrowserTestBase, | 132 : public WebRtcImageCaptureBrowserTestBase, |
132 public testing::WithParamInterface< | 133 public testing::WithParamInterface< |
133 std::tuple<TargetCamera, TargetVideoCaptureStack>> { | 134 std::tuple<TargetCamera, TargetVideoCaptureStack>> { |
134 public: | 135 public: |
135 WebRtcImageCaptureSucceedsBrowserTest() = default; | 136 WebRtcImageCaptureSucceedsBrowserTest() { |
| 137 if (std::get<1>(GetParam()).use_video_capture_service) { |
| 138 scoped_feature_list_.InitAndEnableFeature( |
| 139 video_capture::kMojoVideoCapture); |
| 140 } |
| 141 } |
| 142 |
136 ~WebRtcImageCaptureSucceedsBrowserTest() override = default; | 143 ~WebRtcImageCaptureSucceedsBrowserTest() override = default; |
137 | 144 |
138 void SetUpCommandLine(base::CommandLine* command_line) override { | 145 void SetUpCommandLine(base::CommandLine* command_line) override { |
139 WebRtcImageCaptureBrowserTestBase::SetUpCommandLine(command_line); | 146 WebRtcImageCaptureBrowserTestBase::SetUpCommandLine(command_line); |
140 | 147 |
141 if (std::get<0>(GetParam()).use_fake) { | 148 if (std::get<0>(GetParam()).use_fake) { |
142 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 149 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
143 switches::kUseFakeDeviceForMediaStream); | 150 switches::kUseFakeDeviceForMediaStream); |
144 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( | 151 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( |
145 switches::kUseFakeDeviceForMediaStream)); | 152 switches::kUseFakeDeviceForMediaStream)); |
146 } | 153 } |
147 if (std::get<1>(GetParam()).use_video_capture_service) { | |
148 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
149 switches::kEnableFeatures, video_capture::kMojoVideoCapture.name); | |
150 } | |
151 } | 154 } |
152 | 155 |
153 bool RunImageCaptureTestCase(const std::string& command) override { | 156 bool RunImageCaptureTestCase(const std::string& command) override { |
154 // TODO(chfremer): Enable test cases using the video capture service with | 157 // TODO(chfremer): Enable test cases using the video capture service with |
155 // real cameras as soon as root cause for https://crbug.com/733582 is | 158 // real cameras as soon as root cause for https://crbug.com/733582 is |
156 // understood and resolved. | 159 // understood and resolved. |
157 if ((!std::get<0>(GetParam()).use_fake) && | 160 if ((!std::get<0>(GetParam()).use_fake) && |
158 (std::get<1>(GetParam()).use_video_capture_service)) { | 161 (std::get<1>(GetParam()).use_video_capture_service)) { |
159 LOG(INFO) << "Skipping this test case"; | 162 LOG(INFO) << "Skipping this test case"; |
160 return true; | 163 return true; |
161 } | 164 } |
162 return WebRtcImageCaptureBrowserTestBase::RunImageCaptureTestCase(command); | 165 return WebRtcImageCaptureBrowserTestBase::RunImageCaptureTestCase(command); |
163 } | 166 } |
| 167 |
| 168 private: |
| 169 base::test::ScopedFeatureList scoped_feature_list_; |
164 }; | 170 }; |
165 | 171 |
166 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureSucceedsBrowserTest, | 172 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureSucceedsBrowserTest, |
167 MAYBE_GetPhotoCapabilities) { | 173 MAYBE_GetPhotoCapabilities) { |
168 embedded_test_server()->StartAcceptingConnections(); | 174 embedded_test_server()->StartAcceptingConnections(); |
169 ASSERT_TRUE( | 175 ASSERT_TRUE( |
170 RunImageCaptureTestCase("testCreateAndGetPhotoCapabilitiesSucceeds()")); | 176 RunImageCaptureTestCase("testCreateAndGetPhotoCapabilitiesSucceeds()")); |
171 } | 177 } |
172 | 178 |
173 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureSucceedsBrowserTest, | 179 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureSucceedsBrowserTest, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 testing::ValuesIn(kTargetVideoCaptureStacks))); | 218 testing::ValuesIn(kTargetVideoCaptureStacks))); |
213 | 219 |
214 // Test fixture template for setting up a fake device with a custom | 220 // Test fixture template for setting up a fake device with a custom |
215 // configuration. We are going to use this to set up fake devices that respond | 221 // configuration. We are going to use this to set up fake devices that respond |
216 // to invocation of various ImageCapture API calls with a failure response. | 222 // to invocation of various ImageCapture API calls with a failure response. |
217 template <typename FakeDeviceConfigTraits> | 223 template <typename FakeDeviceConfigTraits> |
218 class WebRtcImageCaptureCustomConfigFakeDeviceBrowserTest | 224 class WebRtcImageCaptureCustomConfigFakeDeviceBrowserTest |
219 : public WebRtcImageCaptureBrowserTestBase, | 225 : public WebRtcImageCaptureBrowserTestBase, |
220 public testing::WithParamInterface<TargetVideoCaptureStack> { | 226 public testing::WithParamInterface<TargetVideoCaptureStack> { |
221 public: | 227 public: |
| 228 WebRtcImageCaptureCustomConfigFakeDeviceBrowserTest() { |
| 229 if (GetParam().use_video_capture_service) { |
| 230 scoped_feature_list_.InitAndEnableFeature( |
| 231 video_capture::kMojoVideoCapture); |
| 232 } |
| 233 } |
| 234 |
222 void SetUpCommandLine(base::CommandLine* command_line) override { | 235 void SetUpCommandLine(base::CommandLine* command_line) override { |
223 WebRtcImageCaptureBrowserTestBase::SetUpCommandLine(command_line); | 236 WebRtcImageCaptureBrowserTestBase::SetUpCommandLine(command_line); |
224 | 237 |
225 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | 238 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
226 switches::kUseFakeDeviceForMediaStream, | 239 switches::kUseFakeDeviceForMediaStream, |
227 std::string("config=") + FakeDeviceConfigTraits::config()); | 240 std::string("config=") + FakeDeviceConfigTraits::config()); |
228 if (GetParam().use_video_capture_service) { | |
229 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( | |
230 switches::kEnableFeatures, video_capture::kMojoVideoCapture.name); | |
231 } | |
232 } | 241 } |
| 242 |
| 243 private: |
| 244 base::test::ScopedFeatureList scoped_feature_list_; |
233 }; | 245 }; |
234 | 246 |
235 struct GetPhotoStateFailsConfigTraits { | 247 struct GetPhotoStateFailsConfigTraits { |
236 static std::string config() { | 248 static std::string config() { |
237 return media::FakeVideoCaptureDeviceFactory:: | 249 return media::FakeVideoCaptureDeviceFactory:: |
238 kDeviceConfigForGetPhotoStateFails; | 250 kDeviceConfigForGetPhotoStateFails; |
239 } | 251 } |
240 }; | 252 }; |
241 | 253 |
242 using WebRtcImageCaptureGetPhotoStateFailsBrowserTest = | 254 using WebRtcImageCaptureGetPhotoStateFailsBrowserTest = |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureTakePhotoFailsBrowserTest, GrabFrame) { | 325 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureTakePhotoFailsBrowserTest, GrabFrame) { |
314 embedded_test_server()->StartAcceptingConnections(); | 326 embedded_test_server()->StartAcceptingConnections(); |
315 ASSERT_TRUE(RunImageCaptureTestCase("testCreateAndGrabFrameSucceeds()")); | 327 ASSERT_TRUE(RunImageCaptureTestCase("testCreateAndGrabFrameSucceeds()")); |
316 } | 328 } |
317 | 329 |
318 INSTANTIATE_TEST_CASE_P(, | 330 INSTANTIATE_TEST_CASE_P(, |
319 WebRtcImageCaptureTakePhotoFailsBrowserTest, | 331 WebRtcImageCaptureTakePhotoFailsBrowserTest, |
320 testing::ValuesIn(kTargetVideoCaptureStacks)); | 332 testing::ValuesIn(kTargetVideoCaptureStacks)); |
321 | 333 |
322 } // namespace content | 334 } // namespace content |
OLD | NEW |