1// Copyright 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5package org.chromium.android_webview.test; 6 7import org.chromium.android_webview.AwContents; 8import org.chromium.base.test.util.DisabledTest; 9import org.chromium.base.test.util.UrlUtils; 10import org.chromium.content.browser.test.util.HistoryUtils; 11import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper; 12import org.chromium.content_public.browser.WebContents; 13 14/** 15 * Tests for a wanted clearHistory method. 16 */ 17public class ClearHistoryTest extends AwTestBase { 18 19 private static final String[] URLS = new String[3]; 20 { 21 for (int i = 0; i < URLS.length; i++) { 22 URLS[i] = UrlUtils.encodeHtmlDataUri( 23 "<html><head></head><body>" + i + "</body></html>"); 24 } 25 } 26 27 /* 28 @SmallTest 29 @Feature({"History", "Main"}) 30 This test is only failing on JellyBean bots. 31 See crbug.com/178762. 32 */ 33 @DisabledTest 34 public void testClearHistory() throws Throwable { 35 final TestAwContentsClient contentsClient = new TestAwContentsClient(); 36 final AwTestContainerView testContainerView = 37 createAwTestContainerViewOnMainSync(contentsClient); 38 final AwContents awContents = testContainerView.getAwContents(); 39 final WebContents webContents = awContents.getWebContents(); 40 OnPageFinishedHelper onPageFinishedHelper = contentsClient.getOnPageFinishedHelper(); 41 for (int i = 0; i < 3; i++) { 42 loadUrlSync(awContents, onPageFinishedHelper, URLS[i]); 43 } 44 45 HistoryUtils.goBackSync(getInstrumentation(), webContents, onPageFinishedHelper); 46 assertTrue("Should be able to go back", 47 HistoryUtils.canGoBackOnUiThread(getInstrumentation(), webContents)); 48 assertTrue("Should be able to go forward", 49 HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), webContents)); 50 51 HistoryUtils.clearHistoryOnUiThread(getInstrumentation(), webContents); 52 assertFalse("Should not be able to go back", 53 HistoryUtils.canGoBackOnUiThread(getInstrumentation(), webContents)); 54 assertFalse("Should not be able to go forward", 55 HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), webContents)); 56 } 57} 58