OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.test.suitebuilder.annotation.MediumTest; | 7 import android.test.suitebuilder.annotation.MediumTest; |
8 | 8 |
9 import org.chromium.base.test.util.Feature; | 9 import org.chromium.base.test.util.Feature; |
10 import org.chromium.base.test.util.UrlUtils; | 10 import org.chromium.base.test.util.UrlUtils; |
11 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; | 11 import org.chromium.content.browser.test.util.TestCallbackHelperContainer; |
12 import org.chromium.content_shell_apk.ContentShellActivity; | 12 import org.chromium.content_shell_apk.ContentShellActivity; |
13 import org.chromium.content_shell_apk.ContentShellTestBase; | 13 import org.chromium.content_shell_apk.ContentShellTestBase; |
14 | 14 |
15 import java.util.concurrent.TimeUnit; | |
16 | |
17 /** | 15 /** |
18 * Tests for various aspects of navigation. | 16 * Tests for various aspects of navigation. |
19 */ | 17 */ |
20 public class NavigationTest extends ContentShellTestBase { | 18 public class NavigationTest extends ContentShellTestBase { |
21 | 19 |
22 private static final String URL_1 = UrlUtils.encodeHtmlDataUri("<html>1</htm
l>"); | 20 private static final String URL_1 = UrlUtils.encodeHtmlDataUri("<html>1</htm
l>"); |
23 private static final String URL_2 = UrlUtils.encodeHtmlDataUri("<html>2</htm
l>"); | 21 private static final String URL_2 = UrlUtils.encodeHtmlDataUri("<html>2</htm
l>"); |
24 private static final String URL_3 = UrlUtils.encodeHtmlDataUri("<html>3</htm
l>"); | 22 private static final String URL_3 = UrlUtils.encodeHtmlDataUri("<html>3</htm
l>"); |
25 private static final String URL_4 = UrlUtils.encodeHtmlDataUri("<html>4</htm
l>"); | 23 private static final String URL_4 = UrlUtils.encodeHtmlDataUri("<html>4</htm
l>"); |
26 private static final String URL_5 = UrlUtils.encodeHtmlDataUri("<html>5</htm
l>"); | 24 private static final String URL_5 = UrlUtils.encodeHtmlDataUri("<html>5</htm
l>"); |
(...skipping 12 matching lines...) Expand all Loading... |
39 }); | 37 }); |
40 } | 38 } |
41 | 39 |
42 private void reload(final ContentView contentView, | 40 private void reload(final ContentView contentView, |
43 TestCallbackHelperContainer testCallbackHelperContainer) throws Thro
wable { | 41 TestCallbackHelperContainer testCallbackHelperContainer) throws Thro
wable { |
44 handleBlockingCallbackAction( | 42 handleBlockingCallbackAction( |
45 testCallbackHelperContainer.getOnPageFinishedHelper(), | 43 testCallbackHelperContainer.getOnPageFinishedHelper(), |
46 new Runnable() { | 44 new Runnable() { |
47 @Override | 45 @Override |
48 public void run() { | 46 public void run() { |
49 contentView.reload(); | 47 contentView.getContentViewCore().reload(true); |
50 } | 48 } |
51 }); | 49 }); |
52 } | 50 } |
53 | 51 |
54 @MediumTest | 52 @MediumTest |
55 @Feature({"Navigation"}) | 53 @Feature({"Navigation"}) |
56 public void testDirectedNavigationHistory() throws Throwable { | 54 public void testDirectedNavigationHistory() throws Throwable { |
57 ContentShellActivity activity = launchContentShellWithUrl(URL_1); | 55 ContentShellActivity activity = launchContentShellWithUrl(URL_1); |
58 waitForActiveShellToBeDoneLoading(); | 56 waitForActiveShellToBeDoneLoading(); |
59 ContentView contentView = activity.getActiveContentView(); | 57 ContentView contentView = activity.getActiveContentView(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 | 123 |
126 // Grab the timestamp after a reload and make sure they don't match. | 124 // Grab the timestamp after a reload and make sure they don't match. |
127 reload(contentView, testCallbackHelperContainer); | 125 reload(contentView, testCallbackHelperContainer); |
128 javascriptHelper.evaluateJavaScript(contentView.getContentViewCore(), "g
etLoadtime();"); | 126 javascriptHelper.evaluateJavaScript(contentView.getContentViewCore(), "g
etLoadtime();"); |
129 javascriptHelper.waitUntilHasValue(); | 127 javascriptHelper.waitUntilHasValue(); |
130 String secondTimestamp = javascriptHelper.getJsonResultAndClear(); | 128 String secondTimestamp = javascriptHelper.getJsonResultAndClear(); |
131 assertNotNull("Timestamp was null.", secondTimestamp); | 129 assertNotNull("Timestamp was null.", secondTimestamp); |
132 assertFalse("Timestamps matched.", firstTimestamp.equals(secondTimestamp
)); | 130 assertFalse("Timestamps matched.", firstTimestamp.equals(secondTimestamp
)); |
133 } | 131 } |
134 } | 132 } |
OLD | NEW |