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

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

Issue 425343002: [Android WebView] API to enable fullscreen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
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 10
11 import junit.framework.Assert; 11 import junit.framework.Assert;
12 12
13 import org.chromium.android_webview.test.util.JavascriptEventObserver;
13 import org.chromium.android_webview.test.util.VideoTestWebServer; 14 import org.chromium.android_webview.test.util.VideoTestWebServer;
14 import org.chromium.base.CommandLine; 15 import org.chromium.base.CommandLine;
15 import org.chromium.base.test.util.Feature; 16 import org.chromium.base.test.util.Feature;
16 import org.chromium.content.browser.ContentViewCore; 17 import org.chromium.content.browser.ContentViewCore;
17 import org.chromium.content.browser.test.util.DOMUtils; 18 import org.chromium.content.browser.test.util.DOMUtils;
18 import org.chromium.content.browser.test.util.TouchCommon; 19 import org.chromium.content.browser.test.util.TouchCommon;
19 import org.chromium.content.common.ContentSwitches; 20 import org.chromium.content.common.ContentSwitches;
20 21
21 /** 22 /**
22 * Test WebChromeClient::onShow/HideCustomView. 23 * Test WebChromeClient::onShow/HideCustomView.
23 */ 24 */
24 public class AwContentsClientFullScreenVideoTest extends AwTestBase { 25 public class AwContentsClientFullScreenVideoTest extends AwTestBase {
25 private FullScreenVideoTestAwContentsClient mContentsClient; 26 private FullScreenVideoTestAwContentsClient mContentsClient;
26 private ContentViewCore mContentViewCore; 27 private ContentViewCore mContentViewCore;
27 private VideoTestWebServer webServer; 28 private VideoTestWebServer webServer;
28 private AwTestContainerView testContainerView; 29 private AwTestContainerView testContainerView;
29 30
30 @Override 31 @Override
31 protected void setUp() throws Exception { 32 protected void setUp() throws Exception {
32 super.setUp(); 33 super.setUp();
33 mContentsClient = new FullScreenVideoTestAwContentsClient(getActivity()) ; 34 mContentsClient = new FullScreenVideoTestAwContentsClient(getActivity()) ;
34 testContainerView = 35 testContainerView =
35 createAwTestContainerViewOnMainSync(mContentsClient); 36 createAwTestContainerViewOnMainSync(mContentsClient);
36 mContentViewCore = testContainerView.getContentViewCore(); 37 mContentViewCore = testContainerView.getContentViewCore();
37 enableJavaScriptOnUiThread(testContainerView.getAwContents()); 38 enableJavaScriptOnUiThread(testContainerView.getAwContents());
39 testContainerView.getAwContents().setFullScreenEnabled(true);
38 webServer = new VideoTestWebServer( 40 webServer = new VideoTestWebServer(
39 getInstrumentation().getTargetContext()); 41 getInstrumentation().getTargetContext());
40 } 42 }
41 43
42 @Override 44 @Override
43 protected void tearDown() throws Exception { 45 protected void tearDown() throws Exception {
44 super.tearDown(); 46 super.tearDown();
45 if (webServer != null) webServer.getTestWebServer().shutdown(); 47 if (webServer != null) webServer.getTestWebServer().shutdown();
46 } 48 }
47 49
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // control since it is a shadow element, so this test might break if the location 104 // control since it is a shadow element, so this test might break if the location
103 // ever moves. 105 // ever moves.
104 TouchCommon touchCommon = new TouchCommon( 106 TouchCommon touchCommon = new TouchCommon(
105 AwContentsClientFullScreenVideoTest.this); 107 AwContentsClientFullScreenVideoTest.this);
106 touchCommon.singleClickView(mContentsClient.getCustomView()); 108 touchCommon.singleClickView(mContentsClient.getCustomView());
107 109
108 Assert.assertTrue(DOMUtils.waitForEndOfVideo( 110 Assert.assertTrue(DOMUtils.waitForEndOfVideo(
109 mContentViewCore, VideoTestWebServer.VIDEO_ID)); 111 mContentViewCore, VideoTestWebServer.VIDEO_ID));
110 } 112 }
111 113
114 @MediumTest
115 @Feature({"AndroidWebView"})
116 public void testFullscreenNotEnabled() throws Throwable {
117 testContainerView.getAwContents().setFullScreenEnabled(false);
118
119 final JavascriptEventObserver fullScreenErrorObserver = new JavascriptEv entObserver();
120 getInstrumentation().runOnMainSync(new Runnable() {
121 @Override
122 public void run() {
123 fullScreenErrorObserver.register(mContentViewCore, "javaFullScre enErrorObserver");
124 }
125 });
126
127 loadTestPageAndClickFullscreen();
128
129 Assert.assertTrue(fullScreenErrorObserver.waitForEvent(500));
130 Assert.assertFalse(mContentsClient.wasCustonViewShownCalled());
131 }
132
112 private static boolean areHtmlControlsEnabled() { 133 private static boolean areHtmlControlsEnabled() {
113 return !CommandLine.getInstance().hasSwitch( 134 return !CommandLine.getInstance().hasSwitch(
114 ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE); 135 ContentSwitches.DISABLE_OVERLAY_FULLSCREEN_VIDEO_SUBTITLE);
115 } 136 }
116 137
117 private void doOnShowAndHideCustomViewTest(final Runnable existFullscreen) 138 private void doOnShowAndHideCustomViewTest(final Runnable existFullscreen)
118 throws Throwable { 139 throws Throwable {
119 doOnShowCustomViewTest(); 140 doOnShowCustomViewTest();
120 getInstrumentation().runOnMainSync(existFullscreen); 141 getInstrumentation().runOnMainSync(existFullscreen);
121 mContentsClient.waitForCustomViewHidden(); 142 mContentsClient.waitForCustomViewHidden();
122 } 143 }
123 144
124 private void doOnShowCustomViewTest() throws Exception { 145 private void doOnShowCustomViewTest() throws Exception {
146 loadTestPageAndClickFullscreen();
147 mContentsClient.waitForCustomViewShown();
148 }
149
150 private void loadTestPageAndClickFullscreen() throws Exception {
125 loadUrlSync(testContainerView.getAwContents(), 151 loadUrlSync(testContainerView.getAwContents(),
126 mContentsClient.getOnPageFinishedHelper(), 152 mContentsClient.getOnPageFinishedHelper(),
127 webServer.getFullScreenVideoTestURL()); 153 webServer.getFullScreenVideoTestURL());
128 154
129 // Click the button in full_screen_video_test.html to enter fullscreen. 155 // Click the button in full_screen_video_test.html to enter fullscreen.
130 TouchCommon touchCommon = new TouchCommon(this); 156 TouchCommon touchCommon = new TouchCommon(this);
131 touchCommon.singleClickView(testContainerView); 157 touchCommon.singleClickView(testContainerView);
132 mContentsClient.waitForCustomViewShown();
133 } 158 }
134 } 159 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698