OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.android_webview.test; | 5 package org.chromium.android_webview.test; |
6 | 6 |
7 import android.test.suitebuilder.annotation.SmallTest; | 7 import android.test.suitebuilder.annotation.SmallTest; |
8 | 8 |
| 9 import org.chromium.android_webview.AwContents; |
9 import org.chromium.base.test.util.Feature; | 10 import org.chromium.base.test.util.Feature; |
10 import org.chromium.content.browser.ContentViewCore; | 11 import org.chromium.content.browser.ContentViewCore; |
11 import org.chromium.content.browser.test.util.HistoryUtils; | 12 import org.chromium.content.browser.test.util.HistoryUtils; |
12 import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPage
FinishedHelper; | 13 import org.chromium.content.browser.test.util.TestCallbackHelperContainer.OnPage
FinishedHelper; |
13 | 14 |
14 /** | 15 /** |
15 * Tests for a wanted clearHistory method. | 16 * Tests for a wanted clearHistory method. |
16 */ | 17 */ |
17 public class ClearHistoryTest extends AndroidWebViewTestBase { | 18 public class ClearHistoryTest extends AndroidWebViewTestBase { |
18 | 19 |
19 private static final String[] URLS = new String[3]; | 20 private static final String[] URLS = new String[3]; |
20 { | 21 { |
21 for (int i = 0; i < URLS.length; i++) { | 22 for (int i = 0; i < URLS.length; i++) { |
22 URLS[i] = "data:text/html;utf-8,<html><head></head><body>" + i + "</
body></html>"; | 23 URLS[i] = "data:text/html;utf-8,<html><head></head><body>" + i + "</
body></html>"; |
23 } | 24 } |
24 } | 25 } |
25 | 26 |
26 @SmallTest | 27 @SmallTest |
27 @Feature({"History", "Main"}) | 28 @Feature({"History", "Main"}) |
28 public void testClearHistory() throws Throwable { | 29 public void testClearHistory() throws Throwable { |
29 final TestAwContentsClient contentsClient = new TestAwContentsClient(); | 30 final TestAwContentsClient contentsClient = new TestAwContentsClient(); |
30 final ContentViewCore contentViewCore = | 31 final AwTestContainerView testContainerView = |
31 createAwTestContainerViewOnMainSync(contentsClient).getContentViewCo
re(); | 32 createAwTestContainerViewOnMainSync(contentsClient); |
| 33 final AwContents awContents = testContainerView.getAwContents(); |
| 34 final ContentViewCore contentViewCore = testContainerView.getContentView
Core(); |
32 | 35 |
33 OnPageFinishedHelper onPageFinishedHelper = contentsClient.getOnPageFini
shedHelper(); | 36 OnPageFinishedHelper onPageFinishedHelper = contentsClient.getOnPageFini
shedHelper(); |
34 for (int i = 0; i < 3; i++) { | 37 for (int i = 0; i < 3; i++) { |
35 loadUrlSync(contentViewCore, onPageFinishedHelper, URLS[i]); | 38 loadUrlSync(awContents, onPageFinishedHelper, URLS[i]); |
36 } | 39 } |
37 | 40 |
38 HistoryUtils.goBackSync(getInstrumentation(), contentViewCore, onPageFin
ishedHelper); | 41 HistoryUtils.goBackSync(getInstrumentation(), contentViewCore, onPageFin
ishedHelper); |
39 assertTrue("Should be able to go back", | 42 assertTrue("Should be able to go back", |
40 HistoryUtils.canGoBackOnUiThread(getInstrumentation(), conten
tViewCore)); | 43 HistoryUtils.canGoBackOnUiThread(getInstrumentation(), conten
tViewCore)); |
41 assertTrue("Should be able to go forward", | 44 assertTrue("Should be able to go forward", |
42 HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), con
tentViewCore)); | 45 HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), con
tentViewCore)); |
43 | 46 |
44 HistoryUtils.clearHistoryOnUiThread(getInstrumentation(), contentViewCor
e); | 47 HistoryUtils.clearHistoryOnUiThread(getInstrumentation(), contentViewCor
e); |
45 assertFalse("Should not be able to go back", | 48 assertFalse("Should not be able to go back", |
46 HistoryUtils.canGoBackOnUiThread(getInstrumentation(), conte
ntViewCore)); | 49 HistoryUtils.canGoBackOnUiThread(getInstrumentation(), conte
ntViewCore)); |
47 assertFalse("Should not be able to go forward", | 50 assertFalse("Should not be able to go forward", |
48 HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), co
ntentViewCore)); | 51 HistoryUtils.canGoForwardOnUiThread(getInstrumentation(), co
ntentViewCore)); |
49 } | 52 } |
50 } | 53 } |
OLD | NEW |