| OLD | NEW |
| (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 static struct TargetCamera { |
| 20 bool do_use_fake; |
| 21 #if !defined(OS_ANDROID) |
| 22 } const kTestParameters[] = {{true}}; |
| 23 #else |
| 24 // Only enable real-camera tests in platforms where the code has been landed, |
| 25 // see https://crbug.com/518807. |
| 26 } const kTestParameters[] = {{true}, {false}}; |
| 27 #endif |
| 28 |
| 29 |
| 30 } // namespace |
| 31 |
| 32 namespace content { |
| 33 |
| 34 // This class is the content_browsertests for Image Capture API, which allows |
| 35 // for capturing still images out of a MediaStreamTrack. Is a |
| 36 // WebRtcWebcamBrowserTest to be able to use a physical camera. |
| 37 class WebRtcImageCaptureBrowserTest |
| 38 : public WebRtcWebcamBrowserTest, |
| 39 public testing::WithParamInterface<struct TargetCamera> { |
| 40 public: |
| 41 WebRtcImageCaptureBrowserTest() = default; |
| 42 ~WebRtcImageCaptureBrowserTest() override = default; |
| 43 |
| 44 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 45 WebRtcWebcamBrowserTest::SetUpCommandLine(command_line); |
| 46 |
| 47 ASSERT_FALSE(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 48 switches::kUseFakeDeviceForMediaStream)); |
| 49 if (GetParam().do_use_fake) { |
| 50 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 51 switches::kUseFakeDeviceForMediaStream); |
| 52 ASSERT_TRUE(base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 53 switches::kUseFakeDeviceForMediaStream)); |
| 54 } |
| 55 |
| 56 // Enables promised-based navigator.mediaDevices.getUserMedia(); |
| 57 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 58 switches::kEnableBlinkFeatures, "GetUserMedia"); |
| 59 // Enables promised-based navigator.mediaDevices.enumerateDevices(); |
| 60 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 61 switches::kEnableBlinkFeatures, "MediaDevices"); |
| 62 |
| 63 base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( |
| 64 switches::kEnableBlinkFeatures, "ImageCapture"); |
| 65 } |
| 66 |
| 67 private: |
| 68 DISALLOW_COPY_AND_ASSIGN(WebRtcImageCaptureBrowserTest); |
| 69 }; |
| 70 |
| 71 IN_PROC_BROWSER_TEST_P(WebRtcImageCaptureBrowserTest, |
| 72 CreateAndGetCapabilities) { |
| 73 ASSERT_TRUE(embedded_test_server()->Start()); |
| 74 GURL url(embedded_test_server()->GetURL(kImageCaptureHtmlFile)); |
| 75 NavigateToURL(shell(), url); |
| 76 |
| 77 std::string result; |
| 78 ASSERT_TRUE(ExecuteScriptAndExtractString( |
| 79 shell(), "testCreateAndGetCapabilities()", &result)); |
| 80 if (result == "OK") |
| 81 return; |
| 82 FAIL(); |
| 83 } |
| 84 |
| 85 INSTANTIATE_TEST_CASE_P(, |
| 86 WebRtcImageCaptureBrowserTest, |
| 87 testing::ValuesIn(kTestParameters)); |
| 88 |
| 89 } // namespace content |
| OLD | NEW |