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