OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "base/command_line.h" | |
6 #include "base/macros.h" | |
7 #include "build/build_config.h" | |
8 #include "chrome/browser/media/webrtc_browsertest_base.h" | |
9 #include "chrome/browser/media/webrtc_browsertest_common.h" | |
10 #include "chrome/common/channel_info.h" | |
11 #include "components/version_info/version_info.h" | |
12 #include "content/public/common/content_switches.h" | |
13 #include "media/base/media_switches.h" | |
14 #include "net/test/embedded_test_server/embedded_test_server.h" | |
15 | |
16 static const char kMainWebrtcTestHtmlPage[] = | |
17 "/webrtc/webrtc_jsep01_test.html"; | |
18 | |
19 // This tests the --disable-webrtc-encryption command line flag. Disabling | |
20 // encryption should only be possible on certain channels. | |
21 | |
22 // NOTE: The test case for each channel will only be exercised when the browser | |
23 // is actually built for that channel. This is not ideal. One can test manually | |
24 // by e.g. faking the channel returned in chrome::GetChannel(). It's likely good | |
25 // to have the test anyway, even though a failure might not be detected until a | |
26 // branch has been promoted to another channel. The unit test for | |
27 // ChromeContentBrowserClient::MaybeCopyDisableWebRtcEncryptionSwitch tests for | |
28 // all channels however. | |
29 // TODO(grunell): Test the different channel cases for any build. | |
30 class WebRtcDisableEncryptionFlagBrowserTest : public WebRtcTestBase { | |
31 public: | |
32 WebRtcDisableEncryptionFlagBrowserTest() {} | |
33 ~WebRtcDisableEncryptionFlagBrowserTest() override {} | |
34 | |
35 void SetUpInProcessBrowserTestFixture() override { | |
36 DetectErrorsInJavaScript(); // Look for errors in our rather complex js. | |
37 } | |
38 | |
39 void SetUpCommandLine(base::CommandLine* command_line) override { | |
40 // This test should run with fake devices. | |
41 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream); | |
42 | |
43 // Disable encryption with the command line flag. | |
44 command_line->AppendSwitch(switches::kDisableWebRtcEncryption); | |
45 } | |
46 | |
47 private: | |
48 DISALLOW_COPY_AND_ASSIGN(WebRtcDisableEncryptionFlagBrowserTest); | |
49 }; | |
50 | |
51 // Makes a call and checks that there's encryption or not in the SDP offer. | |
52 IN_PROC_BROWSER_TEST_F(WebRtcDisableEncryptionFlagBrowserTest, | |
53 VerifyEncryption) { | |
54 ASSERT_TRUE(embedded_test_server()->Start()); | |
55 | |
56 content::WebContents* left_tab = | |
57 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | |
58 content::WebContents* right_tab = | |
59 OpenTestPageAndGetUserMediaInNewTab(kMainWebrtcTestHtmlPage); | |
60 | |
61 SetupPeerconnectionWithLocalStream(left_tab); | |
62 SetupPeerconnectionWithLocalStream(right_tab); | |
63 | |
64 NegotiateCall(left_tab, right_tab); | |
65 | |
66 StartDetectingVideo(left_tab, "remote-view"); | |
67 StartDetectingVideo(right_tab, "remote-view"); | |
68 | |
69 WaitForVideoToPlay(left_tab); | |
70 WaitForVideoToPlay(right_tab); | |
71 | |
72 bool should_detect_encryption = true; | |
73 version_info::Channel channel = chrome::GetChannel(); | |
74 if (channel == version_info::Channel::UNKNOWN || | |
75 channel == version_info::Channel::CANARY || | |
76 channel == version_info::Channel::DEV) { | |
77 should_detect_encryption = false; | |
78 } | |
79 #if defined(OS_ANDROID) | |
80 if (channel == version_info::Channel::BETA) | |
81 should_detect_encryption = false; | |
82 #endif | |
83 | |
84 std::string expected_string = should_detect_encryption ? | |
85 "crypto-seen" : "no-crypto-seen"; | |
86 | |
87 ASSERT_EQ(expected_string, | |
88 ExecuteJavascript("hasSeenCryptoInSdp()", left_tab)); | |
89 | |
90 HangUp(left_tab); | |
91 HangUp(right_tab); | |
92 } | |
OLD | NEW |