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

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

Issue 2193213003: ImageCapture: Queue up requests while device not ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reduce requested getUserMedia() resolution 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
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 "content/browser/webrtc/webrtc_webcam_browsertest.h" 6 #include "content/browser/webrtc/webrtc_webcam_browsertest.h"
7 #include "content/public/common/content_switches.h" 7 #include "content/public/common/content_switches.h"
8 #include "content/public/test/browser_test_utils.h" 8 #include "content/public/test/browser_test_utils.h"
9 #include "content/public/test/content_browser_test.h" 9 #include "content/public/test/content_browser_test.h"
10 #include "content/public/test/content_browser_test_utils.h" 10 #include "content/public/test/content_browser_test_utils.h"
11 #include "content/public/test/test_utils.h" 11 #include "content/public/test/test_utils.h"
12 #include "media/base/media_switches.h" 12 #include "media/base/media_switches.h"
13 #include "net/test/embedded_test_server/embedded_test_server.h" 13 #include "net/test/embedded_test_server/embedded_test_server.h"
14 14
15 namespace { 15 namespace {
16 16
17 static const char kImageCaptureHtmlFile[] = "/media/image_capture_test.html"; 17 static const char kImageCaptureHtmlFile[] = "/media/image_capture_test.html";
18 18
19 // TODO(mcasas): enable real-camera tests by disabling the Fake Device for 19 // TODO(mcasas): enable real-camera tests by disabling the Fake Device for
20 // platforms where the ImageCaptureCode is landed, https://crbug.com/518807. 20 // platforms where the ImageCaptureCode is landed, https://crbug.com/518807.
21 static struct TargetCamera { 21 static struct TargetCamera {
22 bool use_fake; 22 bool use_fake;
23 } const kTestParameters[] = {{true}}; 23 }
24 #if defined(OS_ANDROID)
25 const kTestParameters[] = {{true}, {false}};
26 #else
27 const kTestParameters[] = {{true}};
28 #endif
24 29
25 } // namespace 30 } // namespace
26 31
27 namespace content { 32 namespace content {
28 33
29 #if defined(OS_WIN)
30 // This test is flaky on WebRTC Windows bots: https://crbug.com/633242.
31 #define MAYBE_WebRtcImageCaptureBrowserTest \
32 DISABLED_WebRtcImageCaptureBrowserTest
33 #else
34 #define MAYBE_WebRtcImageCaptureBrowserTest WebRtcImageCaptureBrowserTest
35 #endif
36
37 // This class is the content_browsertests for Image Capture API, which allows 34 // This class is the content_browsertests for Image Capture API, which allows
38 // for capturing still images out of a MediaStreamTrack. Is a 35 // for capturing still images out of a MediaStreamTrack. Is a
39 // WebRtcWebcamBrowserTest to be able to use a physical camera. 36 // WebRtcWebcamBrowserTest to be able to use a physical camera.
40 class MAYBE_WebRtcImageCaptureBrowserTest 37 class WebRtcImageCaptureBrowserTest
41 : public WebRtcWebcamBrowserTest, 38 : public WebRtcWebcamBrowserTest,
42 public testing::WithParamInterface<struct TargetCamera> { 39 public testing::WithParamInterface<struct TargetCamera> {
43 public: 40 public:
44 MAYBE_WebRtcImageCaptureBrowserTest() = default; 41 WebRtcImageCaptureBrowserTest() = default;
45 ~MAYBE_WebRtcImageCaptureBrowserTest() override = default; 42 ~WebRtcImageCaptureBrowserTest() override = default;
46 43
47 void SetUpCommandLine(base::CommandLine* command_line) override { 44 void SetUpCommandLine(base::CommandLine* command_line) override {
48 WebRtcWebcamBrowserTest::SetUpCommandLine(command_line); 45 WebRtcWebcamBrowserTest::SetUpCommandLine(command_line);
49 46
50 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( 47 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
51 switches::kUseFakeDeviceForMediaStream)); 48 switches::kUseFakeDeviceForMediaStream));
52 if (GetParam().use_fake) { 49 if (GetParam().use_fake) {
53 base::CommandLine::ForCurrentProcess()->AppendSwitch( 50 base::CommandLine::ForCurrentProcess()->AppendSwitch(
54 switches::kUseFakeDeviceForMediaStream); 51 switches::kUseFakeDeviceForMediaStream);
55 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( 52 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
56 switches::kUseFakeDeviceForMediaStream)); 53 switches::kUseFakeDeviceForMediaStream));
57 } 54 }
58 55
59 // Enables promised-based navigator.mediaDevices.getUserMedia(); 56 // Enables promised-based navigator.mediaDevices.getUserMedia();
60 // TODO(mcasas): remove after https://crbug.com/503227 is closed. 57 // TODO(mcasas): remove after https://crbug.com/503227 is closed.
61 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 58 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
62 switches::kEnableBlinkFeatures, "GetUserMedia"); 59 switches::kEnableBlinkFeatures, "GetUserMedia");
63 60
64 // Specific flag to enable ImageCapture API. 61 // Specific flag to enable ImageCapture API.
65 // TODO(mcasas): remove after https://crbug.com/603328 is closed. 62 // TODO(mcasas): remove after https://crbug.com/603328 is closed.
66 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 63 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
67 switches::kEnableBlinkFeatures, "ImageCapture"); 64 switches::kEnableBlinkFeatures, "ImageCapture");
68 } 65 }
69 66
70 private: 67 private:
71 DISALLOW_COPY_AND_ASSIGN(MAYBE_WebRtcImageCaptureBrowserTest); 68 DISALLOW_COPY_AND_ASSIGN(WebRtcImageCaptureBrowserTest);
72 }; 69 };
73 70
74 IN_PROC_BROWSER_TEST_P(MAYBE_WebRtcImageCaptureBrowserTest, 71 #if defined(OS_WIN)
75 CreateAndGetCapabilities) { 72 // This test is flaky on WebRTC Windows bots: https://crbug.com/633242.
73 #define MAYBE_CreateAndGetCapabilities DISABLED_CreateAndGetCapabilities
74 #else
75 #define MAYBE_CreateAndGetCapabilities CreateAndGetCapabilities
76 #endif
77 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
78 MAYBE_CreateAndGetCapabilities) {
76 ASSERT_TRUE(embedded_test_server()->Start()); 79 ASSERT_TRUE(embedded_test_server()->Start());
77 GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile)); 80 GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile));
78 NavigateToURL(shell(), url); 81 NavigateToURL(shell(), url);
79 82
80 std::string result; 83 std::string result;
81 ASSERT_TRUE(ExecuteScriptAndExtractString( 84 ASSERT_TRUE(ExecuteScriptAndExtractString(
82 shell(), "testCreateAndGetCapabilities()", &result)); 85 shell(), "testCreateAndGetCapabilities()", &result));
83 if (result == "OK") 86 if (result == "OK")
84 return; 87 return;
85 FAIL(); 88 FAIL();
86 } 89 }
87 90
91 #if defined(OS_WIN)
92 // This test is flaky on WebRTC Windows bots: https://crbug.com/633242.
93 #define MAYBE_CreateAndTakePhoto DISABLED_CreateAndTakePhoto
94 #else
95 #define MAYBE_CreateAndTakePhoto CreateAndTakePhoto
96 #endif
97 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
98 MAYBE_CreateAndTakePhoto) {
99 ASSERT_TRUE(embedded_test_server()->Start());
100 GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile));
101 NavigateToURL(shell(), url);
102
103 std::string result;
104 ASSERT_TRUE(ExecuteScriptAndExtractString(shell(), "testCreateAndTakePhoto()",
105 &result));
106 if (result == "OK")
107 return;
108 FAIL();
109 }
110
88 INSTANTIATE_TEST_CASE_P(, 111 INSTANTIATE_TEST_CASE_P(,
89 MAYBE_WebRtcImageCaptureBrowserTest, 112 WebRtcImageCaptureBrowserTest,
90 testing::ValuesIn(kTestParameters)); 113 testing::ValuesIn(kTestParameters));
91 114
92 } // namespace content 115 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_manager.cc ('k') | content/test/data/media/image_capture_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698