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 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
6 | 6 |
7 import android.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
8 import android.view.KeyEvent; | 8 import android.view.KeyEvent; |
9 import android.view.View; | 9 import android.view.View; |
10 import android.view.ViewGroup; | 10 import android.view.ViewGroup; |
11 | 11 |
12 import org.chromium.android_webview.test.util.JavascriptEventObserver; | 12 import org.chromium.android_webview.test.util.JavascriptEventObserver; |
13 import org.chromium.android_webview.test.util.VideoSurfaceViewUtils; | 13 import org.chromium.android_webview.test.util.VideoSurfaceViewUtils; |
| 14 import org.chromium.base.test.util.DisableIf; |
14 import org.chromium.base.test.util.Feature; | 15 import org.chromium.base.test.util.Feature; |
15 import org.chromium.base.test.util.parameter.ParameterizedTest; | 16 import org.chromium.base.test.util.parameter.ParameterizedTest; |
16 import org.chromium.content.browser.ContentViewCore; | 17 import org.chromium.content.browser.ContentViewCore; |
17 import org.chromium.content.browser.test.util.Criteria; | 18 import org.chromium.content.browser.test.util.Criteria; |
18 import org.chromium.content.browser.test.util.CriteriaHelper; | 19 import org.chromium.content.browser.test.util.CriteriaHelper; |
19 import org.chromium.content.browser.test.util.DOMUtils; | 20 import org.chromium.content.browser.test.util.DOMUtils; |
20 import org.chromium.content.browser.test.util.TouchCommon; | 21 import org.chromium.content.browser.test.util.TouchCommon; |
21 import org.chromium.content_public.browser.WebContents; | 22 import org.chromium.content_public.browser.WebContents; |
22 | 23 |
23 import java.util.concurrent.Callable; | 24 import java.util.concurrent.Callable; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 mTestContainerView = | 58 mTestContainerView = |
58 createAwTestContainerViewOnMainSync(mContentsClient); | 59 createAwTestContainerViewOnMainSync(mContentsClient); |
59 mContentViewCore = mTestContainerView.getContentViewCore(); | 60 mContentViewCore = mTestContainerView.getContentViewCore(); |
60 enableJavaScriptOnUiThread(mTestContainerView.getAwContents()); | 61 enableJavaScriptOnUiThread(mTestContainerView.getAwContents()); |
61 mTestContainerView.getAwContents().getSettings().setFullscreenSupported(
true); | 62 mTestContainerView.getAwContents().getSettings().setFullscreenSupported(
true); |
62 } | 63 } |
63 | 64 |
64 @MediumTest | 65 @MediumTest |
65 @Feature({"AndroidWebView"}) | 66 @Feature({"AndroidWebView"}) |
66 @DisableHardwareAccelerationForTest | 67 @DisableHardwareAccelerationForTest |
| 68 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
67 public void testFullscreenVideoInSoftwareModeDoesNotDeadlock() throws Throwa
ble { | 69 public void testFullscreenVideoInSoftwareModeDoesNotDeadlock() throws Throwa
ble { |
68 // Although fullscreen video is not supported without hardware accelerat
ion | 70 // Although fullscreen video is not supported without hardware accelerat
ion |
69 // we should not deadlock if apps try to use it. | 71 // we should not deadlock if apps try to use it. |
70 loadTestPageAndClickFullscreen(VIDEO_TEST_URL); | 72 loadTestPageAndClickFullscreen(VIDEO_TEST_URL); |
71 mContentsClient.waitForCustomViewShown(); | 73 mContentsClient.waitForCustomViewShown(); |
72 runTestOnUiThread(new Runnable() { | 74 runTestOnUiThread(new Runnable() { |
73 @Override | 75 @Override |
74 public void run() { | 76 public void run() { |
75 mContentsClient.getExitCallback().onCustomViewHidden(); | 77 mContentsClient.getExitCallback().onCustomViewHidden(); |
76 } | 78 } |
77 }); | 79 }); |
78 mContentsClient.waitForCustomViewHidden(); | 80 mContentsClient.waitForCustomViewHidden(); |
79 } | 81 } |
80 | 82 |
81 @MediumTest | 83 @MediumTest |
82 @Feature({"AndroidWebView"}) | 84 @Feature({"AndroidWebView"}) |
83 @DisableHardwareAccelerationForTest | 85 @DisableHardwareAccelerationForTest |
| 86 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
84 public void testFullscreenForNonVideoElementIsSupportedInSoftwareMode() thro
ws Throwable { | 87 public void testFullscreenForNonVideoElementIsSupportedInSoftwareMode() thro
ws Throwable { |
85 // Fullscreen for non-video elements is supported and works as expected.
Note that | 88 // Fullscreen for non-video elements is supported and works as expected.
Note that |
86 // this test is the same as testOnShowAndHideCustomViewWithCallback_vide
oInsideDiv below. | 89 // this test is the same as testOnShowAndHideCustomViewWithCallback_vide
oInsideDiv below. |
87 doTestOnShowAndHideCustomViewWithCallback(VIDEO_INSIDE_DIV_TEST_URL); | 90 doTestOnShowAndHideCustomViewWithCallback(VIDEO_INSIDE_DIV_TEST_URL); |
88 } | 91 } |
89 | 92 |
90 @MediumTest | 93 @MediumTest |
91 @Feature({"AndroidWebView"}) | 94 @Feature({"AndroidWebView"}) |
| 95 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
92 public void testOnShowAndHideCustomViewWithCallback_video() throws Throwable
{ | 96 public void testOnShowAndHideCustomViewWithCallback_video() throws Throwable
{ |
93 doTestOnShowAndHideCustomViewWithCallback(VIDEO_TEST_URL); | 97 doTestOnShowAndHideCustomViewWithCallback(VIDEO_TEST_URL); |
94 } | 98 } |
95 | 99 |
96 @MediumTest | 100 @MediumTest |
97 @Feature({"AndroidWebView"}) | 101 @Feature({"AndroidWebView"}) |
| 102 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
98 public void testOnShowAndHideCustomViewWithCallback_videoInsideDiv() throws
Throwable { | 103 public void testOnShowAndHideCustomViewWithCallback_videoInsideDiv() throws
Throwable { |
99 doTestOnShowAndHideCustomViewWithCallback(VIDEO_INSIDE_DIV_TEST_URL); | 104 doTestOnShowAndHideCustomViewWithCallback(VIDEO_INSIDE_DIV_TEST_URL); |
100 } | 105 } |
101 | 106 |
102 public void doTestOnShowAndHideCustomViewWithCallback(String videoTestUrl) t
hrows Throwable { | 107 public void doTestOnShowAndHideCustomViewWithCallback(String videoTestUrl) t
hrows Throwable { |
103 doOnShowAndHideCustomViewTest(videoTestUrl, new Runnable() { | 108 doOnShowAndHideCustomViewTest(videoTestUrl, new Runnable() { |
104 @Override | 109 @Override |
105 public void run() { | 110 public void run() { |
106 mContentsClient.getExitCallback().onCustomViewHidden(); | 111 mContentsClient.getExitCallback().onCustomViewHidden(); |
107 } | 112 } |
108 }); | 113 }); |
109 } | 114 } |
110 | 115 |
111 @MediumTest | 116 @MediumTest |
112 @Feature({"AndroidWebView"}) | 117 @Feature({"AndroidWebView"}) |
| 118 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
113 public void testOnShowAndHideCustomViewWithJavascript_video() throws Throwab
le { | 119 public void testOnShowAndHideCustomViewWithJavascript_video() throws Throwab
le { |
114 doTestOnShowAndHideCustomViewWithJavascript(VIDEO_TEST_URL); | 120 doTestOnShowAndHideCustomViewWithJavascript(VIDEO_TEST_URL); |
115 } | 121 } |
116 | 122 |
117 @MediumTest | 123 @MediumTest |
118 @Feature({"AndroidWebView"}) | 124 @Feature({"AndroidWebView"}) |
| 125 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
119 public void testOnShowAndHideCustomViewWithJavascript_videoInsideDiv() | 126 public void testOnShowAndHideCustomViewWithJavascript_videoInsideDiv() |
120 throws Throwable { | 127 throws Throwable { |
121 doTestOnShowAndHideCustomViewWithJavascript(VIDEO_INSIDE_DIV_TEST_URL); | 128 doTestOnShowAndHideCustomViewWithJavascript(VIDEO_INSIDE_DIV_TEST_URL); |
122 } | 129 } |
123 | 130 |
124 public void doTestOnShowAndHideCustomViewWithJavascript(String videoTestUrl)
throws Throwable { | 131 public void doTestOnShowAndHideCustomViewWithJavascript(String videoTestUrl)
throws Throwable { |
125 doOnShowAndHideCustomViewTest(videoTestUrl, new Runnable() { | 132 doOnShowAndHideCustomViewTest(videoTestUrl, new Runnable() { |
126 @Override | 133 @Override |
127 public void run() { | 134 public void run() { |
128 DOMUtils.exitFullscreen(mContentViewCore.getWebContents()); | 135 DOMUtils.exitFullscreen(mContentViewCore.getWebContents()); |
129 } | 136 } |
130 }); | 137 }); |
131 } | 138 } |
132 | 139 |
133 @MediumTest | 140 @MediumTest |
134 @Feature({"AndroidWebView"}) | 141 @Feature({"AndroidWebView"}) |
135 @ParameterizedTest.Set // crbug.com/616501 | 142 @ParameterizedTest.Set // crbug.com/616501 |
| 143 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
136 public void testOnShowAndHideCustomViewWithBackKey_video() throws Throwable
{ | 144 public void testOnShowAndHideCustomViewWithBackKey_video() throws Throwable
{ |
137 doTestOnShowAndHideCustomViewWithBackKey(VIDEO_TEST_URL); | 145 doTestOnShowAndHideCustomViewWithBackKey(VIDEO_TEST_URL); |
138 } | 146 } |
139 | 147 |
140 @MediumTest | 148 @MediumTest |
141 @Feature({"AndroidWebView"}) | 149 @Feature({"AndroidWebView"}) |
| 150 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
142 public void testOnShowAndHideCustomViewWithBackKey_videoInsideDiv() | 151 public void testOnShowAndHideCustomViewWithBackKey_videoInsideDiv() |
143 throws Throwable { | 152 throws Throwable { |
144 doTestOnShowAndHideCustomViewWithBackKey(VIDEO_INSIDE_DIV_TEST_URL); | 153 doTestOnShowAndHideCustomViewWithBackKey(VIDEO_INSIDE_DIV_TEST_URL); |
145 } | 154 } |
146 | 155 |
147 public void doTestOnShowAndHideCustomViewWithBackKey(String videoTestUrl) th
rows Throwable { | 156 public void doTestOnShowAndHideCustomViewWithBackKey(String videoTestUrl) th
rows Throwable { |
148 doOnShowCustomViewTest(videoTestUrl); | 157 doOnShowCustomViewTest(videoTestUrl); |
149 | 158 |
150 // The key event should not be propagated to mTestContainerView (the ori
ginal container | 159 // The key event should not be propagated to mTestContainerView (the ori
ginal container |
151 // view). | 160 // view). |
152 mTestContainerView.setOnKeyListener(new View.OnKeyListener() { | 161 mTestContainerView.setOnKeyListener(new View.OnKeyListener() { |
153 @Override | 162 @Override |
154 public boolean onKey(View v, int keyCode, KeyEvent event) { | 163 public boolean onKey(View v, int keyCode, KeyEvent event) { |
155 fail("mTestContainerView received key event"); | 164 fail("mTestContainerView received key event"); |
156 return false; | 165 return false; |
157 } | 166 } |
158 }); | 167 }); |
159 | 168 |
160 sendKeys(KeyEvent.KEYCODE_BACK); | 169 sendKeys(KeyEvent.KEYCODE_BACK); |
161 mContentsClient.waitForCustomViewHidden(); | 170 mContentsClient.waitForCustomViewHidden(); |
162 assertFalse(mContentsClient.wasOnUnhandledKeyUpEventCalled()); | 171 assertFalse(mContentsClient.wasOnUnhandledKeyUpEventCalled()); |
163 assertWaitForIsEmbedded(); | 172 assertWaitForIsEmbedded(); |
164 } | 173 } |
165 | 174 |
166 @MediumTest | 175 @MediumTest |
167 @Feature({"AndroidWebView"}) | 176 @Feature({"AndroidWebView"}) |
| 177 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
168 public void testExitFullscreenEndsIfAppInvokesCallbackFromOnHideCustomView()
throws Throwable { | 178 public void testExitFullscreenEndsIfAppInvokesCallbackFromOnHideCustomView()
throws Throwable { |
169 mContentsClient.setOnHideCustomViewRunnable(new Runnable() { | 179 mContentsClient.setOnHideCustomViewRunnable(new Runnable() { |
170 @Override | 180 @Override |
171 public void run() { | 181 public void run() { |
172 mContentsClient.getExitCallback().onCustomViewHidden(); | 182 mContentsClient.getExitCallback().onCustomViewHidden(); |
173 } | 183 } |
174 }); | 184 }); |
175 doTestOnShowAndHideCustomViewWithCallback(VIDEO_TEST_URL); | 185 doTestOnShowAndHideCustomViewWithCallback(VIDEO_TEST_URL); |
176 } | 186 } |
177 | 187 |
178 @MediumTest | 188 @MediumTest |
179 @Feature({"AndroidWebView"}) | 189 @Feature({"AndroidWebView"}) |
| 190 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
180 public void testOnShowCustomViewAndPlayWithHtmlControl_video() throws Throwa
ble { | 191 public void testOnShowCustomViewAndPlayWithHtmlControl_video() throws Throwa
ble { |
181 doTestOnShowCustomViewAndPlayWithHtmlControl(VIDEO_TEST_URL); | 192 doTestOnShowCustomViewAndPlayWithHtmlControl(VIDEO_TEST_URL); |
182 } | 193 } |
183 | 194 |
184 @MediumTest | 195 @MediumTest |
185 @Feature({"AndroidWebView"}) | 196 @Feature({"AndroidWebView"}) |
| 197 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
186 public void testOnShowCustomViewAndPlayWithHtmlControl_videoInsideDiv() thro
ws Throwable { | 198 public void testOnShowCustomViewAndPlayWithHtmlControl_videoInsideDiv() thro
ws Throwable { |
187 doTestOnShowCustomViewAndPlayWithHtmlControl(VIDEO_INSIDE_DIV_TEST_URL); | 199 doTestOnShowCustomViewAndPlayWithHtmlControl(VIDEO_INSIDE_DIV_TEST_URL); |
188 } | 200 } |
189 | 201 |
190 public void doTestOnShowCustomViewAndPlayWithHtmlControl(String videoTestUrl
) throws Throwable { | 202 public void doTestOnShowCustomViewAndPlayWithHtmlControl(String videoTestUrl
) throws Throwable { |
191 doOnShowCustomViewTest(videoTestUrl); | 203 doOnShowCustomViewTest(videoTestUrl); |
192 assertTrue(DOMUtils.isMediaPaused(getWebContentsOnUiThread(), VIDEO_ID))
; | 204 assertTrue(DOMUtils.isMediaPaused(getWebContentsOnUiThread(), VIDEO_ID))
; |
193 | 205 |
194 tapPlayButton(); | 206 tapPlayButton(); |
195 DOMUtils.waitForMediaPlay(getWebContentsOnUiThread(), VIDEO_ID); | 207 DOMUtils.waitForMediaPlay(getWebContentsOnUiThread(), VIDEO_ID); |
196 } | 208 } |
197 | 209 |
198 @MediumTest | 210 @MediumTest |
199 @Feature({"AndroidWebView"}) | 211 @Feature({"AndroidWebView"}) |
| 212 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
200 public void testHolePunchingSurfaceNotCreatedForClearVideo() | 213 public void testHolePunchingSurfaceNotCreatedForClearVideo() |
201 throws Throwable { | 214 throws Throwable { |
202 loadTestPage(VIDEO_TEST_URL); | 215 loadTestPage(VIDEO_TEST_URL); |
203 assertFalse(DOMUtils.isFullscreen(getWebContentsOnUiThread())); | 216 assertFalse(DOMUtils.isFullscreen(getWebContentsOnUiThread())); |
204 | 217 |
205 // Play and verify that a surface view for hole punching is not created. | 218 // Play and verify that a surface view for hole punching is not created. |
206 // Note that VIDEO_TEST_URL contains clear video. | 219 // Note that VIDEO_TEST_URL contains clear video. |
207 tapPlayButton(); | 220 tapPlayButton(); |
208 DOMUtils.waitForMediaPlay(getWebContentsOnUiThread(), VIDEO_ID); | 221 DOMUtils.waitForMediaPlay(getWebContentsOnUiThread(), VIDEO_ID); |
209 // Wait to ensure that the surface view is not added asynchronously. | 222 // Wait to ensure that the surface view is not added asynchronously. |
210 VideoSurfaceViewUtils.waitAndAssertContainsZeroVideoHoleSurfaceViews(thi
s, | 223 VideoSurfaceViewUtils.waitAndAssertContainsZeroVideoHoleSurfaceViews(thi
s, |
211 mTestContainerView); | 224 mTestContainerView); |
212 } | 225 } |
213 | 226 |
214 @MediumTest | 227 @MediumTest |
215 @Feature({"AndroidWebView"}) | 228 @Feature({"AndroidWebView"}) |
| 229 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
216 public void testOnShowCustomViewTransfersHolePunchingSurfaceForVideoInsideDi
v() | 230 public void testOnShowCustomViewTransfersHolePunchingSurfaceForVideoInsideDi
v() |
217 throws Throwable { | 231 throws Throwable { |
218 getInstrumentation().runOnMainSync(new Runnable() { | 232 getInstrumentation().runOnMainSync(new Runnable() { |
219 @Override | 233 @Override |
220 public void run() { | 234 public void run() { |
221 mTestContainerView.getAwContents().getSettings().setForceVideoOv
erlayForTests(true); | 235 mTestContainerView.getAwContents().getSettings().setForceVideoOv
erlayForTests(true); |
222 } | 236 } |
223 }); | 237 }); |
224 | 238 |
225 loadTestPage(VIDEO_INSIDE_DIV_TEST_URL); | 239 loadTestPage(VIDEO_INSIDE_DIV_TEST_URL); |
(...skipping 14 matching lines...) Expand all Loading... |
240 mContentsClient.waitForCustomViewShown(); | 254 mContentsClient.waitForCustomViewShown(); |
241 View customView = mContentsClient.getCustomView(); | 255 View customView = mContentsClient.getCustomView(); |
242 VideoSurfaceViewUtils.assertContainsZeroVideoHoleSurfaceViews(this, mTes
tContainerView); | 256 VideoSurfaceViewUtils.assertContainsZeroVideoHoleSurfaceViews(this, mTes
tContainerView); |
243 // Wait to ensure that the surface view stays there after being transfer
ed and not | 257 // Wait to ensure that the surface view stays there after being transfer
ed and not |
244 // removed asynchronously. | 258 // removed asynchronously. |
245 VideoSurfaceViewUtils.waitAndAssertContainsOneVideoHoleSurfaceView(this,
customView); | 259 VideoSurfaceViewUtils.waitAndAssertContainsOneVideoHoleSurfaceView(this,
customView); |
246 } | 260 } |
247 | 261 |
248 @MediumTest | 262 @MediumTest |
249 @Feature({"AndroidWebView"}) | 263 @Feature({"AndroidWebView"}) |
| 264 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
250 public void testOnShowCustomViewRemovesHolePunchingSurfaceForVideo() | 265 public void testOnShowCustomViewRemovesHolePunchingSurfaceForVideo() |
251 throws Throwable { | 266 throws Throwable { |
252 getInstrumentation().runOnMainSync(new Runnable() { | 267 getInstrumentation().runOnMainSync(new Runnable() { |
253 @Override | 268 @Override |
254 public void run() { | 269 public void run() { |
255 mTestContainerView.getAwContents().getSettings().setForceVideoOv
erlayForTests(true); | 270 mTestContainerView.getAwContents().getSettings().setForceVideoOv
erlayForTests(true); |
256 } | 271 } |
257 }); | 272 }); |
258 | 273 |
259 loadTestPage(VIDEO_TEST_URL); | 274 loadTestPage(VIDEO_TEST_URL); |
(...skipping 18 matching lines...) Expand all Loading... |
278 VideoSurfaceViewUtils.waitAndAssertContainsZeroVideoHoleSurfaceViews(thi
s, customView); | 293 VideoSurfaceViewUtils.waitAndAssertContainsZeroVideoHoleSurfaceViews(thi
s, customView); |
279 | 294 |
280 // Exit fullscreen and verify that the video hole surface is re-created. | 295 // Exit fullscreen and verify that the video hole surface is re-created. |
281 DOMUtils.exitFullscreen(mContentViewCore.getWebContents()); | 296 DOMUtils.exitFullscreen(mContentViewCore.getWebContents()); |
282 VideoSurfaceViewUtils.pollAndAssertContainsOneVideoHoleSurfaceView(this, | 297 VideoSurfaceViewUtils.pollAndAssertContainsOneVideoHoleSurfaceView(this, |
283 mTestContainerView); | 298 mTestContainerView); |
284 } | 299 } |
285 | 300 |
286 @MediumTest | 301 @MediumTest |
287 @Feature({"AndroidWebView"}) | 302 @Feature({"AndroidWebView"}) |
| 303 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
288 public void testFullscreenNotSupported_video() throws Throwable { | 304 public void testFullscreenNotSupported_video() throws Throwable { |
289 doTestFullscreenNotSupported(VIDEO_TEST_URL); | 305 doTestFullscreenNotSupported(VIDEO_TEST_URL); |
290 } | 306 } |
291 | 307 |
292 @MediumTest | 308 @MediumTest |
293 @Feature({"AndroidWebView"}) | 309 @Feature({"AndroidWebView"}) |
| 310 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
294 public void testFullscreenNotSupported_videoInsideDiv() throws Throwable { | 311 public void testFullscreenNotSupported_videoInsideDiv() throws Throwable { |
295 doTestFullscreenNotSupported(VIDEO_INSIDE_DIV_TEST_URL); | 312 doTestFullscreenNotSupported(VIDEO_INSIDE_DIV_TEST_URL); |
296 } | 313 } |
297 | 314 |
298 public void doTestFullscreenNotSupported(String videoTestUrl) throws Throwab
le { | 315 public void doTestFullscreenNotSupported(String videoTestUrl) throws Throwab
le { |
299 mTestContainerView.getAwContents().getSettings().setFullscreenSupported(
false); | 316 mTestContainerView.getAwContents().getSettings().setFullscreenSupported(
false); |
300 final JavascriptEventObserver fullscreenErrorObserver = registerObserver
( | 317 final JavascriptEventObserver fullscreenErrorObserver = registerObserver
( |
301 FULLSCREEN_ERROR_OBSERVER); | 318 FULLSCREEN_ERROR_OBSERVER); |
302 | 319 |
303 loadTestPageAndClickFullscreen(videoTestUrl); | 320 loadTestPageAndClickFullscreen(videoTestUrl); |
304 | 321 |
305 assertTrue(fullscreenErrorObserver.waitForEvent(WAIT_TIMEOUT_MS)); | 322 assertTrue(fullscreenErrorObserver.waitForEvent(WAIT_TIMEOUT_MS)); |
306 assertFalse(mContentsClient.wasCustomViewShownCalled()); | 323 assertFalse(mContentsClient.wasCustomViewShownCalled()); |
307 } | 324 } |
308 | 325 |
309 @MediumTest | 326 @MediumTest |
310 @Feature({"AndroidWebView"}) | 327 @Feature({"AndroidWebView"}) |
| 328 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
311 public void testPowerSaveBlockerIsEnabledDuringFullscreenPlayback_video() | 329 public void testPowerSaveBlockerIsEnabledDuringFullscreenPlayback_video() |
312 throws Throwable { | 330 throws Throwable { |
313 doTestPowerSaveBlockerIsEnabledDuringFullscreenPlayback(VIDEO_TEST_URL); | 331 doTestPowerSaveBlockerIsEnabledDuringFullscreenPlayback(VIDEO_TEST_URL); |
314 } | 332 } |
315 | 333 |
316 @MediumTest | 334 @MediumTest |
317 @Feature({"AndroidWebView"}) | 335 @Feature({"AndroidWebView"}) |
| 336 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
318 public void testPowerSaveBlockerIsEnabledDuringFullscreenPlayback_videoInsid
eDiv() | 337 public void testPowerSaveBlockerIsEnabledDuringFullscreenPlayback_videoInsid
eDiv() |
319 throws Throwable { | 338 throws Throwable { |
320 doTestPowerSaveBlockerIsEnabledDuringFullscreenPlayback(VIDEO_INSIDE_DIV
_TEST_URL); | 339 doTestPowerSaveBlockerIsEnabledDuringFullscreenPlayback(VIDEO_INSIDE_DIV
_TEST_URL); |
321 } | 340 } |
322 | 341 |
323 public void doTestPowerSaveBlockerIsEnabledDuringFullscreenPlayback(String v
ideoTestUrl) | 342 public void doTestPowerSaveBlockerIsEnabledDuringFullscreenPlayback(String v
ideoTestUrl) |
324 throws Throwable { | 343 throws Throwable { |
325 // Enter fullscreen. | 344 // Enter fullscreen. |
326 doOnShowCustomViewTest(videoTestUrl); | 345 doOnShowCustomViewTest(videoTestUrl); |
327 View customView = mContentsClient.getCustomView(); | 346 View customView = mContentsClient.getCustomView(); |
328 | 347 |
329 // No power save blocker is active before playback starts. | 348 // No power save blocker is active before playback starts. |
330 assertKeepScreenOnActive(customView, false); | 349 assertKeepScreenOnActive(customView, false); |
331 | 350 |
332 // Play and verify that there is an active power save blocker. | 351 // Play and verify that there is an active power save blocker. |
333 tapPlayButton(); | 352 tapPlayButton(); |
334 assertWaitForKeepScreenOnActive(customView, true); | 353 assertWaitForKeepScreenOnActive(customView, true); |
335 | 354 |
336 // Stop the video and verify that the power save blocker is gone. | 355 // Stop the video and verify that the power save blocker is gone. |
337 DOMUtils.pauseMedia(getWebContentsOnUiThread(), VIDEO_ID); | 356 DOMUtils.pauseMedia(getWebContentsOnUiThread(), VIDEO_ID); |
338 assertWaitForKeepScreenOnActive(customView, false); | 357 assertWaitForKeepScreenOnActive(customView, false); |
339 } | 358 } |
340 | 359 |
341 @MediumTest | 360 @MediumTest |
342 @Feature({"AndroidWebView"}) | 361 @Feature({"AndroidWebView"}) |
| 362 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
343 public void testPowerSaveBlockerIsEnabledDuringEmbeddedPlayback() | 363 public void testPowerSaveBlockerIsEnabledDuringEmbeddedPlayback() |
344 throws Throwable { | 364 throws Throwable { |
345 assertFalse(DOMUtils.isFullscreen(getWebContentsOnUiThread())); | 365 assertFalse(DOMUtils.isFullscreen(getWebContentsOnUiThread())); |
346 loadTestPage(VIDEO_INSIDE_DIV_TEST_URL); | 366 loadTestPage(VIDEO_INSIDE_DIV_TEST_URL); |
347 | 367 |
348 // No power save blocker is active before playback starts. | 368 // No power save blocker is active before playback starts. |
349 assertKeepScreenOnActive(mTestContainerView, false); | 369 assertKeepScreenOnActive(mTestContainerView, false); |
350 | 370 |
351 // Play and verify that there is an active power save blocker. | 371 // Play and verify that there is an active power save blocker. |
352 tapPlayButton(); | 372 tapPlayButton(); |
353 assertWaitForKeepScreenOnActive(mTestContainerView, true); | 373 assertWaitForKeepScreenOnActive(mTestContainerView, true); |
354 | 374 |
355 // Stop the video and verify that the power save blocker is gone. | 375 // Stop the video and verify that the power save blocker is gone. |
356 DOMUtils.pauseMedia(getWebContentsOnUiThread(), VIDEO_ID); | 376 DOMUtils.pauseMedia(getWebContentsOnUiThread(), VIDEO_ID); |
357 assertWaitForKeepScreenOnActive(mTestContainerView, false); | 377 assertWaitForKeepScreenOnActive(mTestContainerView, false); |
358 } | 378 } |
359 | 379 |
360 @MediumTest | 380 @MediumTest |
361 @Feature({"AndroidWebView"}) | 381 @Feature({"AndroidWebView"}) |
| 382 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
362 public void testPowerSaveBlockerIsTransferredToFullscreen() | 383 public void testPowerSaveBlockerIsTransferredToFullscreen() |
363 throws Throwable { | 384 throws Throwable { |
364 assertFalse(DOMUtils.isFullscreen(getWebContentsOnUiThread())); | 385 assertFalse(DOMUtils.isFullscreen(getWebContentsOnUiThread())); |
365 loadTestPage(VIDEO_INSIDE_DIV_TEST_URL); | 386 loadTestPage(VIDEO_INSIDE_DIV_TEST_URL); |
366 | 387 |
367 // Play and verify that there is an active power save blocker. | 388 // Play and verify that there is an active power save blocker. |
368 tapPlayButton(); | 389 tapPlayButton(); |
369 assertWaitForKeepScreenOnActive(mTestContainerView, true); | 390 assertWaitForKeepScreenOnActive(mTestContainerView, true); |
370 | 391 |
371 // Enter fullscreen and verify that the power save blocker is | 392 // Enter fullscreen and verify that the power save blocker is |
372 // still there. | 393 // still there. |
373 DOMUtils.clickNode(this, mContentViewCore, CUSTOM_FULLSCREEN_CONTROL_ID)
; | 394 DOMUtils.clickNode(this, mContentViewCore, CUSTOM_FULLSCREEN_CONTROL_ID)
; |
374 mContentsClient.waitForCustomViewShown(); | 395 mContentsClient.waitForCustomViewShown(); |
375 View customView = mContentsClient.getCustomView(); | 396 View customView = mContentsClient.getCustomView(); |
376 assertKeepScreenOnActive(customView, true); | 397 assertKeepScreenOnActive(customView, true); |
377 | 398 |
378 // Pause the video and the power save blocker is gone. | 399 // Pause the video and the power save blocker is gone. |
379 DOMUtils.pauseMedia(getWebContentsOnUiThread(), VIDEO_ID); | 400 DOMUtils.pauseMedia(getWebContentsOnUiThread(), VIDEO_ID); |
380 assertWaitForKeepScreenOnActive(customView, false); | 401 assertWaitForKeepScreenOnActive(customView, false); |
381 | 402 |
382 // Exit fullscreen and the power save blocker is still gone. | 403 // Exit fullscreen and the power save blocker is still gone. |
383 DOMUtils.exitFullscreen(getWebContentsOnUiThread()); | 404 DOMUtils.exitFullscreen(getWebContentsOnUiThread()); |
384 mContentsClient.waitForCustomViewHidden(); | 405 mContentsClient.waitForCustomViewHidden(); |
385 assertKeepScreenOnActive(mTestContainerView, false); | 406 assertKeepScreenOnActive(mTestContainerView, false); |
386 } | 407 } |
387 | 408 |
388 @MediumTest | 409 @MediumTest |
389 @Feature({"AndroidWebView"}) | 410 @Feature({"AndroidWebView"}) |
| 411 @DisableIf.Build(sdk_is_greater_than = 22, message = "crbug.com/615483,61518
4") |
390 public void testPowerSaveBlockerIsTransferredToEmbedded() | 412 public void testPowerSaveBlockerIsTransferredToEmbedded() |
391 throws Throwable { | 413 throws Throwable { |
392 // Enter fullscreen. | 414 // Enter fullscreen. |
393 doOnShowCustomViewTest(VIDEO_INSIDE_DIV_TEST_URL); | 415 doOnShowCustomViewTest(VIDEO_INSIDE_DIV_TEST_URL); |
394 View customView = mContentsClient.getCustomView(); | 416 View customView = mContentsClient.getCustomView(); |
395 | 417 |
396 // Play and verify that there is an active power save blocker | 418 // Play and verify that there is an active power save blocker |
397 // in fullscreen. | 419 // in fullscreen. |
398 tapPlayButton(); | 420 tapPlayButton(); |
399 assertWaitForKeepScreenOnActive(customView, true); | 421 assertWaitForKeepScreenOnActive(customView, true); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 public WebContents call() throws Exception { | 585 public WebContents call() throws Exception { |
564 return mContentViewCore.getWebContents(); | 586 return mContentViewCore.getWebContents(); |
565 } | 587 } |
566 }); | 588 }); |
567 } catch (Exception e) { | 589 } catch (Exception e) { |
568 fail(e.getMessage()); | 590 fail(e.getMessage()); |
569 return null; | 591 return null; |
570 } | 592 } |
571 } | 593 } |
572 } | 594 } |
OLD | NEW |