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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "chrome/browser/media/webrtc_browsertest_base.h" | 6 #include "chrome/browser/media/webrtc_browsertest_base.h" |
7 #include "chrome/browser/media/webrtc_browsertest_common.h" | 7 #include "chrome/browser/media/webrtc_browsertest_common.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_tabstrip.h" | 9 #include "chrome/browser/ui/browser_tabstrip.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 10 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 25 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
26 EXPECT_FALSE(command_line->HasSwitch( | 26 EXPECT_FALSE(command_line->HasSwitch( |
27 switches::kUseFakeDeviceForMediaStream)); | 27 switches::kUseFakeDeviceForMediaStream)); |
28 EXPECT_FALSE(command_line->HasSwitch( | 28 EXPECT_FALSE(command_line->HasSwitch( |
29 switches::kUseFakeUIForMediaStream)); | 29 switches::kUseFakeUIForMediaStream)); |
30 } | 30 } |
31 | 31 |
32 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 32 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
33 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 33 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
34 } | 34 } |
| 35 |
| 36 protected: |
| 37 std::string GetUserMediaAndGetStreamSize(content::WebContents* tab, |
| 38 const std::string& constraints) { |
| 39 GetUserMediaWithSpecificConstraintsAndAccept(tab, constraints); |
| 40 StartDetectingVideo(tab, "local-view"); |
| 41 WaitForVideoToPlay(tab); |
| 42 std::string actual_stream_size = GetStreamSize(tab, "local-view"); |
| 43 CloseLastLocalStream(tab); |
| 44 return actual_stream_size; |
| 45 } |
35 }; | 46 }; |
36 | 47 |
37 IN_PROC_BROWSER_TEST_F(WebRtcWebcamBrowserTest, | 48 IN_PROC_BROWSER_TEST_F(WebRtcWebcamBrowserTest, |
38 TestAcquiringAndReacquiringWebcam) { | 49 TestAcquiringAndReacquiringWebcam) { |
39 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 50 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
40 GURL url(embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage)); | 51 GURL url(embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage)); |
41 ui_test_utils::NavigateToURL(browser(), url); | 52 ui_test_utils::NavigateToURL(browser(), url); |
42 content::WebContents* tab = | 53 content::WebContents* tab = |
43 browser()->tab_strip_model()->GetActiveWebContents(); | 54 browser()->tab_strip_model()->GetActiveWebContents(); |
44 | 55 |
45 if (!HasWebcamAvailableOnSystem(tab)) { | 56 if (!HasWebcamAvailableOnSystem(tab)) { |
46 LOG(INFO) << "No webcam found on bot: skipping..."; | 57 LOG(INFO) << "No webcam found on bot: skipping..."; |
47 return; | 58 return; |
48 } | 59 } |
49 | 60 |
50 GetUserMediaWithSpecificConstraintsAndAccept(tab, | 61 EXPECT_EQ("640x480", |
51 kAudioVideoCallConstraintsVGA); | 62 GetUserMediaAndGetStreamSize(tab, kAudioVideoCallConstraintsVGA)); |
52 StartDetectingVideo(tab, "local-view"); | 63 EXPECT_EQ("320x240", |
53 WaitForVideoToPlay(tab); | 64 GetUserMediaAndGetStreamSize(tab, kAudioVideoCallConstraintsQVGA)); |
54 EXPECT_EQ("640x480", GetStreamSize(tab, "local-view")); | 65 EXPECT_EQ("640x360", |
55 CloseLastLocalStream(tab); | 66 GetUserMediaAndGetStreamSize(tab, kAudioVideoCallConstraints360p)); |
56 GetUserMediaWithSpecificConstraintsAndAccept(tab, | 67 EXPECT_EQ("1280x720", |
57 kAudioVideoCallConstraintsQVGA); | 68 GetUserMediaAndGetStreamSize(tab, kAudioVideoCallConstraints720p)); |
58 StartDetectingVideo(tab, "local-view"); | 69 EXPECT_EQ("1920x1080", |
59 WaitForVideoToPlay(tab); | 70 GetUserMediaAndGetStreamSize(tab, kAudioVideoCallConstraints1080p)); |
60 EXPECT_EQ("320x240", GetStreamSize(tab, "local-view")); | |
61 CloseLastLocalStream(tab); | |
62 GetUserMediaWithSpecificConstraintsAndAccept(tab, | |
63 kAudioVideoCallConstraints360p); | |
64 StartDetectingVideo(tab, "local-view"); | |
65 WaitForVideoToPlay(tab); | |
66 EXPECT_EQ("640x360", GetStreamSize(tab, "local-view")); | |
67 CloseLastLocalStream(tab); | |
68 | |
69 // Broken on all platforms for C920 webcams: see http://crbug.com/360512. | |
70 // GetUserMediaWithSpecificConstraintsAndAccept(tab, | |
71 // kAudioVideoCallConstraints720p); | |
72 // StartDetectingVideo(tab, "local-view"); | |
73 // WaitForVideoToPlay(tab); | |
74 // EXPECT_EQ("1280x720", GetStreamSize(tab, "local-view")); | |
75 // CloseLastLocalStream(tab); | |
76 // GetUserMediaWithSpecificConstraintsAndAccept(tab, | |
77 // kAudioVideoCallConstraints1080p); | |
78 // StartDetectingVideo(tab, "local-view"); | |
79 // WaitForVideoToPlay(tab); | |
80 // EXPECT_EQ("1920x1080", GetStreamSize(tab, "local-view")); | |
81 // CloseLastLocalStream(tab); | |
82 } | 71 } |
OLD | NEW |