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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/ntp/NewTabPageTest.java

Issue 2105933002: NTP: Fix metrics recording crash by plumbing the necessary data to Java. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address treib@ comments. Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
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};
54 private static final int[] FAKE_MOST_VISITED_PROVIDER_INDEXES = new int[] {0 };
53 55
54 private Tab mTab; 56 private Tab mTab;
55 private NewTabPage mNtp; 57 private NewTabPage mNtp;
56 private View mFakebox; 58 private View mFakebox;
57 private ViewGroup mMostVisitedLayout; 59 private ViewGroup mMostVisitedLayout;
58 private String[] mFakeMostVisitedUrls; 60 private String[] mFakeMostVisitedUrls;
59 private FakeMostVisitedSites mFakeMostVisitedSites; 61 private FakeMostVisitedSites mFakeMostVisitedSites;
60 private EmbeddedTestServer mTestServer; 62 private EmbeddedTestServer mTestServer;
61 63
62 @Override 64 @Override
(...skipping 16 matching lines...) Expand all
79 mTab = getActivity().getActivityTab(); 81 mTab = getActivity().getActivityTab();
80 82
81 try { 83 try {
82 runTestOnUiThread(new Runnable() { 84 runTestOnUiThread(new Runnable() {
83 @Override 85 @Override
84 public void run() { 86 public void run() {
85 // Create FakeMostVisitedSites after starting the activity, since it depends on 87 // Create FakeMostVisitedSites after starting the activity, since it depends on
86 // native code. 88 // native code.
87 mFakeMostVisitedSites = 89 mFakeMostVisitedSites =
88 new FakeMostVisitedSites(mTab.getProfile(), FAKE_MOS T_VISITED_TITLES, 90 new FakeMostVisitedSites(mTab.getProfile(), FAKE_MOS T_VISITED_TITLES,
89 mFakeMostVisitedUrls, FAKE_MOST_VISITED_WHIT ELIST_ICON_PATHS); 91 mFakeMostVisitedUrls, FAKE_MOST_VISITED_WHIT ELIST_ICON_PATHS,
92 FAKE_MOST_VISITED_SOURCES, FAKE_MOST_VISITED _PROVIDER_INDEXES);
90 } 93 }
91 }); 94 });
92 } catch (Throwable t) { 95 } catch (Throwable t) {
93 fail(t.getMessage()); 96 fail(t.getMessage());
94 } 97 }
95 NewTabPage.setMostVisitedSitesForTests(mFakeMostVisitedSites); 98 NewTabPage.setMostVisitedSitesForTests(mFakeMostVisitedSites);
96 99
97 loadUrl(UrlConstants.NTP_URL); 100 loadUrl(UrlConstants.NTP_URL);
98 NewTabPageTestUtils.waitForNtpLoaded(mTab); 101 NewTabPageTestUtils.waitForNtpLoaded(mTab);
99 102
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 private void waitForFakeboxTopPosition(final NewTabPage ntp, int position) 363 private void waitForFakeboxTopPosition(final NewTabPage ntp, int position)
361 throws InterruptedException { 364 throws InterruptedException {
362 CriteriaHelper.pollUiThread(Criteria.equals(position, new Callable<Integ er>() { 365 CriteriaHelper.pollUiThread(Criteria.equals(position, new Callable<Integ er>() {
363 @Override 366 @Override
364 public Integer call() { 367 public Integer call() {
365 return getFakeboxTop(ntp); 368 return getFakeboxTop(ntp);
366 } 369 }
367 })); 370 }));
368 } 371 }
369 } 372 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698