This source file includes following definitions.
- onShowCustomView
- onHideCustomView
- waitForCustomViewShown
- waitForCustomViewHidden
package org.chromium.android_webview.test;
import android.app.Activity;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebChromeClient;
import android.widget.FrameLayout;
import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
import org.chromium.content.browser.test.util.CallbackHelper;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class FullScreenVideoTestAwContentsClient extends TestAwContentsClient {
public static final long WAITING_SECONDS = scaleTimeout(20);
private CallbackHelper mOnShowCustomViewCallbackHelper = new CallbackHelper();
private CallbackHelper mOnHideCustomViewCallbackHelper = new CallbackHelper();
private Activity mActivity;
public FullScreenVideoTestAwContentsClient(Activity activity) {
mActivity = activity;
}
@Override
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {
mActivity.getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
mActivity.getWindow().addContentView(view,
new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT,
Gravity.CENTER));
mOnShowCustomViewCallbackHelper.notifyCalled();
}
@Override
public void onHideCustomView() {
mActivity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
mOnHideCustomViewCallbackHelper.notifyCalled();
}
public void waitForCustomViewShown() throws TimeoutException, InterruptedException {
mOnShowCustomViewCallbackHelper.waitForCallback(0, 1, WAITING_SECONDS, TimeUnit.SECONDS);
}
public void waitForCustomViewHidden() throws InterruptedException, TimeoutException {
mOnHideCustomViewCallbackHelper.waitForCallback(0, 1, WAITING_SECONDS, TimeUnit.SECONDS);
}
}