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

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

Issue 2212343003: Reland: ImageCapture: Queue up requests while device not ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable Android tests with bug and explanation 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 // TODO(mcasas): enable in Android when takePhoto() can be specified a (small)
22 // capture resolution preventing the test from timeout https://crbug.com/634811.
21 static struct TargetCamera { 23 static struct TargetCamera {
22 bool use_fake; 24 bool use_fake;
23 } const kTestParameters[] = {{true}}; 25 }
26 const kTestParameters[] = {{true}};
24 27
25 } // namespace 28 } // namespace
26 29
27 namespace content { 30 namespace content {
28 31
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 32 // This class is the content_browsertests for Image Capture API, which allows
38 // for capturing still images out of a MediaStreamTrack. Is a 33 // for capturing still images out of a MediaStreamTrack. Is a
39 // WebRtcWebcamBrowserTest to be able to use a physical camera. 34 // WebRtcWebcamBrowserTest to be able to use a physical camera.
40 class MAYBE_WebRtcImageCaptureBrowserTest 35 class WebRtcImageCaptureBrowserTest
41 : public WebRtcWebcamBrowserTest, 36 : public WebRtcWebcamBrowserTest,
42 public testing::WithParamInterface<struct TargetCamera> { 37 public testing::WithParamInterface<struct TargetCamera> {
43 public: 38 public:
44 MAYBE_WebRtcImageCaptureBrowserTest() = default; 39 WebRtcImageCaptureBrowserTest() = default;
45 ~MAYBE_WebRtcImageCaptureBrowserTest() override = default; 40 ~WebRtcImageCaptureBrowserTest() override = default;
46 41
47 void SetUpCommandLine(base::CommandLine* command_line) override { 42 void SetUpCommandLine(base::CommandLine* command_line) override {
48 WebRtcWebcamBrowserTest::SetUpCommandLine(command_line); 43 WebRtcWebcamBrowserTest::SetUpCommandLine(command_line);
49 44
50 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( 45 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch(
51 switches::kUseFakeDeviceForMediaStream)); 46 switches::kUseFakeDeviceForMediaStream));
52 if (GetParam().use_fake) { 47 if (GetParam().use_fake) {
53 base::CommandLine::ForCurrentProcess()->AppendSwitch( 48 base::CommandLine::ForCurrentProcess()->AppendSwitch(
54 switches::kUseFakeDeviceForMediaStream); 49 switches::kUseFakeDeviceForMediaStream);
55 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( 50 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch(
56 switches::kUseFakeDeviceForMediaStream)); 51 switches::kUseFakeDeviceForMediaStream));
57 } 52 }
58 53
59 // Enables promised-based navigator.mediaDevices.getUserMedia(); 54 // Enables promised-based navigator.mediaDevices.getUserMedia();
60 // TODO(mcasas): remove after https://crbug.com/503227 is closed. 55 // TODO(mcasas): remove after https://crbug.com/503227 is closed.
61 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 56 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
62 switches::kEnableBlinkFeatures, "GetUserMedia"); 57 switches::kEnableBlinkFeatures, "GetUserMedia");
63 58
64 // Specific flag to enable ImageCapture API. 59 // Specific flag to enable ImageCapture API.
65 // TODO(mcasas): remove after https://crbug.com/603328 is closed. 60 // TODO(mcasas): remove after https://crbug.com/603328 is closed.
66 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( 61 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII(
67 switches::kEnableBlinkFeatures, "ImageCapture"); 62 switches::kEnableBlinkFeatures, "ImageCapture");
68 } 63 }
69 64
70 private: 65 private:
71 DISALLOW_COPY_AND_ASSIGN(MAYBE_WebRtcImageCaptureBrowserTest); 66 DISALLOW_COPY_AND_ASSIGN(WebRtcImageCaptureBrowserTest);
72 }; 67 };
73 68
74 IN_PROC_BROWSER_TEST_P(MAYBE_WebRtcImageCaptureBrowserTest, 69 #if defined(OS_WIN)
75 CreateAndGetCapabilities) { 70 // This test is flaky on WebRTC Windows bots: https://crbug.com/633242.
71 #define MAYBE_CreateAndGetCapabilities DISABLED_CreateAndGetCapabilities
72 #else
73 #define MAYBE_CreateAndGetCapabilities CreateAndGetCapabilities
74 #endif
75 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
76 MAYBE_CreateAndGetCapabilities) {
76 ASSERT_TRUE(embedded_test_server()->Start()); 77 ASSERT_TRUE(embedded_test_server()->Start());
77 GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile)); 78 GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile));
78 NavigateToURL(shell(), url); 79 NavigateToURL(shell(), url);
79 80
80 std::string result; 81 std::string result;
81 ASSERT_TRUE(ExecuteScriptAndExtractString( 82 ASSERT_TRUE(ExecuteScriptAndExtractString(
82 shell(), "testCreateAndGetCapabilities()", &result)); 83 shell(), "testCreateAndGetCapabilities()", &result));
83 if (result == "OK") 84 if (result == "OK")
84 return; 85 return;
85 FAIL(); 86 FAIL();
86 } 87 }
87 88
89 #if defined(OS_WIN)
90 // This test is flaky on WebRTC Windows bots: https://crbug.com/633242.
91 #define MAYBE_CreateAndTakePhoto DISABLED_CreateAndTakePhoto
92 #else
93 #define MAYBE_CreateAndTakePhoto CreateAndTakePhoto
94 #endif
95 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest,
96 MAYBE_CreateAndTakePhoto) {
97 ASSERT_TRUE(embedded_test_server()->Start());
98 GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile));
99 NavigateToURL(shell(), url);
100
101 std::string result;
102 ASSERT_TRUE(ExecuteScriptAndExtractString(shell(), "testCreateAndTakePhoto()",
103 &result));
104 if (result == "OK")
105 return;
106 FAIL();
107 }
108
88 INSTANTIATE_TEST_CASE_P(, 109 INSTANTIATE_TEST_CASE_P(,
89 MAYBE_WebRtcImageCaptureBrowserTest, 110 WebRtcImageCaptureBrowserTest,
90 testing::ValuesIn(kTestParameters)); 111 testing::ValuesIn(kTestParameters));
91 112
92 } // namespace content 113 } // 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