| 1 | // Copyright (c) 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 | |
| 5 | package org.chromium.android_webview.test; |
| 6 | |
| 7 | import android.test.suitebuilder.annotation.SmallTest; |
| 8 | |
| 9 | import org.chromium.android_webview.AwContents; |
| 10 | import org.chromium.base.test.util.DisabledTest; |
| 11 | import org.chromium.base.test.util.Feature; |
| 12 | import org.chromium.base.test.util.UrlUtils; |
| 13 | import org.chromium.content.browser.ContentViewCore; |
| 14 | import org.chromium.content.browser.test.util.HistoryUtils; |
| 15 | import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPageFinishedHelper; |
| 16 | |
| 17 | /** |
| 18 | * Tests for a wanted clearHistory method. |
| 19 | */ |
| 20 | public class ClearHistoryTest extends AwTestBase { |
| 21 | |
| 22 | private static final String[] URLS = new String[3]; |
| 23 | { |
| 24 | for (int i = 0; i < URLS.length; i++) { |
| 25 | URLS[i] = UrlUtils.encodeHtmlDataUri( |
| 26 | "<html><head></head><body>" + i + "</body></html>"); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | /* |
| 31 | @SmallTest |
| 32 | @Feature({"History", "Main"}) |
| 33 | This test is only failing on JellyBean bots. |
| 34 | See crbug.com/178762. |
| 35 | */ |
| 36 | @DisabledTest |
| 37 | public void testClearHistory() throws Throwable { |
| 38 | final TestAwContentsClient contentsClient = new TestAwContentsClient(); |
| 39 | final AwTestContainerView testContainerView = |
| 40 | createAwTestContainerViewOnMainSync(contentsClient); |
| 41 | final AwContents awContents = testContainerView.getAwContents(); |
| 42 | final ContentViewCore contentViewCore = testContainerView.getContentViewCore(); |
| 43 | |
| 44 | OnPageFinishedHelper onPageFinishedHelper = contentsClient.getOnPageFinishedHelper(); |
| 45 | for (int i = 0; i < 3; i++) { |
| 46 | loadUrlSync(awContents, onPageFinishedHelper, URLS[i]); |
| 47 | } |
| 48 | |
| 49 | HistoryUtils.goBackSync(getInstrumentation(), contentViewCore, onPageFinishedHelper); |
| 50 | assertTrue("Should be able to go back", |
| 51 | HistoryUtils.canGoBackOnUiThread(getInstrumentation(), contentViewCore)); |
| 52 | assertTrue("Should be able to go forward", |
| 53 | HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), contentViewCore)); |
| 54 | |
| 55 | HistoryUtils.clearHistoryOnUiThread(getInstrumentation(), contentViewCore); |
| 56 | assertFalse("Should not be able to go back", |
| 57 | HistoryUtils.canGoBackOnUiThread(getInstrumentation(), contentViewCore)); |
| 58 | assertFalse("Should not be able to go forward", |
| 59 | HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), contentViewCore)); |
| 60 | } |
| 61 | } |