| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/media/webrtc/webrtc_webcam_browsertest.h" |
| 6 |
| 5 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 6 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 7 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/public/common/content_switches.h" | 11 #include "content/public/common/content_switches.h" |
| 10 #include "content/public/test/browser_test_utils.h" | 12 #include "content/public/test/browser_test_utils.h" |
| 11 #include "content/public/test/content_browser_test.h" | 13 #include "content/public/test/content_browser_test.h" |
| 12 #include "content/public/test/content_browser_test_utils.h" | 14 #include "content/public/test/content_browser_test_utils.h" |
| 13 #include "content/public/test/test_utils.h" | 15 #include "content/public/test/test_utils.h" |
| 14 #include "content/shell/browser/shell.h" | 16 #include "content/shell/browser/shell.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 33 argv.erase(std::remove_if(argv.begin(), argv.end(), | 35 argv.erase(std::remove_if(argv.begin(), argv.end(), |
| 34 IsUseFakeDeviceForMediaStream), | 36 IsUseFakeDeviceForMediaStream), |
| 35 argv.end()); | 37 argv.end()); |
| 36 command_line->InitFromArgv(argv); | 38 command_line->InitFromArgv(argv); |
| 37 } | 39 } |
| 38 | 40 |
| 39 } // namespace | 41 } // namespace |
| 40 | 42 |
| 41 namespace content { | 43 namespace content { |
| 42 | 44 |
| 43 // This class doesn't inherit from WebRtcContentBrowserTestBase like the others | 45 void WebRtcWebcamBrowserTest::SetUpCommandLine( |
| 44 // since we want it to actually acquire the real webcam on the system (if there | 46 base::CommandLine* command_line) { |
| 45 // is one). | 47 // Allows for accessing capture devices without prompting for permission. |
| 46 class WebRtcWebcamBrowserTest: public ContentBrowserTest { | 48 command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); |
| 47 public: | |
| 48 ~WebRtcWebcamBrowserTest() override {} | |
| 49 | 49 |
| 50 void SetUpCommandLine(base::CommandLine* command_line) override { | 50 // The content_browsertests run with this flag by default, and this test is |
| 51 command_line->AppendSwitch(switches::kUseFakeUIForMediaStream); | 51 // the only current exception to that rule, so just remove the flag |
| 52 // --use-fake-device-for-media-stream here. We could also have all tests |
| 53 // involving media streams add this flag explicitly, but it will be really |
| 54 // unintuitive for developers to write tests involving media stream and have |
| 55 // them fail on what looks like random bots, so running with fake devices |
| 56 // is really a reasonable default. |
| 57 RemoveFakeDeviceFromCommandLine(command_line); |
| 58 } |
| 52 | 59 |
| 53 // The content_browsertests run with this flag by default, and this test is | 60 void WebRtcWebcamBrowserTest::SetUp() { |
| 54 // the only current exception to that rule, so just remove the flag | 61 EnablePixelOutput(); |
| 55 // --use-fake-device-for-media-stream here. We could also have all tests | 62 ContentBrowserTest::SetUp(); |
| 56 // involving media streams add this flag explicitly, but it will be really | 63 } |
| 57 // unintuitive for developers to write tests involving media stream and have | |
| 58 // them fail on what looks like random bots, so running with fake devices | |
| 59 // is really a reasonable default. | |
| 60 RemoveFakeDeviceFromCommandLine(command_line); | |
| 61 } | |
| 62 | |
| 63 void SetUp() override { | |
| 64 EnablePixelOutput(); | |
| 65 ContentBrowserTest::SetUp(); | |
| 66 } | |
| 67 }; | |
| 68 | 64 |
| 69 // The test is tagged as MANUAL since the webcam is a system-level resource; we | 65 // The test is tagged as MANUAL since the webcam is a system-level resource; we |
| 70 // only want it to run on bots where we can ensure sequential execution. The | 66 // only want it to run on bots where we can ensure sequential execution. The |
| 71 // Android bots will run the test since they ignore MANUAL, but that's what we | 67 // Android bots will run the test since they ignore MANUAL, but that's what we |
| 72 // want here since the bot runs tests sequentially on the device. | 68 // want here since the bot runs tests sequentially on the device. |
| 73 IN_PROC_BROWSER_TEST_F(WebRtcWebcamBrowserTest, | 69 IN_PROC_BROWSER_TEST_F(WebRtcWebcamBrowserTest, |
| 74 MANUAL_CanAcquireVgaOnRealWebcam) { | 70 MANUAL_CanAcquireVgaOnRealWebcam) { |
| 75 ASSERT_TRUE(embedded_test_server()->Start()); | 71 ASSERT_TRUE(embedded_test_server()->Start()); |
| 76 GURL url(embedded_test_server()->GetURL( | 72 GURL url(embedded_test_server()->GetURL( |
| 77 "/media/getusermedia-real-webcam.html")); | 73 "/media/getusermedia-real-webcam.html")); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 91 | 87 |
| 92 if (result == "640x480" || result == "480x640") { | 88 if (result == "640x480" || result == "480x640") { |
| 93 // Don't care if the device happens to be in landscape or portrait mode | 89 // Don't care if the device happens to be in landscape or portrait mode |
| 94 // since we don't know how it is oriented in the lab :) | 90 // since we don't know how it is oriented in the lab :) |
| 95 return; | 91 return; |
| 96 } | 92 } |
| 97 FAIL() << "Expected resolution to be 640x480 or 480x640, got" << result; | 93 FAIL() << "Expected resolution to be 640x480 or 480x640, got" << result; |
| 98 } | 94 } |
| 99 | 95 |
| 100 } // namespace content | 96 } // namespace content |
| OLD | NEW |