This source file includes following definitions.
- onViewAttachedToWindow
- onViewDetachedFromWindow
- waitForViewAttached
- Feature
- testGetVideoLoadingProgressView
package org.chromium.android_webview.test;
import android.test.suitebuilder.annotation.SmallTest;
import android.view.View;
import org.chromium.android_webview.AwContents;
import org.chromium.android_webview.test.util.VideoTestWebServer;
import org.chromium.base.test.util.Feature;
import org.chromium.content.browser.test.util.CallbackHelper;
import org.chromium.content.browser.test.util.TouchCommon;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class AwContentsClientGetVideoLoadingProgressViewTest extends AwTestBase
implements View.OnAttachStateChangeListener {
private CallbackHelper mViewAttachedCallbackHelper = new CallbackHelper();
@Override
public void onViewAttachedToWindow(View view) {
mViewAttachedCallbackHelper.notifyCalled();
view.removeOnAttachStateChangeListener(this);
}
@Override
public void onViewDetachedFromWindow(View arg0) {
}
private void waitForViewAttached() throws InterruptedException, TimeoutException {
mViewAttachedCallbackHelper.waitForCallback(0, 1, WAIT_TIMEOUT_MS,
TimeUnit.MILLISECONDS);
}
@Feature({"AndroidWebView"})
@SmallTest
public void testGetVideoLoadingProgressView() throws Throwable {
TestAwContentsClient contentsClient =
new FullScreenVideoTestAwContentsClient(getActivity()) {
@Override
protected View getVideoLoadingProgressView() {
View view = new View(getInstrumentation().getTargetContext());
view.addOnAttachStateChangeListener(
AwContentsClientGetVideoLoadingProgressViewTest.this);
return view;
}
};
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
final AwContents awContents = testContainerView.getAwContents();
enableJavaScriptOnUiThread(awContents);
VideoTestWebServer webServer = new VideoTestWebServer(
getInstrumentation().getTargetContext());
try {
loadUrlSync(awContents, contentsClient.getOnPageFinishedHelper(),
webServer.getFullScreenVideoTestURL());
Thread.sleep(5 * 1000);
TouchCommon touchCommon = new TouchCommon(this);
touchCommon.singleClickView(testContainerView);
waitForViewAttached();
} finally {
if (webServer != null) webServer.getTestWebServer().shutdown();
}
}
}