OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "chrome/browser/media/webrtc_browsertest_base.h" | 7 #include "chrome/browser/media/webrtc_browsertest_base.h" |
8 #include "chrome/browser/media/webrtc_browsertest_common.h" | 8 #include "chrome/browser/media/webrtc_browsertest_common.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_tabstrip.h" | 10 #include "chrome/browser/ui/browser_tabstrip.h" |
11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/test/browser_test_utils.h" | 15 #include "content/public/test/browser_test_utils.h" |
16 #include "media/base/media_switches.h" | 16 #include "media/base/media_switches.h" |
17 #include "net/test/embedded_test_server/embedded_test_server.h" | 17 #include "net/test/embedded_test_server/embedded_test_server.h" |
18 | 18 |
19 static const char kMainWebrtcTestHtmlPage[] = | 19 static const char kMainWebrtcTestHtmlPage[] = |
20 "/webrtc/webrtc_jsep01_test.html"; | 20 "/webrtc/webrtc_jsep01_test.html"; |
21 | 21 |
22 // Top-level integration test for WebRTC. It always uses fake devices; see | 22 // Top-level integration test for WebRTC. It always uses fake devices; see |
23 // WebRtcWebcamBrowserTest for a test that acquires any real webcam on the | 23 // WebRtcWebcamBrowserTest for a test that acquires any real webcam on the |
24 // system. | 24 // system. |
25 class WebRtcBrowserTest : public WebRtcTestBase, | 25 class WebRtcBrowserTest : public WebRtcTestBase { |
26 public testing::WithParamInterface<bool> { | |
27 public: | 26 public: |
28 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 27 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
29 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | 28 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. |
30 } | 29 } |
31 | 30 |
32 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 31 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
33 // Ensure the infobar is enabled, since we expect that in this test. | 32 // Ensure the infobar is enabled, since we expect that in this test. |
34 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); | 33 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream)); |
35 | 34 |
36 // Always use fake devices. | 35 // Always use fake devices. |
37 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | 36 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); |
38 | 37 |
39 // Flag used by TestWebAudioMediaStream to force garbage collection. | 38 // Flag used by TestWebAudioMediaStream to force garbage collection. |
40 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); | 39 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc"); |
41 } | 40 } |
42 }; | 41 }; |
43 | 42 |
44 static const bool kRunTestsWithFlag[] = { false, true }; | 43 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, RunsAudioVideoWebRTCCallInTwoTabs) { |
45 INSTANTIATE_TEST_CASE_P(WebRtcBrowserTests, | |
46 WebRtcBrowserTest, | |
47 testing::ValuesIn(kRunTestsWithFlag)); | |
48 | |
49 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, RunsAudioVideoWebRTCCallInTwoTabs) { | |
50 if (OnWinXp()) return; | 44 if (OnWinXp()) return; |
51 | 45 |
52 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 46 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
53 | 47 |
54 content::WebContents* left_tab = | 48 content::WebContents* left_tab = |
55 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 49 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
56 content::WebContents* right_tab = | 50 content::WebContents* right_tab = |
57 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | 51 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); |
58 | 52 |
59 SetupPeerconnectionWithLocalStream(left_tab); | 53 SetupPeerconnectionWithLocalStream(left_tab); |
60 SetupPeerconnectionWithLocalStream(right_tab); | 54 SetupPeerconnectionWithLocalStream(right_tab); |
61 | 55 |
62 NegotiateCall(left_tab, right_tab); | 56 NegotiateCall(left_tab, right_tab); |
63 | 57 |
64 StartDetectingVideo(left_tab, "remote-view"); | 58 StartDetectingVideo(left_tab, "remote-view"); |
65 StartDetectingVideo(right_tab, "remote-view"); | 59 StartDetectingVideo(right_tab, "remote-view"); |
66 | 60 |
67 WaitForVideoToPlay(left_tab); | 61 WaitForVideoToPlay(left_tab); |
68 WaitForVideoToPlay(right_tab); | 62 WaitForVideoToPlay(right_tab); |
69 | 63 |
70 HangUp(left_tab); | 64 HangUp(left_tab); |
71 HangUp(right_tab); | 65 HangUp(right_tab); |
72 } | 66 } |
73 | 67 |
74 IN_PROC_BROWSER_TEST_P(WebRtcBrowserTest, TestWebAudioMediaStream) { | 68 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, TestWebAudioMediaStream) { |
75 // This tests against crash regressions for the WebAudio-MediaStream | 69 // This tests against crash regressions for the WebAudio-MediaStream |
76 // integration. | 70 // integration. |
77 if (OnWinXp()) return; | 71 if (OnWinXp()) return; |
78 | 72 |
79 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 73 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
80 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); | 74 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html")); |
81 ui_test_utils::NavigateToURL(browser(), url); | 75 ui_test_utils::NavigateToURL(browser(), url); |
82 content::WebContents* tab = | 76 content::WebContents* tab = |
83 browser()->tab_strip_model()->GetActiveWebContents(); | 77 browser()->tab_strip_model()->GetActiveWebContents(); |
84 | 78 |
85 // A sleep is necessary to be able to detect the crash. | 79 // A sleep is necessary to be able to detect the crash. |
86 test::SleepInJavascript(tab, 1000); | 80 test::SleepInJavascript(tab, 1000); |
87 | 81 |
88 ASSERT_FALSE(tab->IsCrashed()); | 82 ASSERT_FALSE(tab->IsCrashed()); |
89 } | 83 } |
OLD | NEW |