This source file includes following definitions.
- getTestCallbackHelperContainer
- urlForContent
- isCurrentTestUrl
- scrollAndTapExpectingIntent
- scrollAndTapNavigatingOut
package org.chromium.content.browser;
import android.net.Uri;
import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnStartContentIntentHelper;
import org.chromium.content_shell_apk.ContentShellTestBase;
import java.util.concurrent.TimeUnit;
public class ContentDetectionTestBase extends ContentShellTestBase {
private static final long WAIT_TIMEOUT_SECONDS = scaleTimeout(10);
private TestCallbackHelperContainer mCallbackHelper;
protected TestCallbackHelperContainer getTestCallbackHelperContainer() {
if (mCallbackHelper == null) {
mCallbackHelper = new TestCallbackHelperContainer(getContentView());
}
return mCallbackHelper;
}
protected String urlForContent(String content) {
return Uri.encode(content).replaceAll("%20", "+");
}
protected boolean isCurrentTestUrl(String testUrl) {
return UrlUtils.getTestFileUrl(testUrl).equals(getContentView().getUrl());
}
protected String scrollAndTapExpectingIntent(String id) throws Throwable {
TestCallbackHelperContainer callbackHelperContainer = getTestCallbackHelperContainer();
OnStartContentIntentHelper onStartContentIntentHelper =
callbackHelperContainer.getOnStartContentIntentHelper();
int currentCallCount = onStartContentIntentHelper.getCallCount();
DOMUtils.scrollNodeIntoView(getContentView(), callbackHelperContainer, id);
DOMUtils.clickNode(this, getContentView(), callbackHelperContainer, id);
onStartContentIntentHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_SECONDS,
TimeUnit.SECONDS);
getInstrumentation().waitForIdleSync();
return onStartContentIntentHelper.getIntentUrl();
}
protected void scrollAndTapNavigatingOut(String id) throws Throwable {
TestCallbackHelperContainer callbackHelperContainer = getTestCallbackHelperContainer();
OnPageFinishedHelper onPageFinishedHelper =
callbackHelperContainer.getOnPageFinishedHelper();
int currentCallCount = onPageFinishedHelper.getCallCount();
DOMUtils.scrollNodeIntoView(getContentView(), callbackHelperContainer, id);
DOMUtils.clickNode(this, getContentView(), callbackHelperContainer, id);
onPageFinishedHelper.waitForCallback(currentCallCount, 1, WAIT_TIMEOUT_SECONDS,
TimeUnit.SECONDS);
getInstrumentation().waitForIdleSync();
}
}