[safe-browsing] Database full hash matches like prefix match.
[chromium-blink-merge.git] / chrome / browser / media / chrome_webrtc_disable_encryption_flag_browsertest.cc
blob14e461fd3e3fc1cf1a3625cbe21af01f60c2b9c2
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 "base/win/windows_version.h"
7 #include "chrome/browser/media/webrtc_browsertest_base.h"
8 #include "chrome/browser/media/webrtc_browsertest_common.h"
9 #include "chrome/common/chrome_version_info.h"
10 #include "content/public/common/content_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 virtual ~WebRtcDisableEncryptionFlagBrowserTest() {}
34 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
35 test::PeerConnectionServerRunner::KillAllPeerConnectionServers();
36 DetectErrorsInJavaScript(); // Look for errors in our rather complex js.
39 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
40 // This test should run with fake devices.
41 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
43 // Disable encryption with the command line flag.
44 command_line->AppendSwitch(switches::kDisableWebRtcEncryption);
47 protected:
48 test::PeerConnectionServerRunner peerconnection_server_;
50 private:
51 DISALLOW_COPY_AND_ASSIGN(WebRtcDisableEncryptionFlagBrowserTest);
54 // Makes a call and checks that there's encryption or not in the SDP offer.
55 // TODO(phoglund): this is unreliable on non-webrtc bots because its peer
56 // connection server could clash with other tests running in parallel,
57 // therefore only running manually. http://crbug.com/358207.
58 IN_PROC_BROWSER_TEST_F(WebRtcDisableEncryptionFlagBrowserTest,
59 MANUAL_VerifyEncryption) {
60 // Flaky timeout on a webrtc Win XP bot. http://crbug.com/368163.
61 #if defined (OS_WIN)
62 if (base::win::GetVersion() < base::win::VERSION_VISTA)
63 return;
64 #endif
66 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
67 ASSERT_TRUE(peerconnection_server_.Start());
69 content::WebContents* left_tab =
70 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
71 content::WebContents* right_tab =
72 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage);
74 EstablishCall(left_tab, right_tab);
76 StartDetectingVideo(left_tab, "remote-view");
77 StartDetectingVideo(right_tab, "remote-view");
79 WaitForVideoToPlay(left_tab);
80 WaitForVideoToPlay(right_tab);
82 bool should_detect_encryption = true;
83 VersionInfo::Channel channel = VersionInfo::GetChannel();
84 if (channel == VersionInfo::CHANNEL_UNKNOWN ||
85 channel == VersionInfo::CHANNEL_CANARY ||
86 channel == VersionInfo::CHANNEL_DEV) {
87 should_detect_encryption = false;
89 #if defined(OS_ANDROID)
90 if (channel == VersionInfo::CHANNEL_BETA)
91 should_detect_encryption = false;
92 #endif
94 std::string expected_string = should_detect_encryption ?
95 "crypto-seen" : "no-crypto-seen";
97 ASSERT_EQ(expected_string,
98 ExecuteJavascript("hasSeenCryptoInSdp()", left_tab));
100 HangUp(left_tab);
101 WaitUntilHangupVerified(left_tab);
102 WaitUntilHangupVerified(right_tab);
104 ASSERT_TRUE(peerconnection_server_.Stop());