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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/ntp/NewTabPageNavigationTest.java

Issue 1141283003: Upstream oodles of Chrome for Android code into Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: final patch? Created 5 years, 7 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
Index: chrome/android/javatests/src/org/chromium/chrome/browser/ntp/NewTabPageNavigationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/ntp/NewTabPageNavigationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/ntp/NewTabPageNavigationTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..34a0cd92574048719740e7bf691d1d57d8c359eb
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/ntp/NewTabPageNavigationTest.java
@@ -0,0 +1,75 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.ntp;
+
+import android.test.suitebuilder.annotation.LargeTest;
+import android.test.suitebuilder.annotation.MediumTest;
+import android.test.suitebuilder.annotation.Smoke;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.chrome.browser.Tab;
+import org.chromium.chrome.browser.UrlConstants;
+import org.chromium.chrome.test.ChromeTabbedActivityTestBase;
+import org.chromium.chrome.test.util.TestHttpServerClient;
+
+/**
+ * Tests loading the NTP and navigating between it and other pages.
+ */
+public class NewTabPageNavigationTest extends ChromeTabbedActivityTestBase {
+
+ /**
+ * Sanity check that we do start on the NTP by default.
+ */
+ @Smoke
+ @MediumTest
+ @Feature({"NewTabPage", "Main"})
+ public void testNTPIsDefault() {
+ Tab tab = getActivity().getActivityTab();
+ assertNotNull(tab);
+ String url = tab.getUrl();
+ assertTrue("Unexpected url: " + url,
+ url.startsWith("chrome-native://newtab/")
+ || url.startsWith("chrome-native://bookmarks/")
+ || url.startsWith("chrome-native://recent-tabs/"));
+ }
+
+ /**
+ * Check that navigating away from the NTP does work.
+ */
+ @LargeTest
+ @Feature({"NewTabPage"})
+ public void testNavigatingFromNTP() throws InterruptedException {
+ String url = TestHttpServerClient.getUrl("chrome/test/data/android/google.html");
+ loadUrl(url);
+ assertEquals(url, getActivity().getActivityTab().getUrl());
+ }
+
+ /**
+ * Tests navigating back to the NTP after loading another page.
+ */
+ @MediumTest
+ @Feature({"NewTabPage"})
+ public void testNavigateBackToNTPViaUrl() throws InterruptedException {
+ String url = TestHttpServerClient.getUrl("chrome/test/data/android/google.html");
+ loadUrl(url);
+ assertEquals(url, getActivity().getActivityTab().getUrl());
+
+ loadUrl(UrlConstants.NTP_URL);
+ Tab tab = getActivity().getActivityTab();
+ assertNotNull(tab);
+ url = tab.getUrl();
+ assertEquals(UrlConstants.NTP_URL, url);
+
+ // Check that the NTP is actually displayed.
+ assertNotNull(tab.getNativePage() instanceof NewTabPage);
+ }
+
+ @Override
+ public void startMainActivity() throws InterruptedException {
+ // Passing null below starts the activity on its default page, which is the NTP on a clean
+ // profile.
+ startMainActivityWithURL(null);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698