Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / media / chrome_webrtc_browsertest.cc
blobf006253ad89e3ebd692079e1ff54ffecd889cd6b
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "base/strings/stringprintf.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/test/browser_test_utils.h"
16 #include "media/base/media_switches.h"
17 #include "net/test/embedded_test_server/embedded_test_server.h"
19 static const char kMainWebrtcTestHtmlPage[] =
20 "/webrtc/webrtc_jsep01_test.html";
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
24 // system.
25 class WebRtcBrowserTest : public WebRtcTestBase {
26 public:
27 void SetUpInProcessBrowserTestFixture() override {
28 DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
31 void SetUpCommandLine(base::CommandLine* command_line) override {
32 // Ensure the infobar is enabled, since we expect that in this test.
33 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream));
35 // Always use fake devices.
36 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
38 // Flag used by TestWebAudioMediaStream to force garbage collection.
39 command_line->AppendSwitchASCII(switches::kJavaScriptFlags, "--expose-gc");
43 // Flaky on ChromeOS (?), Windows: http://crbug.com/443542.
44 #if defined(OS_CHROMEOS) || defined(OS_WIN)
45 #define MAYBE_RunsAudioVideoWebRTCCallInTwoTabs \
46 DISABLED_RunsAudioVideoWebRTCCallInTwoTabs
47 #else
48 #define MAYBE_RunsAudioVideoWebRTCCallInTwoTabs \
49 RunsAudioVideoWebRTCCallInTwoTabs
50 #endif
51 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest,
52 MAYBE_RunsAudioVideoWebRTCCallInTwoTabs) {
53 if (OnWinXp()) return;
55 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
57 content::WebContents* left_tab =
58 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
59 content::WebContents* right_tab =
60 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
62 SetupPeerconnectionWithLocalStream(left_tab);
63 SetupPeerconnectionWithLocalStream(right_tab);
65 NegotiateCall(left_tab, right_tab);
67 StartDetectingVideo(left_tab, "remote-view");
68 StartDetectingVideo(right_tab, "remote-view");
70 #if !defined(OS_MACOSX)
71 // Video is choppy on Mac OS X. http://crbug.com/443542.
72 WaitForVideoToPlay(left_tab);
73 WaitForVideoToPlay(right_tab);
74 #endif
76 HangUp(left_tab);
77 HangUp(right_tab);
80 IN_PROC_BROWSER_TEST_F(WebRtcBrowserTest, TestWebAudioMediaStream) {
81 // This tests against crash regressions for the WebAudio-MediaStream
82 // integration.
83 if (OnWinXp()) return;
85 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
86 GURL url(embedded_test_server()->GetURL("/webrtc/webaudio_crash.html"));
87 ui_test_utils::NavigateToURL(browser(), url);
88 content::WebContents* tab =
89 browser()->tab_strip_model()->GetActiveWebContents();
91 // A sleep is necessary to be able to detect the crash.
92 test::SleepInJavascript(tab, 1000);
94 ASSERT_FALSE(tab->IsCrashed());