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

Side by Side Diff: android_webview/javatests/src/org/chromium/android_webview/test/MediaAccessPermissionRequestTest.java

Issue 2696443002: Reland of Use spec-compliant algorithm to select video devices in getUserMedia. (Closed)
Patch Set: Address boliu's comments Created 3 years, 10 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
« no previous file with comments | « no previous file | content/browser/webrtc/webrtc_getusermedia_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 package org.chromium.android_webview.test; 5 package org.chromium.android_webview.test;
6 6
7 import android.support.test.filters.SmallTest; 7 import android.support.test.filters.SmallTest;
8 8
9 import org.chromium.android_webview.AwContents; 9 import org.chromium.android_webview.AwContents;
10 import org.chromium.android_webview.permission.AwPermissionRequest; 10 import org.chromium.android_webview.permission.AwPermissionRequest;
11 import org.chromium.android_webview.test.util.CommonResources; 11 import org.chromium.android_webview.test.util.CommonResources;
12 import org.chromium.base.annotations.SuppressFBWarnings; 12 import org.chromium.base.annotations.SuppressFBWarnings;
13 import org.chromium.base.test.util.CallbackHelper; 13 import org.chromium.base.test.util.CallbackHelper;
14 import org.chromium.base.test.util.CommandLineFlags;
14 import org.chromium.base.test.util.DisableIf; 15 import org.chromium.base.test.util.DisableIf;
15 import org.chromium.base.test.util.Feature; 16 import org.chromium.base.test.util.Feature;
16 import org.chromium.base.test.util.RetryOnFailure; 17 import org.chromium.base.test.util.RetryOnFailure;
18 import org.chromium.content.common.ContentSwitches;
17 import org.chromium.net.test.util.TestWebServer; 19 import org.chromium.net.test.util.TestWebServer;
18 20
19 import java.util.concurrent.Callable; 21 import java.util.concurrent.Callable;
20 22
21 /** 23 /**
22 * Test MediaAccessPermissionRequest. 24 * Test MediaAccessPermissionRequest.
23 */ 25 */
24 public class MediaAccessPermissionRequestTest extends AwTestBase { 26 public class MediaAccessPermissionRequestTest extends AwTestBase {
25 private static class OnPermissionRequestHelper extends CallbackHelper { 27 private static class OnPermissionRequestHelper extends CallbackHelper {
26 private boolean mCanceled; 28 private boolean mCanceled;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 @Override 71 @Override
70 protected void tearDown() throws Exception { 72 protected void tearDown() throws Exception {
71 mTestWebServer.shutdown(); 73 mTestWebServer.shutdown();
72 mTestWebServer = null; 74 mTestWebServer = null;
73 super.tearDown(); 75 super.tearDown();
74 } 76 }
75 77
76 @Feature({"AndroidWebView"}) 78 @Feature({"AndroidWebView"})
77 @SmallTest 79 @SmallTest
78 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/623921") 80 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/623921")
81 @CommandLineFlags.Add(ContentSwitches.USE_FAKE_DEVICE_FOR_MEDIA_STREAM)
79 @RetryOnFailure 82 @RetryOnFailure
80 public void testGrantAccess() throws Throwable { 83 public void testGrantAccess() throws Throwable {
81 final OnPermissionRequestHelper helper = new OnPermissionRequestHelper() ; 84 final OnPermissionRequestHelper helper = new OnPermissionRequestHelper() ;
82 TestAwContentsClient contentsClient = 85 TestAwContentsClient contentsClient =
83 new TestAwContentsClient() { 86 new TestAwContentsClient() {
84 @Override 87 @Override
85 public void onPermissionRequest(AwPermissionRequest awPermis sionRequest) { 88 public void onPermissionRequest(AwPermissionRequest awPermis sionRequest) {
86 awPermissionRequest.grant(); 89 awPermissionRequest.grant();
87 helper.notifyCalled(); 90 helper.notifyCalled();
88 } 91 }
89 }; 92 };
90 final AwTestContainerView testContainerView = 93 final AwTestContainerView testContainerView =
91 createAwTestContainerViewOnMainSync(contentsClient); 94 createAwTestContainerViewOnMainSync(contentsClient);
92 final AwContents awContents = testContainerView.getAwContents(); 95 final AwContents awContents = testContainerView.getAwContents();
93 enableJavaScriptOnUiThread(awContents); 96 enableJavaScriptOnUiThread(awContents);
94 int callCount = helper.getCallCount(); 97 int callCount = helper.getCallCount();
95 loadUrlAsync(awContents, mWebRTCPage, null); 98 loadUrlAsync(awContents, mWebRTCPage, null);
96 helper.waitForCallback(callCount); 99 helper.waitForCallback(callCount);
97 pollTitleAs("grant", awContents); 100 pollTitleAs("grant", awContents);
98 } 101 }
99 102
100 @Feature({"AndroidWebView"}) 103 @Feature({"AndroidWebView"})
101 @SmallTest 104 @SmallTest
102 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/614347") 105 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/614347")
106 @CommandLineFlags.Add(ContentSwitches.USE_FAKE_DEVICE_FOR_MEDIA_STREAM)
103 @RetryOnFailure 107 @RetryOnFailure
104 public void testDenyAccess() throws Throwable { 108 public void testDenyAccess() throws Throwable {
105 final OnPermissionRequestHelper helper = new OnPermissionRequestHelper() ; 109 final OnPermissionRequestHelper helper = new OnPermissionRequestHelper() ;
106 TestAwContentsClient contentsClient = 110 TestAwContentsClient contentsClient =
107 new TestAwContentsClient() { 111 new TestAwContentsClient() {
108 @Override 112 @Override
109 public void onPermissionRequest(AwPermissionRequest awPermis sionRequest) { 113 public void onPermissionRequest(AwPermissionRequest awPermis sionRequest) {
110 awPermissionRequest.deny(); 114 awPermissionRequest.deny();
111 helper.notifyCalled(); 115 helper.notifyCalled();
112 } 116 }
(...skipping 14 matching lines...) Expand all
127 @Override 131 @Override
128 public Boolean call() throws Exception { 132 public Boolean call() throws Exception {
129 return title.equals(getTitleOnUiThread(awContents)); 133 return title.equals(getTitleOnUiThread(awContents));
130 } 134 }
131 }); 135 });
132 } 136 }
133 137
134 @Feature({"AndroidWebView"}) 138 @Feature({"AndroidWebView"})
135 @SmallTest 139 @SmallTest
136 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/614347") 140 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/614347")
141 @CommandLineFlags.Add(ContentSwitches.USE_FAKE_DEVICE_FOR_MEDIA_STREAM)
137 @RetryOnFailure 142 @RetryOnFailure
138 public void testDenyAccessByDefault() throws Throwable { 143 public void testDenyAccessByDefault() throws Throwable {
139 final OnPermissionRequestHelper helper = new OnPermissionRequestHelper() ; 144 final OnPermissionRequestHelper helper = new OnPermissionRequestHelper() ;
140 TestAwContentsClient contentsClient = 145 TestAwContentsClient contentsClient =
141 new TestAwContentsClient() { 146 new TestAwContentsClient() {
142 @Override 147 @Override
143 public void onPermissionRequest(AwPermissionRequest awPermis sionRequest) { 148 public void onPermissionRequest(AwPermissionRequest awPermis sionRequest) {
144 // Intentionally do nothing with awPermissionRequest. 149 // Intentionally do nothing with awPermissionRequest.
145 helper.notifyCalled(); 150 helper.notifyCalled();
146 } 151 }
(...skipping 17 matching lines...) Expand all
164 public Boolean call() throws Exception { 169 public Boolean call() throws Exception {
165 Runtime.getRuntime().gc(); 170 Runtime.getRuntime().gc();
166 return "deny".equals(getTitleOnUiThread(awContents)); 171 return "deny".equals(getTitleOnUiThread(awContents));
167 } 172 }
168 }); 173 });
169 } 174 }
170 175
171 @Feature({"AndroidWebView"}) 176 @Feature({"AndroidWebView"})
172 @SmallTest 177 @SmallTest
173 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/614347") 178 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/614347")
179 @CommandLineFlags.Add(ContentSwitches.USE_FAKE_DEVICE_FOR_MEDIA_STREAM)
174 @RetryOnFailure 180 @RetryOnFailure
175 public void testCancelPermission() throws Throwable { 181 public void testCancelPermission() throws Throwable {
176 final OnPermissionRequestHelper helper = new OnPermissionRequestHelper() ; 182 final OnPermissionRequestHelper helper = new OnPermissionRequestHelper() ;
177 TestAwContentsClient contentsClient = 183 TestAwContentsClient contentsClient =
178 new TestAwContentsClient() { 184 new TestAwContentsClient() {
179 private AwPermissionRequest mRequest; 185 private AwPermissionRequest mRequest;
180 @Override 186 @Override
181 public void onPermissionRequest(AwPermissionRequest awPermis sionRequest) { 187 public void onPermissionRequest(AwPermissionRequest awPermis sionRequest) {
182 assertNull(mRequest); 188 assertNull(mRequest);
183 mRequest = awPermissionRequest; 189 mRequest = awPermissionRequest;
(...skipping 15 matching lines...) Expand all
199 int callCount = helper.getCallCount(); 205 int callCount = helper.getCallCount();
200 loadUrlAsync(awContents, mWebRTCPage, null); 206 loadUrlAsync(awContents, mWebRTCPage, null);
201 helper.waitForCallback(callCount); 207 helper.waitForCallback(callCount);
202 callCount = helper.getCallCount(); 208 callCount = helper.getCallCount();
203 // Load the same page again, the previous request should be canceled. 209 // Load the same page again, the previous request should be canceled.
204 loadUrlAsync(awContents, mWebRTCPage, null); 210 loadUrlAsync(awContents, mWebRTCPage, null);
205 helper.waitForCallback(callCount); 211 helper.waitForCallback(callCount);
206 assertTrue(helper.canceled()); 212 assertTrue(helper.canceled());
207 } 213 }
208 } 214 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/webrtc/webrtc_getusermedia_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698