Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java

Issue 12313070: [Android] Add a reload navigation test for ContentShell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java b/content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java
index 8b7754669a977a1e09bf132e083c4b9d2b32ed35..1d590adf2c5d6f89b6ff6c9996242ecc7d472886 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/NavigationTest.java
@@ -12,6 +12,8 @@ import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
import org.chromium.content_shell.ContentShellTestBase;
import org.chromium.content_shell_apk.ContentShellActivity;
+import java.util.concurrent.TimeUnit;
+
/**
* Tests for various aspects of navigation.
*/
@@ -37,6 +39,18 @@ public class NavigationTest extends ContentShellTestBase {
});
}
+ private void reload(final ContentView contentView,
+ TestCallbackHelperContainer testCallbackHelperContainer) throws Throwable {
+ handleBlockingCallbackAction(
+ testCallbackHelperContainer.getOnPageFinishedHelper(),
+ new Runnable() {
+ @Override
+ public void run() {
+ contentView.reload();
+ }
+ });
+ }
+
@MediumTest
@Feature({"Navigation"})
public void testDirectedNavigationHistory() throws Throwable {
@@ -82,4 +96,39 @@ public class NavigationTest extends ContentShellTestBase {
assertEquals(URL_7, history.getEntryAtIndex(2).getUrl());
}
+ /**
+ * Tests whether a page was successfully reloaded.
+ * Checks to make sure that OnPageFinished events were fired and that the timestamps of when
+ * the page loaded are different after the reload.
+ */
+ @MediumTest
+ @Feature({"Navigation"})
+ public void testPageReload() throws Throwable {
+ final String HTML_LOADTIME = "<html><head>" +
+ "<script type=\"text/javascript\">var loadTimestamp = new Date().getTime();" +
+ "function getLoadtime() { return loadTimestamp; }</script></head></html>";
+ final String URL_LOADTIME = UrlUtils.encodeHtmlDataUri(HTML_LOADTIME);
+
+ ContentShellActivity activity = launchContentShellWithUrl(URL_LOADTIME);
+ waitForActiveShellToBeDoneLoading();
+ ContentView contentView = activity.getActiveContentView();
+ TestCallbackHelperContainer testCallbackHelperContainer =
+ new TestCallbackHelperContainer(contentView);
+ TestCallbackHelperContainer.OnEvaluateJavaScriptResultHelper javascriptHelper =
+ testCallbackHelperContainer.getOnEvaluateJavaScriptResultHelper();
+
+ // Grab the first timestamp.
+ javascriptHelper.evaluateJavaScript(contentView.getContentViewCore(), "getLoadtime();");
+ javascriptHelper.waitUntilHasValue();
+ String firstTimestamp = javascriptHelper.getJsonResultAndClear();
+ assertNotNull("Timestamp was null.", firstTimestamp);
+
+ // Grab the timestamp after a reload and make sure they don't match.
+ reload(contentView, testCallbackHelperContainer);
+ javascriptHelper.evaluateJavaScript(contentView.getContentViewCore(), "getLoadtime();");
+ javascriptHelper.waitUntilHasValue();
+ String secondTimestamp = javascriptHelper.getJsonResultAndClear();
+ assertNotNull("Timestamp was null.", secondTimestamp);
+ assertFalse("Timestamps matched.", firstTimestamp.equals(secondTimestamp));
+ }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698