OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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.chrome.browser.ntp; | 5 package org.chromium.chrome.browser.ntp; |
6 | 6 |
7 import android.os.Environment; | 7 import android.os.Environment; |
8 import android.test.suitebuilder.annotation.LargeTest; | 8 import android.test.suitebuilder.annotation.LargeTest; |
9 import android.test.suitebuilder.annotation.MediumTest; | 9 import android.test.suitebuilder.annotation.MediumTest; |
10 import android.test.suitebuilder.annotation.SmallTest; | 10 import android.test.suitebuilder.annotation.SmallTest; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 /** | 44 /** |
45 * Tests for the native android New Tab Page. | 45 * Tests for the native android New Tab Page. |
46 */ | 46 */ |
47 public class NewTabPageTest extends ChromeTabbedActivityTestBase { | 47 public class NewTabPageTest extends ChromeTabbedActivityTestBase { |
48 | 48 |
49 private static final String TEST_PAGE = "/chrome/test/data/android/navigate/
simple.html"; | 49 private static final String TEST_PAGE = "/chrome/test/data/android/navigate/
simple.html"; |
50 | 50 |
51 private static final String[] FAKE_MOST_VISITED_TITLES = new String[] { "Sim
ple" }; | 51 private static final String[] FAKE_MOST_VISITED_TITLES = new String[] { "Sim
ple" }; |
52 private static final String[] FAKE_MOST_VISITED_WHITELIST_ICON_PATHS = new S
tring[] { "" }; | 52 private static final String[] FAKE_MOST_VISITED_WHITELIST_ICON_PATHS = new S
tring[] { "" }; |
53 private static final int[] FAKE_MOST_VISITED_SOURCES = new int[] {MostVisite
dSource.TOP_SITES}; | 53 private static final int[] FAKE_MOST_VISITED_SOURCES = new int[] {MostVisite
dSource.TOP_SITES}; |
54 private static final int[] FAKE_MOST_VISITED_PROVIDER_INDEXES = new int[] {0
}; | |
55 | 54 |
56 private Tab mTab; | 55 private Tab mTab; |
57 private NewTabPage mNtp; | 56 private NewTabPage mNtp; |
58 private View mFakebox; | 57 private View mFakebox; |
59 private ViewGroup mMostVisitedLayout; | 58 private ViewGroup mMostVisitedLayout; |
60 private String[] mFakeMostVisitedUrls; | 59 private String[] mFakeMostVisitedUrls; |
61 private FakeMostVisitedSites mFakeMostVisitedSites; | 60 private FakeMostVisitedSites mFakeMostVisitedSites; |
62 private EmbeddedTestServer mTestServer; | 61 private EmbeddedTestServer mTestServer; |
63 | 62 |
64 @Override | 63 @Override |
(...skipping 17 matching lines...) Expand all Loading... |
82 | 81 |
83 try { | 82 try { |
84 runTestOnUiThread(new Runnable() { | 83 runTestOnUiThread(new Runnable() { |
85 @Override | 84 @Override |
86 public void run() { | 85 public void run() { |
87 // Create FakeMostVisitedSites after starting the activity,
since it depends on | 86 // Create FakeMostVisitedSites after starting the activity,
since it depends on |
88 // native code. | 87 // native code. |
89 mFakeMostVisitedSites = | 88 mFakeMostVisitedSites = |
90 new FakeMostVisitedSites(mTab.getProfile(), FAKE_MOS
T_VISITED_TITLES, | 89 new FakeMostVisitedSites(mTab.getProfile(), FAKE_MOS
T_VISITED_TITLES, |
91 mFakeMostVisitedUrls, FAKE_MOST_VISITED_WHIT
ELIST_ICON_PATHS, | 90 mFakeMostVisitedUrls, FAKE_MOST_VISITED_WHIT
ELIST_ICON_PATHS, |
92 FAKE_MOST_VISITED_SOURCES, FAKE_MOST_VISITED
_PROVIDER_INDEXES); | 91 FAKE_MOST_VISITED_SOURCES); |
93 } | 92 } |
94 }); | 93 }); |
95 } catch (Throwable t) { | 94 } catch (Throwable t) { |
96 fail(t.getMessage()); | 95 fail(t.getMessage()); |
97 } | 96 } |
98 NewTabPage.setMostVisitedSitesForTests(mFakeMostVisitedSites); | 97 NewTabPage.setMostVisitedSitesForTests(mFakeMostVisitedSites); |
99 | 98 |
100 loadUrl(UrlConstants.NTP_URL); | 99 loadUrl(UrlConstants.NTP_URL); |
101 NewTabPageTestUtils.waitForNtpLoaded(mTab); | 100 NewTabPageTestUtils.waitForNtpLoaded(mTab); |
102 | 101 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 private void waitForFakeboxTopPosition(final NewTabPage ntp, int position) | 362 private void waitForFakeboxTopPosition(final NewTabPage ntp, int position) |
364 throws InterruptedException { | 363 throws InterruptedException { |
365 CriteriaHelper.pollUiThread(Criteria.equals(position, new Callable<Integ
er>() { | 364 CriteriaHelper.pollUiThread(Criteria.equals(position, new Callable<Integ
er>() { |
366 @Override | 365 @Override |
367 public Integer call() { | 366 public Integer call() { |
368 return getFakeboxTop(ntp); | 367 return getFakeboxTop(ntp); |
369 } | 368 } |
370 })); | 369 })); |
371 } | 370 } |
372 } | 371 } |
OLD | NEW |