This source file includes following definitions.
- testClearHistory
package org.chromium.android_webview.test;
import org.chromium.android_webview.AwContents;
import org.chromium.base.test.util.DisabledTest;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.ContentViewCore;
import org.chromium.content.browser.test.util.HistoryUtils;
import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper;
public class ClearHistoryTest extends AwTestBase {
private static final String[] URLS = new String[3];
{
for (int i = 0; i < URLS.length; i++) {
URLS[i] = UrlUtils.encodeHtmlDataUri(
"<html><head></head><body>" + i + "</body></html>");
}
}
@DisabledTest
public void testClearHistory() throws Throwable {
final TestAwContentsClient contentsClient = new TestAwContentsClient();
final AwTestContainerView testContainerView =
createAwTestContainerViewOnMainSync(contentsClient);
final AwContents awContents = testContainerView.getAwContents();
final ContentViewCore contentViewCore = testContainerView.getContentViewCore();
OnPageFinishedHelper onPageFinishedHelper = contentsClient.getOnPageFinishedHelper();
for (int i = 0; i < 3; i++) {
loadUrlSync(awContents, onPageFinishedHelper, URLS[i]);
}
HistoryUtils.goBackSync(getInstrumentation(), contentViewCore, onPageFinishedHelper);
assertTrue("Should be able to go back",
HistoryUtils.canGoBackOnUiThread(getInstrumentation(), contentViewCore));
assertTrue("Should be able to go forward",
HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), contentViewCore));
HistoryUtils.clearHistoryOnUiThread(getInstrumentation(), contentViewCore);
assertFalse("Should not be able to go back",
HistoryUtils.canGoBackOnUiThread(getInstrumentation(), contentViewCore));
assertFalse("Should not be able to go forward",
HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), contentViewCore));
}
}