OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
9 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
10 #include "chrome/browser/media/media_stream_devices_controller.h" | 10 #include "chrome/browser/media/media_stream_devices_controller.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 content::MediaStreamRequestResult result, | 99 content::MediaStreamRequestResult result, |
100 scoped_ptr<content::MediaStreamUI> ui) {} | 100 scoped_ptr<content::MediaStreamUI> ui) {} |
101 | 101 |
102 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarTest); | 102 DISALLOW_COPY_AND_ASSIGN(MediaStreamInfoBarTest); |
103 }; | 103 }; |
104 | 104 |
105 // Actual tests --------------------------------------------------------------- | 105 // Actual tests --------------------------------------------------------------- |
106 | 106 |
107 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestAllowingUserMedia) { | 107 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestAllowingUserMedia) { |
108 content::WebContents* tab_contents = LoadTestPageInTab(); | 108 content::WebContents* tab_contents = LoadTestPageInTab(); |
109 GetUserMediaAndAccept(tab_contents); | 109 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); |
110 } | 110 } |
111 | 111 |
112 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDenyingUserMedia) { | 112 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDenyingUserMedia) { |
113 content::WebContents* tab_contents = LoadTestPageInTab(); | 113 content::WebContents* tab_contents = LoadTestPageInTab(); |
114 GetUserMediaAndDeny(tab_contents); | 114 GetUserMediaAndDeny(tab_contents); |
115 } | 115 } |
116 | 116 |
117 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissingInfobar) { | 117 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissingInfobar) { |
118 content::WebContents* tab_contents = LoadTestPageInTab(); | 118 content::WebContents* tab_contents = LoadTestPageInTab(); |
119 GetUserMediaAndDismiss(tab_contents); | 119 GetUserMediaAndDismiss(tab_contents); |
120 } | 120 } |
121 | 121 |
122 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDenyingUserMediaIncognito) { | 122 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDenyingUserMediaIncognito) { |
123 content::WebContents* tab_contents = LoadTestPageInIncognitoTab(); | 123 content::WebContents* tab_contents = LoadTestPageInIncognitoTab(); |
124 GetUserMediaAndDeny(tab_contents); | 124 GetUserMediaAndDeny(tab_contents); |
125 } | 125 } |
126 | 126 |
127 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, | 127 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, |
128 TestAcceptThenDenyWhichShouldBeSticky) { | 128 TestAcceptThenDenyWhichShouldBeSticky) { |
129 #if defined(OS_WIN) && defined(USE_ASH) | 129 #if defined(OS_WIN) && defined(USE_ASH) |
130 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 130 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
131 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 131 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
132 switches::kAshBrowserTests)) | 132 switches::kAshBrowserTests)) |
133 return; | 133 return; |
134 #endif | 134 #endif |
135 | 135 |
136 content::WebContents* tab_contents = LoadTestPageInTab(); | 136 content::WebContents* tab_contents = LoadTestPageInTab(); |
137 | 137 |
138 GetUserMediaAndAccept(tab_contents); | 138 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); |
139 GetUserMediaAndDeny(tab_contents); | 139 GetUserMediaAndDeny(tab_contents); |
140 | 140 |
141 // Should fail with permission denied right away with no infobar popping up. | 141 // Should fail with permission denied right away with no infobar popping up. |
142 GetUserMedia(tab_contents, kAudioVideoCallConstraints); | 142 GetUserMedia(tab_contents, kAudioVideoCallConstraints); |
143 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", | 143 EXPECT_TRUE(test::PollingWaitUntil("obtainGetUserMediaResult()", |
144 kFailedWithPermissionDeniedError, | 144 kFailedWithPermissionDeniedError, |
145 tab_contents)); | 145 tab_contents)); |
146 InfoBarService* infobar_service = | 146 InfoBarService* infobar_service = |
147 InfoBarService::FromWebContents(tab_contents); | 147 InfoBarService::FromWebContents(tab_contents); |
148 EXPECT_EQ(0u, infobar_service->infobar_count()); | 148 EXPECT_EQ(0u, infobar_service->infobar_count()); |
149 } | 149 } |
150 | 150 |
151 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestAcceptIsNotSticky) { | 151 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestAcceptIsNotSticky) { |
152 content::WebContents* tab_contents = LoadTestPageInTab(); | 152 content::WebContents* tab_contents = LoadTestPageInTab(); |
153 | 153 |
154 // If accept were sticky the second call would hang because it hangs if an | 154 // If accept were sticky the second call would hang because it hangs if an |
155 // infobar does not pop up. | 155 // infobar does not pop up. |
156 GetUserMediaAndAccept(tab_contents); | 156 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); |
157 GetUserMediaAndAccept(tab_contents); | 157 EXPECT_TRUE(GetUserMediaAndAccept(tab_contents)); |
158 } | 158 } |
159 | 159 |
160 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissIsNotSticky) { | 160 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, TestDismissIsNotSticky) { |
161 content::WebContents* tab_contents = LoadTestPageInTab(); | 161 content::WebContents* tab_contents = LoadTestPageInTab(); |
162 | 162 |
163 // If dismiss were sticky the second call would hang because it hangs if an | 163 // If dismiss were sticky the second call would hang because it hangs if an |
164 // infobar does not pop up. | 164 // infobar does not pop up. |
165 GetUserMediaAndDismiss(tab_contents); | 165 GetUserMediaAndDismiss(tab_contents); |
166 GetUserMediaAndDismiss(tab_contents); | 166 GetUserMediaAndDismiss(tab_contents); |
167 } | 167 } |
(...skipping 23 matching lines...) Expand all Loading... |
191 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \ | 191 #define MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras \ |
192 DenyingMicDoesNotCauseStickyDenyForCameras | 192 DenyingMicDoesNotCauseStickyDenyForCameras |
193 #endif | 193 #endif |
194 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, | 194 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, |
195 MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras) { | 195 MAYBE_DenyingMicDoesNotCauseStickyDenyForCameras) { |
196 content::WebContents* tab_contents = LoadTestPageInTab(); | 196 content::WebContents* tab_contents = LoadTestPageInTab(); |
197 | 197 |
198 // If mic blocking also blocked cameras, the second call here would hang. | 198 // If mic blocking also blocked cameras, the second call here would hang. |
199 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, | 199 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, |
200 kAudioOnlyCallConstraints); | 200 kAudioOnlyCallConstraints); |
201 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, | 201 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( |
202 kVideoOnlyCallConstraints); | 202 tab_contents, kVideoOnlyCallConstraints)); |
203 } | 203 } |
204 | 204 |
205 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, | 205 IN_PROC_BROWSER_TEST_F(MediaStreamInfoBarTest, |
206 DenyingCameraDoesNotCauseStickyDenyForMics) { | 206 DenyingCameraDoesNotCauseStickyDenyForMics) { |
207 content::WebContents* tab_contents = LoadTestPageInTab(); | 207 content::WebContents* tab_contents = LoadTestPageInTab(); |
208 | 208 |
209 // If camera blocking also blocked mics, the second call here would hang. | 209 // If camera blocking also blocked mics, the second call here would hang. |
210 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, | 210 GetUserMediaWithSpecificConstraintsAndDeny(tab_contents, |
211 kVideoOnlyCallConstraints); | 211 kVideoOnlyCallConstraints); |
212 GetUserMediaWithSpecificConstraintsAndAccept(tab_contents, | 212 EXPECT_TRUE(GetUserMediaWithSpecificConstraintsAndAccept( |
213 kAudioOnlyCallConstraints); | 213 tab_contents, kAudioOnlyCallConstraints)); |
214 } | 214 } |
OLD | NEW |