OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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.chrome.browser.ntp; |
| 6 |
| 7 import android.test.suitebuilder.annotation.LargeTest; |
| 8 import android.test.suitebuilder.annotation.MediumTest; |
| 9 import android.test.suitebuilder.annotation.Smoke; |
| 10 |
| 11 import org.chromium.base.test.util.Feature; |
| 12 import org.chromium.chrome.browser.Tab; |
| 13 import org.chromium.chrome.browser.UrlConstants; |
| 14 import org.chromium.chrome.test.ChromeTabbedActivityTestBase; |
| 15 import org.chromium.chrome.test.util.TestHttpServerClient; |
| 16 |
| 17 /** |
| 18 * Tests loading the NTP and navigating between it and other pages. |
| 19 */ |
| 20 public class NewTabPageNavigationTest extends ChromeTabbedActivityTestBase { |
| 21 |
| 22 /** |
| 23 * Sanity check that we do start on the NTP by default. |
| 24 */ |
| 25 @Smoke |
| 26 @MediumTest |
| 27 @Feature({"NewTabPage", "Main"}) |
| 28 public void testNTPIsDefault() { |
| 29 Tab tab = getActivity().getActivityTab(); |
| 30 assertNotNull(tab); |
| 31 String url = tab.getUrl(); |
| 32 assertTrue("Unexpected url: " + url, |
| 33 url.startsWith("chrome-native://newtab/") |
| 34 || url.startsWith("chrome-native://bookmarks/") |
| 35 || url.startsWith("chrome-native://recent-tabs/")); |
| 36 } |
| 37 |
| 38 /** |
| 39 * Check that navigating away from the NTP does work. |
| 40 */ |
| 41 @LargeTest |
| 42 @Feature({"NewTabPage"}) |
| 43 public void testNavigatingFromNTP() throws InterruptedException { |
| 44 String url = TestHttpServerClient.getUrl("chrome/test/data/android/googl
e.html"); |
| 45 loadUrl(url); |
| 46 assertEquals(url, getActivity().getActivityTab().getUrl()); |
| 47 } |
| 48 |
| 49 /** |
| 50 * Tests navigating back to the NTP after loading another page. |
| 51 */ |
| 52 @MediumTest |
| 53 @Feature({"NewTabPage"}) |
| 54 public void testNavigateBackToNTPViaUrl() throws InterruptedException { |
| 55 String url = TestHttpServerClient.getUrl("chrome/test/data/android/googl
e.html"); |
| 56 loadUrl(url); |
| 57 assertEquals(url, getActivity().getActivityTab().getUrl()); |
| 58 |
| 59 loadUrl(UrlConstants.NTP_URL); |
| 60 Tab tab = getActivity().getActivityTab(); |
| 61 assertNotNull(tab); |
| 62 url = tab.getUrl(); |
| 63 assertEquals(UrlConstants.NTP_URL, url); |
| 64 |
| 65 // Check that the NTP is actually displayed. |
| 66 assertNotNull(tab.getNativePage() instanceof NewTabPage); |
| 67 } |
| 68 |
| 69 @Override |
| 70 public void startMainActivity() throws InterruptedException { |
| 71 // Passing null below starts the activity on its default page, which is
the NTP on a clean |
| 72 // profile. |
| 73 startMainActivityWithURL(null); |
| 74 } |
| 75 } |
OLD | NEW |