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

Side by Side Diff: chrome/browser/media/webrtc_webcam_browsertest.cc

Issue 2307083002: Cleanup: move WebRTC related files from chrome/browser/media to chrome/browser/media/webrtc/ (Closed)
Patch Set: Removed file wrongly resuscitated during rebase Created 4 years, 3 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "build/build_config.h"
7 #include "chrome/browser/media/webrtc_browsertest_base.h"
8 #include "chrome/browser/media/webrtc_browsertest_common.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_tabstrip.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h"
15 #include "content/public/common/content_switches.h"
16 #include "content/public/test/browser_test_utils.h"
17 #include "media/base/media_switches.h"
18 #include "net/test/embedded_test_server/embedded_test_server.h"
19 #include "testing/gtest/include/gtest/gtest-param-test.h"
20
21 static const char kMainWebrtcTestHtmlPage[] =
22 "/webrtc/webrtc_jsep01_test.html";
23
24 static const char* kTestConfigFlags[] = {
25 #if defined(OS_WIN)
26 NULL,
27 // Media Foundation is only available in Windows versions >= 7, below that the
28 // following flag has no effect; the test would run twice using DirectShow.
29 switches::kForceMediaFoundationVideoCapture
30 #else
31 NULL
32 #endif
33 };
34
35 // These tests runs on real webcams and ensure WebRTC can acquire webcams
36 // correctly. They will do nothing if there are no webcams on the system.
37 // The webcam on the system must support up to 1080p, or the test will fail.
38 // This test is excellent for testing the various capture paths of WebRTC
39 // on all desktop platforms.
40 class WebRtcWebcamBrowserTest : public WebRtcTestBase,
41 public testing::WithParamInterface<const char*> {
42 public:
43 void SetUpCommandLine(base::CommandLine* command_line) override {
44 EXPECT_FALSE(command_line->HasSwitch(
45 switches::kUseFakeDeviceForMediaStream));
46 EXPECT_FALSE(command_line->HasSwitch(
47 switches::kUseFakeUIForMediaStream));
48 if (GetParam())
49 command_line->AppendSwitch(GetParam());
50 }
51
52 protected:
53 void SetUpInProcessBrowserTestFixture() override {
54 DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
55 }
56
57 std::string GetUserMediaAndGetStreamSize(content::WebContents* tab,
58 const std::string& constraints) {
59 std::string actual_stream_size;
60 if (GetUserMediaWithSpecificConstraintsAndAcceptIfPrompted(tab,
61 constraints)) {
62 StartDetectingVideo(tab, "local-view");
63 if (WaitForVideoToPlay(tab))
64 actual_stream_size = GetStreamSize(tab, "local-view");
65 CloseLastLocalStream(tab);
66 }
67 return actual_stream_size;
68 }
69 };
70
71 // This test is manual because the test results can vary heavily depending on
72 // which webcam or drivers you have on the system.
73 IN_PROC_BROWSER_TEST_P(WebRtcWebcamBrowserTest,
74 MANUAL_TestAcquiringAndReacquiringWebcam) {
75 ASSERT_TRUE(embedded_test_server()->Start());
76 GURL url(embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage));
77 ui_test_utils::NavigateToURL(browser(), url);
78 content::WebContents* tab =
79 browser()->tab_strip_model()->GetActiveWebContents();
80
81 if (!HasWebcamAvailableOnSystem(tab)) {
82 LOG(INFO) << "No webcam found on bot: skipping...";
83 return;
84 }
85
86 EXPECT_EQ("320x240",
87 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraintsQVGA));
88 EXPECT_EQ("640x480",
89 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraintsVGA));
90 EXPECT_EQ("640x360",
91 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints360p));
92 EXPECT_EQ("1280x720",
93 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints720p));
94 EXPECT_EQ("1920x1080",
95 GetUserMediaAndGetStreamSize(tab, kVideoCallConstraints1080p));
96 }
97
98 INSTANTIATE_TEST_CASE_P(WebRtcWebcamBrowserTests,
99 WebRtcWebcamBrowserTest,
100 testing::ValuesIn(kTestConfigFlags));
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_video_quality_browsertest.cc ('k') | chrome/browser/media/window_icon_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698