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 <stddef.h> |
| 6 |
| 7 #include "base/command_line.h" |
| 8 #include "base/strings/stringprintf.h" |
| 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "content/browser/webrtc/webrtc_content_browsertest_base.h" |
| 11 #include "content/public/common/content_switches.h" |
| 12 #include "content/public/test/content_browser_test_utils.h" |
| 13 #include "media/base/media_switches.h" |
| 14 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 15 |
| 16 namespace { |
| 17 |
| 18 static const char kGetDepthStreamAndCallCreateImageBitmap[] = |
| 19 "getDepthStreamAndCallCreateImageBitmap"; |
| 20 |
| 21 void RemoveSwitchFromCommandLine(base::CommandLine* command_line, |
| 22 const std::string& switch_value) { |
| 23 base::CommandLine::StringVector argv = command_line->argv(); |
| 24 const base::CommandLine::StringType switch_string = |
| 25 #if defined(OS_WIN) |
| 26 base::ASCIIToUTF16(switch_value); |
| 27 #else |
| 28 switch_value; |
| 29 #endif |
| 30 argv.erase(std::remove_if( |
| 31 argv.begin(), argv.end(), |
| 32 [switch_string](const base::CommandLine::StringType& value) { |
| 33 return value.find(switch_string) != std::string::npos; |
| 34 }), |
| 35 argv.end()); |
| 36 command_line->InitFromArgv(argv); |
| 37 } |
| 38 |
| 39 } // namespace |
| 40 |
| 41 namespace content { |
| 42 |
| 43 class WebRtcDepthCaptureBrowserTest : public WebRtcContentBrowserTestBase { |
| 44 public: |
| 45 WebRtcDepthCaptureBrowserTest() { |
| 46 // Automatically grant device permission. |
| 47 AppendUseFakeUIForMediaStreamFlag(); |
| 48 } |
| 49 ~WebRtcDepthCaptureBrowserTest() override {} |
| 50 |
| 51 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 52 // Test using two video capture devices - a color and a 16-bit depth device. |
| 53 // By default, command line argument is present with no value. We need to |
| 54 // remove it and then add the value defining two video capture devices. |
| 55 const std::string fake_device_switch = |
| 56 switches::kUseFakeDeviceForMediaStream; |
| 57 ASSERT_TRUE(command_line->HasSwitch(fake_device_switch) && |
| 58 command_line->GetSwitchValueASCII(fake_device_switch).empty()); |
| 59 RemoveSwitchFromCommandLine(command_line, fake_device_switch); |
| 60 command_line->AppendSwitchASCII(fake_device_switch, "device-count=2"); |
| 61 WebRtcContentBrowserTestBase::SetUpCommandLine(command_line); |
| 62 } |
| 63 }; |
| 64 |
| 65 IN_PROC_BROWSER_TEST_F(WebRtcDepthCaptureBrowserTest, |
| 66 GetDepthStreamAndCallCreateImageBitmap) { |
| 67 ASSERT_TRUE(embedded_test_server()->Start()); |
| 68 |
| 69 GURL url( |
| 70 embedded_test_server()->GetURL("/media/getusermedia-depth-capture.html")); |
| 71 NavigateToURL(shell(), url); |
| 72 |
| 73 ExecuteJavascriptAndWaitForOk(base::StringPrintf( |
| 74 "%s({video: true});", kGetDepthStreamAndCallCreateImageBitmap)); |
| 75 } |
| 76 |
| 77 } // namespace content |
OLD | NEW |