Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(537)

Side by Side Diff: content/browser/webrtc/webrtc_image_capture_browsertest.cc

Issue 2910843002: [Cleanup] Move all browsertests to use ScopedFeatureList to modify features
Patch Set: comments addressed and updated Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
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() = default;
136 ~WebRtcImageCaptureSucceedsBrowserTest() override = default; 137 ~WebRtcImageCaptureSucceedsBrowserTest() override = default;
137 138
139 void SetUp() override {
140 if (std::get<1>(GetParam()).use_video_capture_service) {
141 scoped_feature_list_.InitAndEnableFeature(
142 video_capture::kMojoVideoCapture);
143 }
144 WebRtcImageCaptureBrowserTestBase::SetUp();
145 }
146
138 void SetUpCommandLine(base::CommandLine* command_line) override { 147 void SetUpCommandLine(base::CommandLine* command_line) override {
139 WebRtcImageCaptureBrowserTestBase::SetUpCommandLine(command_line); 148 WebRtcImageCaptureBrowserTestBase::SetUpCommandLine(command_line);
140 149
141 if (std::get<0>(GetParam()).use_fake) { 150 if (std::get<0>(GetParam()).use_fake) {
142 base::CommandLine::ForCurrentProcess()->AppendSwitch( 151 base::CommandLine::ForCurrentProcess()->AppendSwitch(
143 switches::kUseFakeDeviceForMediaStream); 152 switches::kUseFakeDeviceForMediaStream);
144 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( 153 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
145 switches::kUseFakeDeviceForMediaStream)); 154 switches::kUseFakeDeviceForMediaStream));
146 } 155 }
147 if (std::get<1>(GetParam()).use_video_capture_service) {
148 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
149 switches::kEnableFeatures, video_capture::kMojoVideoCapture.name);
150 }
151 } 156 }
152 157
153 bool RunImageCaptureTestCase(const std::string& command) override { 158 bool RunImageCaptureTestCase(const std::string& command) override {
154 // TODO(chfremer): Enable test cases using the video capture service with 159 // 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 160 // real cameras as soon as root cause for https://crbug.com/733582 is
156 // understood and resolved. 161 // understood and resolved.
157 if ((!std::get<0>(GetParam()).use_fake) && 162 if ((!std::get<0>(GetParam()).use_fake) &&
158 (std::get<1>(GetParam()).use_video_capture_service)) { 163 (std::get<1>(GetParam()).use_video_capture_service)) {
159 LOG(INFO) << "Skipping this test case"; 164 LOG(INFO) << "Skipping this test case";
160 return true; 165 return true;
161 } 166 }
162 return WebRtcImageCaptureBrowserTestBase::RunImageCaptureTestCase(command); 167 return WebRtcImageCaptureBrowserTestBase::RunImageCaptureTestCase(command);
163 } 168 }
169
170 private:
171 base::test::ScopedFeatureList scoped_feature_list_;
164 }; 172 };
165 173
166 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureSucceedsBrowserTest, 174 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureSucceedsBrowserTest,
167 MAYBE_GetPhotoCapabilities) { 175 MAYBE_GetPhotoCapabilities) {
168 embedded_test_server()->StartAcceptingConnections(); 176 embedded_test_server()->StartAcceptingConnections();
169 ASSERT_TRUE( 177 ASSERT_TRUE(
170 RunImageCaptureTestCase("testCreateAndGetPhotoCapabilitiesSucceeds()")); 178 RunImageCaptureTestCase("testCreateAndGetPhotoCapabilitiesSucceeds()"));
171 } 179 }
172 180
173 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureSucceedsBrowserTest, 181 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureSucceedsBrowserTest,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 testing::ValuesIn(kTargetVideoCaptureStacks))); 220 testing::ValuesIn(kTargetVideoCaptureStacks)));
213 221
214 // Test fixture template for setting up a fake device with a custom 222 // 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 223 // 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. 224 // to invocation of various ImageCapture API calls with a failure response.
217 template <typename FakeDeviceConfigTraits> 225 template <typename FakeDeviceConfigTraits>
218 class WebRtcImageCaptureCustomConfigFakeDeviceBrowserTest 226 class WebRtcImageCaptureCustomConfigFakeDeviceBrowserTest
219 : public WebRtcImageCaptureBrowserTestBase, 227 : public WebRtcImageCaptureBrowserTestBase,
220 public testing::WithParamInterface<TargetVideoCaptureStack> { 228 public testing::WithParamInterface<TargetVideoCaptureStack> {
221 public: 229 public:
230 void SetUp() override {
231 if (GetParam().use_video_capture_service) {
232 scoped_feature_list_.InitAndEnableFeature(
233 video_capture::kMojoVideoCapture);
234 }
235 WebRtcImageCaptureBrowserTestBase::SetUp();
236 }
237
222 void SetUpCommandLine(base::CommandLine* command_line) override { 238 void SetUpCommandLine(base::CommandLine* command_line) override {
223 WebRtcImageCaptureBrowserTestBase::SetUpCommandLine(command_line); 239 WebRtcImageCaptureBrowserTestBase::SetUpCommandLine(command_line);
224 240
225 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 241 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
226 switches::kUseFakeDeviceForMediaStream, 242 switches::kUseFakeDeviceForMediaStream,
227 std::string("config=") + FakeDeviceConfigTraits::config()); 243 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 } 244 }
245
246 private:
247 base::test::ScopedFeatureList scoped_feature_list_;
233 }; 248 };
234 249
235 struct GetPhotoStateFailsConfigTraits { 250 struct GetPhotoStateFailsConfigTraits {
236 static std::string config() { 251 static std::string config() {
237 return media::FakeVideoCaptureDeviceFactory:: 252 return media::FakeVideoCaptureDeviceFactory::
238 kDeviceConfigForGetPhotoStateFails; 253 kDeviceConfigForGetPhotoStateFails;
239 } 254 }
240 }; 255 };
241 256
242 using WebRtcImageCaptureGetPhotoStateFailsBrowserTest = 257 using WebRtcImageCaptureGetPhotoStateFailsBrowserTest =
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureTakePhotoFailsBrowserTest, GrabFrame) { 328 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureTakePhotoFailsBrowserTest, GrabFrame) {
314 embedded_test_server()->StartAcceptingConnections(); 329 embedded_test_server()->StartAcceptingConnections();
315 ASSERT_TRUE(RunImageCaptureTestCase("testCreateAndGrabFrameSucceeds()")); 330 ASSERT_TRUE(RunImageCaptureTestCase("testCreateAndGrabFrameSucceeds()"));
316 } 331 }
317 332
318 INSTANTIATE_TEST_CASE_P(, 333 INSTANTIATE_TEST_CASE_P(,
319 WebRtcImageCaptureTakePhotoFailsBrowserTest, 334 WebRtcImageCaptureTakePhotoFailsBrowserTest,
320 testing::ValuesIn(kTargetVideoCaptureStacks)); 335 testing::ValuesIn(kTargetVideoCaptureStacks));
321 336
322 } // namespace content 337 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698