Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: chrome/browser/media/media_stream_infobar_browsertest.cc

Issue 2307083002: Cleanup: move WebRTC related files from chrome/browser/media to chrome/browser/media/webrtc/ (Closed)
Patch Set: Removed file wrongly resuscitated during rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #include "base/command_line.h"
6 #include "base/files/file_util.h"
7 #include "base/macros.h"
8 #include "base/strings/stringprintf.h"
9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/content_settings/host_content_settings_map_factory.h"
11 #include "chrome/browser/media/media_stream_devices_controller.h"
12 #include "chrome/browser/media/webrtc_browsertest_base.h"
13 #include "chrome/browser/media/webrtc_browsertest_common.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_tabstrip.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/test/base/in_process_browser_test.h"
20 #include "chrome/test/base/test_switches.h"
21 #include "chrome/test/base/ui_test_utils.h"
22 #include "components/content_settings/core/browser/host_content_settings_map.h"
23 #include "components/content_settings/core/common/content_settings_types.h"
24 #include "content/public/browser/notification_service.h"
25 #include "content/public/common/content_switches.h"
26 #include "content/public/common/media_stream_request.h"
27 #include "content/public/common/origin_util.h"
28 #include "content/public/test/browser_test_utils.h"
29 #include "media/base/media_switches.h"
30 #include "net/dns/mock_host_resolver.h"
31 #include "net/test/embedded_test_server/embedded_test_server.h"
32
33 // MediaStreamPermissionTest ---------------------------------------------------
34
35 class MediaStreamPermissionTest : public WebRtcTestBase {
36 public:
37 MediaStreamPermissionTest() {}
38 ~MediaStreamPermissionTest() override {}
39
40 // InProcessBrowserTest:
41 void SetUpCommandLine(base::CommandLine* command_line) override {
42 // This test expects to run with fake devices but real UI.
43 command_line->AppendSwitch(switches::kUseFakeDeviceForMediaStream);
44 EXPECT_FALSE(command_line->HasSwitch(switches::kUseFakeUIForMediaStream))
45 << "Since this test tests the UI we want the real UI!";
46 }
47
48 protected:
49 content::WebContents* LoadTestPageInTab() {
50 return LoadTestPageInBrowser(browser());
51 }
52
53 content::WebContents* LoadTestPageInIncognitoTab() {
54 return LoadTestPageInBrowser(CreateIncognitoBrowser());
55 }
56
57 // Returns the URL of the main test page.
58 GURL test_page_url() const {
59 const char kMainWebrtcTestHtmlPage[] = "/webrtc/webrtc_jsep01_test.html";
60 return embedded_test_server()->GetURL(kMainWebrtcTestHtmlPage);
61 }
62
63 private:
64 content::WebContents* LoadTestPageInBrowser(Browser* browser) {
65 EXPECT_TRUE(embedded_test_server()->Start());
66
67 // Uses the default server.
68 GURL url = test_page_url();
69
70 EXPECT_TRUE(content::IsOriginSecure(url));
71
72 ui_test_utils::NavigateToURL(browser, url);
73 return browser->tab_strip_model()->GetActiveWebContents();
74 }
75
76 // Dummy callback for when we deny the current request directly.
77 static void OnMediaStreamResponse(
78 const content::MediaStreamDevices& devices,
79 content::MediaStreamRequestResult result,
80 std::unique_ptr<content::MediaStreamUI> ui) {}
81
82 DISALLOW_COPY_AND_ASSIGN(MediaStreamPermissionTest);
83 };
84
85 // Actual tests ---------------------------------------------------------------
86
87 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, TestAllowingUserMedia) {
88 content::WebContents* tab_contents = LoadTestPageInTab();
89 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
90 }
91
92 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, TestDenyingUserMedia) {
93 content::WebContents* tab_contents = LoadTestPageInTab();
94 GetUserMediaAndDeny(tab_contents);
95 }
96
97 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, TestDismissingRequest) {
98 content::WebContents* tab_contents = LoadTestPageInTab();
99 GetUserMediaAndDismiss(tab_contents);
100 }
101
102 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
103 TestDenyingUserMediaIncognito) {
104 content::WebContents* tab_contents = LoadTestPageInIncognitoTab();
105 GetUserMediaAndDeny(tab_contents);
106 }
107
108 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
109 TestSecureOriginDenyIsSticky) {
110 content::WebContents* tab_contents = LoadTestPageInTab();
111 EXPECT_TRUE(content::IsOriginSecure(tab_contents->GetLastCommittedURL()));
112
113 GetUserMediaAndDeny(tab_contents);
114 GetUserMediaAndExpectAutoDenyWithoutPrompt(tab_contents);
115 }
116
117 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
118 TestSecureOriginAcceptIsSticky) {
119 content::WebContents* tab_contents = LoadTestPageInTab();
120 EXPECT_TRUE(content::IsOriginSecure(tab_contents->GetLastCommittedURL()));
121
122 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents));
123 GetUserMediaAndExpectAutoAcceptWithoutPrompt(tab_contents);
124 }
125
126 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest, TestDismissIsNotSticky) {
127 content::WebContents* tab_contents = LoadTestPageInTab();
128
129 GetUserMediaAndDismiss(tab_contents);
130 GetUserMediaAndDismiss(tab_contents);
131 }
132
133 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
134 TestDenyingThenClearingStickyException) {
135 content::WebContents* tab_contents = LoadTestPageInTab();
136
137 GetUserMediaAndDeny(tab_contents);
138 GetUserMediaAndExpectAutoDenyWithoutPrompt(tab_contents);
139
140 HostContentSettingsMap* settings_map =
141 HostContentSettingsMapFactory::GetForProfile(browser()->profile());
142
143 settings_map->ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC);
144 settings_map->ClearSettingsForOneType(
145 CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA);
146
147 GetUserMediaAndDeny(tab_contents);
148 }
149
150 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
151 DenyingMicDoesNotCauseStickyDenyForCameras) {
152 content::WebContents* tab_contents = LoadTestPageInTab();
153
154 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents,
155 kAudioOnlyCallConstraints);
156 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept(
157 tab_contents, kVideoOnlyCallConstraints));
158 }
159
160 IN_PROC_BROWSER_TEST_F(MediaStreamPermissionTest,
161 DenyingCameraDoesNotCauseStickyDenyForMics) {
162 content::WebContents* tab_contents = LoadTestPageInTab();
163
164 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents,
165 kVideoOnlyCallConstraints);
166 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept(
167 tab_contents, kAudioOnlyCallConstraints));
168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698