Chromium Code Reviews| 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.DisabledTest; | |
| 14 import org.chromium.base.test.util.Feature; | 15 import org.chromium.base.test.util.Feature; |
| 15 import org.chromium.base.test.util.FlakyTest; | 16 import org.chromium.base.test.util.FlakyTest; |
| 16 import org.chromium.base.test.util.parameter.ParameterizedTest; | 17 import org.chromium.base.test.util.parameter.ParameterizedTest; |
| 17 import org.chromium.content.browser.ContentViewCore; | 18 import org.chromium.content.browser.ContentViewCore; |
| 18 import org.chromium.content.browser.test.util.Criteria; | 19 import org.chromium.content.browser.test.util.Criteria; |
| 19 import org.chromium.content.browser.test.util.CriteriaHelper; | 20 import org.chromium.content.browser.test.util.CriteriaHelper; |
| 20 import org.chromium.content.browser.test.util.DOMUtils; | 21 import org.chromium.content.browser.test.util.DOMUtils; |
| 21 import org.chromium.content.browser.test.util.TouchCommon; | 22 import org.chromium.content.browser.test.util.TouchCommon; |
| 22 import org.chromium.content_public.browser.WebContents; | 23 import org.chromium.content_public.browser.WebContents; |
| 23 | 24 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 | 208 |
| 208 // Play and verify that a surface view for hole punching is not created. | 209 // Play and verify that a surface view for hole punching is not created. |
| 209 // Note that VIDEO_TEST_URL contains clear video. | 210 // Note that VIDEO_TEST_URL contains clear video. |
| 210 tapPlayButton(); | 211 tapPlayButton(); |
| 211 DOMUtils.waitForMediaPlay(getWebContentsOnUiThread(), VIDEO_ID); | 212 DOMUtils.waitForMediaPlay(getWebContentsOnUiThread(), VIDEO_ID); |
| 212 // Wait to ensure that the surface view is not added asynchronously. | 213 // Wait to ensure that the surface view is not added asynchronously. |
| 213 VideoSurfaceViewUtils.waitAndAssertContainsZeroVideoHoleSurfaceViews(thi s, | 214 VideoSurfaceViewUtils.waitAndAssertContainsZeroVideoHoleSurfaceViews(thi s, |
| 214 mTestContainerView); | 215 mTestContainerView); |
| 215 } | 216 } |
| 216 | 217 |
| 218 /* | |
| 217 @MediumTest | 219 @MediumTest |
| 218 @Feature({"AndroidWebView"}) | 220 @Feature({"AndroidWebView"}) |
| 221 crbug.com/597495 | |
| 222 */ | |
| 223 @DisabledTest | |
| 219 public void testOnShowCustomViewTransfersHolePunchingSurfaceForVideoInsideDi v() | 224 public void testOnShowCustomViewTransfersHolePunchingSurfaceForVideoInsideDi v() |
| 220 throws Throwable { | 225 throws Throwable { |
| 221 getInstrumentation().runOnMainSync(new Runnable() { | 226 getInstrumentation().runOnMainSync(new Runnable() { |
| 222 @Override | 227 @Override |
| 223 public void run() { | 228 public void run() { |
| 224 mTestContainerView.getAwContents().getSettings().setForceVideoOv erlayForTests(true); | 229 mTestContainerView.getAwContents().getSettings().setForceVideoOv erlayForTests(true); |
| 225 } | 230 } |
| 226 }); | 231 }); |
| 227 | 232 |
| 228 loadTestPage(VIDEO_INSIDE_DIV_TEST_URL); | 233 loadTestPage(VIDEO_INSIDE_DIV_TEST_URL); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 241 // new container view. | 246 // new container view. |
| 242 DOMUtils.clickNode(this, mContentViewCore, CUSTOM_FULLSCREEN_CONTROL_ID) ; | 247 DOMUtils.clickNode(this, mContentViewCore, CUSTOM_FULLSCREEN_CONTROL_ID) ; |
| 243 mContentsClient.waitForCustomViewShown(); | 248 mContentsClient.waitForCustomViewShown(); |
| 244 View customView = mContentsClient.getCustomView(); | 249 View customView = mContentsClient.getCustomView(); |
| 245 VideoSurfaceViewUtils.assertContainsZeroVideoHoleSurfaceViews(this, mTes tContainerView); | 250 VideoSurfaceViewUtils.assertContainsZeroVideoHoleSurfaceViews(this, mTes tContainerView); |
| 246 // Wait to ensure that the surface view stays there after being transfer ed and not | 251 // Wait to ensure that the surface view stays there after being transfer ed and not |
| 247 // removed asynchronously. | 252 // removed asynchronously. |
| 248 VideoSurfaceViewUtils.waitAndAssertContainsOneVideoHoleSurfaceView(this, customView); | 253 VideoSurfaceViewUtils.waitAndAssertContainsOneVideoHoleSurfaceView(this, customView); |
| 249 } | 254 } |
| 250 | 255 |
| 256 /* | |
| 251 @MediumTest | 257 @MediumTest |
| 252 @Feature({"AndroidWebView"}) | 258 @Feature({"AndroidWebView"}) |
| 253 @FlakyTest | 259 @FlakyTest |
| 254 public void testOnShowCustomViewRemovesHolePunchingSurfaceForVideo() | 260 crbug.com/597495 |
| 255 throws Throwable { | 261 */ |
| 262 @DisabledTest | |
| 263 public void testOnShowCustomViewRemovesHolePunchingSurfaceForVideo() throws Throwable { | |
| 256 getInstrumentation().runOnMainSync(new Runnable() { | 264 getInstrumentation().runOnMainSync(new Runnable() { |
| 257 @Override | 265 @Override |
| 258 public void run() { | 266 public void run() { |
| 259 mTestContainerView.getAwContents().getSettings().setForceVideoOv erlayForTests(true); | 267 mTestContainerView.getAwContents().getSettings().setForceVideoOv erlayForTests(true); |
| 260 } | 268 } |
| 261 }); | 269 }); |
| 262 | 270 |
| 263 loadTestPage(VIDEO_TEST_URL); | 271 loadTestPage(VIDEO_TEST_URL); |
| 264 assertFalse(DOMUtils.isFullscreen(getWebContentsOnUiThread())); | 272 assertFalse(DOMUtils.isFullscreen(getWebContentsOnUiThread())); |
| 265 | 273 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 return !DOMUtils.isFullscreen(getWebContentsOnUiThread()); | 514 return !DOMUtils.isFullscreen(getWebContentsOnUiThread()); |
| 507 } catch (InterruptedException | TimeoutException e) { | 515 } catch (InterruptedException | TimeoutException e) { |
| 508 fail(e.getMessage()); | 516 fail(e.getMessage()); |
| 509 return false; | 517 return false; |
| 510 } | 518 } |
| 511 } | 519 } |
| 512 }); | 520 }); |
| 513 // TODO: Test that inline video is actually displayed. | 521 // TODO: Test that inline video is actually displayed. |
| 514 } | 522 } |
| 515 | 523 |
| 516 private void assertContainsContentVideoView() throws Exception { | 524 private void assertContainsContentVideoView() throws Exception { |
|
boliu
2016/06/02 20:28:38
remove this and assertContainsOneContentVideoView
| |
| 517 VideoSurfaceViewUtils.assertContainsOneContentVideoView(this, | 525 VideoSurfaceViewUtils.assertContainsOneContentVideoView(this, |
| 518 mContentsClient.getCustomView()); | 526 mContentsClient.getCustomView()); |
| 519 } | 527 } |
| 520 | 528 |
| 521 private JavascriptEventObserver registerObserver(final String observerName) throws Throwable { | 529 private JavascriptEventObserver registerObserver(final String observerName) throws Throwable { |
| 522 final JavascriptEventObserver observer = new JavascriptEventObserver(); | 530 final JavascriptEventObserver observer = new JavascriptEventObserver(); |
| 523 runTestOnUiThread(new Runnable() { | 531 runTestOnUiThread(new Runnable() { |
| 524 @Override | 532 @Override |
| 525 public void run() { | 533 public void run() { |
| 526 observer.register(mContentViewCore, observerName); | 534 observer.register(mContentViewCore, observerName); |
| 527 } | 535 } |
| 528 }); | 536 }); |
| 529 return observer; | 537 return observer; |
| 530 } | 538 } |
| 531 | 539 |
| 532 private void doOnShowAndHideCustomViewTest(String videoTestUrl, final Runnab le existFullscreen) | 540 private void doOnShowAndHideCustomViewTest(String videoTestUrl, final Runnab le existFullscreen) |
| 533 throws Throwable { | 541 throws Throwable { |
| 534 doOnShowCustomViewTest(videoTestUrl); | 542 doOnShowCustomViewTest(videoTestUrl); |
| 535 runTestOnUiThread(existFullscreen); | 543 runTestOnUiThread(existFullscreen); |
| 536 mContentsClient.waitForCustomViewHidden(); | 544 mContentsClient.waitForCustomViewHidden(); |
| 537 assertWaitForIsEmbedded(); | 545 assertWaitForIsEmbedded(); |
| 538 } | 546 } |
| 539 | 547 |
| 540 private void doOnShowCustomViewTest(String videoTestUrl) throws Exception { | 548 private void doOnShowCustomViewTest(String videoTestUrl) throws Exception { |
| 541 loadTestPageAndClickFullscreen(videoTestUrl); | 549 loadTestPageAndClickFullscreen(videoTestUrl); |
| 542 mContentsClient.waitForCustomViewShown(); | 550 mContentsClient.waitForCustomViewShown(); |
| 543 assertWaitForIsFullscreen(); | 551 assertWaitForIsFullscreen(); |
| 544 if (videoTestUrl.equals(VIDEO_TEST_URL)) { | |
| 545 // We only create a ContentVideoView (ie. a hardware accelerated sur face) when going | |
| 546 // fullscreen on a video element. | |
| 547 assertContainsContentVideoView(); | |
| 548 } | |
| 549 } | 552 } |
| 550 | 553 |
| 551 private void loadTestPageAndClickFullscreen(String videoTestUrl) throws Exce ption { | 554 private void loadTestPageAndClickFullscreen(String videoTestUrl) throws Exce ption { |
| 552 loadTestPage(videoTestUrl); | 555 loadTestPage(videoTestUrl); |
| 553 DOMUtils.clickNode(this, mContentViewCore, CUSTOM_FULLSCREEN_CONTROL_ID) ; | 556 DOMUtils.clickNode(this, mContentViewCore, CUSTOM_FULLSCREEN_CONTROL_ID) ; |
| 554 } | 557 } |
| 555 | 558 |
| 556 private void loadTestPage(String videoTestUrl) throws Exception { | 559 private void loadTestPage(String videoTestUrl) throws Exception { |
| 557 loadUrlSync(mTestContainerView.getAwContents(), | 560 loadUrlSync(mTestContainerView.getAwContents(), |
| 558 mContentsClient.getOnPageFinishedHelper(), videoTestUrl); | 561 mContentsClient.getOnPageFinishedHelper(), videoTestUrl); |
| 559 // As we are loading a non-trivial page, let's wait until we have someth ing displayed. | 562 // As we are loading a non-trivial page, let's wait until we have someth ing displayed. |
| 560 waitForVisualStateCallback(mTestContainerView.getAwContents()); | 563 waitForVisualStateCallback(mTestContainerView.getAwContents()); |
| 561 } | 564 } |
| 562 | 565 |
| 563 private WebContents getWebContentsOnUiThread() { | 566 private WebContents getWebContentsOnUiThread() { |
| 564 try { | 567 try { |
| 565 return runTestOnUiThreadAndGetResult(new Callable<WebContents>() { | 568 return runTestOnUiThreadAndGetResult(new Callable<WebContents>() { |
| 566 @Override | 569 @Override |
| 567 public WebContents call() throws Exception { | 570 public WebContents call() throws Exception { |
| 568 return mContentViewCore.getWebContents(); | 571 return mContentViewCore.getWebContents(); |
| 569 } | 572 } |
| 570 }); | 573 }); |
| 571 } catch (Exception e) { | 574 } catch (Exception e) { |
| 572 fail(e.getMessage()); | 575 fail(e.getMessage()); |
| 573 return null; | 576 return null; |
| 574 } | 577 } |
| 575 } | 578 } |
| 576 } | 579 } |
| OLD | NEW |