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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/media/webrtc/webrtc_image_capture_browsertest.cc
diff --git a/content/browser/media/webrtc/webrtc_image_capture_browsertest.cc b/content/browser/media/webrtc/webrtc_image_capture_browsertest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d690ef03c4eaa2bf2a3cd675ab9c3319a7013a61
--- /dev/null
+++ b/content/browser/media/webrtc/webrtc_image_capture_browsertest.cc
@@ -0,0 +1,84 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "content/browser/media/webrtc/webrtc_webcam_browsertest.h"
+#include "content/public/common/content_switches.h"
+#include "content/public/test/browser_test_utils.h"
+#include "content/public/test/content_browser_test.h"
+#include "content/public/test/content_browser_test_utils.h"
+#include "content/public/test/test_utils.h"
+#include "media/base/media_switches.h"
+#include "net/test/embedded_test_server/embedded_test_server.h"
+
+namespace {
+
+static const char kImageCaptureHtmlFile[] = "/media/image_capture_test.html";
+
+// TODO(mcasas): enable real-camera tests by disabling the Fake Device for
+// platforms where the ImageCaptureCode is landed, https://crbug.com/518807.
+static struct TargetCamera {
+ bool use_fake;
+} const kTestParameters[] = {{true}};
+
+} // namespace
+
+namespace content {
+
+// This class is the content_browsertests for Image Capture API, which allows
+// for capturing still images out of a MediaStreamTrack. Is a
+// WebRtcWebcamBrowserTest to be able to use a physical camera.
+class WebRtcImageCaptureBrowserTest
+ : public WebRtcWebcamBrowserTest,
+ public testing::WithParamInterface<struct TargetCamera> {
+ public:
+ WebRtcImageCaptureBrowserTest() = default;
+ ~WebRtcImageCaptureBrowserTest() override = default;
+
+ void SetUpCommandLine(base::CommandLine* command_line) override {
+ WebRtcWebcamBrowserTest::SetUpCommandLine(command_line);
+
+ ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kUseFakeDeviceForMediaStream));
+ if (GetParam().use_fake) {
+ base::CommandLine::ForCurrentProcess()->AppendSwitch(
+ switches::kUseFakeDeviceForMediaStream);
+ ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kUseFakeDeviceForMediaStream));
+ }
+
+ // Enables promised-based navigator.mediaDevices.getUserMedia();
+ // TODO(mcasas): remove after https://crbug.com/503227 is closed.
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kEnableBlinkFeatures, "GetUserMedia");
+
+ // Specific flag to enable ImageCapture API.
+ // TODO(mcasas): remove after https://crbug.com/603328 is closed.
+ base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ switches::kEnableBlinkFeatures, "ImageCapture");
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WebRtcImageCaptureBrowserTest);
+};
+
+IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
+ CreateAndGetCapabilities) {
+ ASSERT_TRUE(embedded_test_server()->Start());
+ GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile));
+ NavigateToURL(shell(), url);
+
+ std::string result;
+ ASSERT_TRUE(ExecuteScriptAndExtractString(
+ shell(), "testCreateAndGetCapabilities()", &result));
+ if (result == "OK")
+ return;
+ FAIL();
+}
+
+INSTANTIATE_TEST_CASE_P(,
+ WebRtcImageCaptureBrowserTest,
+ testing::ValuesIn(kTestParameters));
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698