Remove obsolete for_web_contents parameter in FontRenderParamsQuery.
[chromium-blink-merge.git] / chrome / browser / media / chrome_webrtc_disable_encryption_flag_browsertest.cc
blob91d613afc11e7604b19f676bd3e4fa7950dca8a3
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.
5 #include "base/command_line.h"
6 #include "chrome/browser/media/webrtc_browsertest_base.h"
7 #include "chrome/browser/media/webrtc_browsertest_common.h"
8 #include "chrome/common/chrome_version_info.h"
9 #include "content/public/common/content_switches.h"
10 #include "media/base/media_switches.h"
11 #include "net/test/embedded_test_server/embedded_test_server.h"
13 static const char kMainWebrtcTestHtmlPage[] =
14 "/webrtc/webrtc_jsep01_test.html";
16 using chrome::VersionInfo;
18 // This tests the --disable-webrtc-encryption command line flag. Disabling
19 // encryption should only be possible on certain channels.
21 // NOTE: The test case for each channel will only be exercised when the browser
22 // is actually built for that channel. This is not ideal. One can test manually
23 // by e.g. faking the channel returned in VersionInfo::GetChannel(). It's
24 // likely good to have the test anyway, even though a failure might not be
25 // detected until a branch has been promoted to another channel. The unit
26 // test for ChromeContentBrowserClient::MaybeCopyDisableWebRtcEncryptionSwitch
27 // tests for all channels however.
28 // TODO(grunell): Test the different channel cases for any build.
29 class WebRtcDisableEncryptionFlagBrowserTest : public WebRtcTestBase {
30 public:
31 WebRtcDisableEncryptionFlagBrowserTest() {}
32 ~WebRtcDisableEncryptionFlagBrowserTest() override {}
34 void SetUpInProcessBrowserTestFixture() override {
35 DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
38 void SetUpCommandLine(base::CommandLine* command_line) override {
39 // This test should run with fake devices.
40 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
42 // Disable encryption with the command line flag.
43 command_line->AppendSwitch(switches::kDisableWebRtcEncryption);
46 private:
47 DISALLOW_COPY_AND_ASSIGN(WebRtcDisableEncryptionFlagBrowserTest);
50 // Makes a call and checks that there's encryption or not in the SDP offer.
51 IN_PROC_BROWSER_TEST_F(WebRtcDisableEncryptionFlagBrowserTest,
52 VerifyEncryption) {
53 if (!OnWinXp())
54 return; // Flaky timeout on a webrtc Win XP bot. http://crbug.com/368163.
56 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
58 content::WebContents* left_tab =
59 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
60 content::WebContents* right_tab =
61 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
63 SetupPeerconnectionWithLocalStream(left_tab);
64 SetupPeerconnectionWithLocalStream(right_tab);
66 NegotiateCall(left_tab, right_tab);
68 StartDetectingVideo(left_tab, "remote-view");
69 StartDetectingVideo(right_tab, "remote-view");
71 WaitForVideoToPlay(left_tab);
72 WaitForVideoToPlay(right_tab);
74 bool should_detect_encryption = true;
75 VersionInfo::Channel channel = VersionInfo::GetChannel();
76 if (channel == VersionInfo::CHANNEL_UNKNOWN ||
77 channel == VersionInfo::CHANNEL_CANARY ||
78 channel == VersionInfo::CHANNEL_DEV) {
79 should_detect_encryption = false;
81 #if defined(OS_ANDROID)
82 if (channel == VersionInfo::CHANNEL_BETA)
83 should_detect_encryption = false;
84 #endif
86 std::string expected_string = should_detect_encryption ?
87 "crypto-seen" : "no-crypto-seen";
89 ASSERT_EQ(expected_string,
90 ExecuteJavascript("hasSeenCryptoInSdp()", left_tab));
92 HangUp(left_tab);
93 HangUp(right_tab);