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

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

Issue 2190523004: ImageCapture: content_browsertest WebRtcImageCaptureBrowserTest CreateAndGetCapabilities (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed test entry for real-world capture device, leaving just FakeVCD Created 4 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "content/browser/media/webrtc/webrtc_webcam_browsertest.h"
7 #include "content/public/common/content_switches.h"
8 #include "content/public/test/browser_test_utils.h"
9 #include "content/public/test/content_browser_test.h"
10 #include "content/public/test/content_browser_test_utils.h"
11 #include "content/public/test/test_utils.h"
12 #include "media/base/media_switches.h"
13 #include "net/test/embedded_test_server/embedded_test_server.h"
14
15 namespace {
16
17 static const char kImageCaptureHtmlFile[] = "/media/image_capture_test.html";
18
19 // TODO(mcasas): enable real-camera tests by disabling the Fake Device for
20 // platforms where the ImageCaptureCode is landed, https://crbug.com/518807.
21 static struct TargetCamera {
22 bool use_fake;
23 } const kTestParameters[] = {{true}};
24
25 } // namespace
26
27 namespace content {
28
29 // This class is the content_browsertests for Image Capture API, which allows
30 // for capturing still images out of a MediaStreamTrack. Is a
31 // WebRtcWebcamBrowserTest to be able to use a physical camera.
32 class WebRtcImageCaptureBrowserTest
33 : public WebRtcWebcamBrowserTest,
34 public testing::WithParamInterface<struct TargetCamera> {
35 public:
36 WebRtcImageCaptureBrowserTest() = default;
37 ~WebRtcImageCaptureBrowserTest() override = default;
38
39 void SetUpCommandLine(base::CommandLine* command_line) override {
40 WebRtcWebcamBrowserTest::SetUpCommandLine(command_line);
41
42 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
43 switches::kUseFakeDeviceForMediaStream));
44 if (GetParam().use_fake) {
45 base::CommandLine::ForCurrentProcess()->AppendSwitch(
46 switches::kUseFakeDeviceForMediaStream);
47 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
48 switches::kUseFakeDeviceForMediaStream));
49 }
50
51 // Enables promised-based navigator.mediaDevices.getUserMedia();
52 // TODO(mcasas): remove after https://crbug.com/503227 is closed.
53 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
54 switches::kEnableBlinkFeatures, "GetUserMedia");
55
56 // Specific flag to enable ImageCapture API.
57 // TODO(mcasas): remove after https://crbug.com/603328 is closed.
58 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
59 switches::kEnableBlinkFeatures, "ImageCapture");
60 }
61
62 private:
63 DISALLOW_COPY_AND_ASSIGN(WebRtcImageCaptureBrowserTest);
64 };
65
66 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
67 CreateAndGetCapabilities) {
68 ASSERT_TRUE(embedded_test_server()->Start());
69 GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile));
70 NavigateToURL(shell(), url);
71
72 std::string result;
73 ASSERT_TRUE(ExecuteScriptAndExtractString(
74 shell(), "testCreateAndGetCapabilities()", &result));
75 if (result == "OK")
76 return;
77 FAIL();
78 }
79
80 INSTANTIATE_TEST_CASE_P(,
81 WebRtcImageCaptureBrowserTest,
82 testing::ValuesIn(kTestParameters));
83
84 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698