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

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

Issue 2754203004: 📰 Add tests for context menu usage (Closed)
Patch Set: y Created 3 years, 9 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.graphics.Canvas; 7 import android.graphics.Canvas;
8 import android.support.test.filters.LargeTest; 8 import android.support.test.filters.LargeTest;
9 import android.support.test.filters.MediumTest; 9 import android.support.test.filters.MediumTest;
10 import android.support.test.filters.SmallTest; 10 import android.support.test.filters.SmallTest;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 private View mFakebox; 66 private View mFakebox;
67 private ViewGroup mTileGridLayout; 67 private ViewGroup mTileGridLayout;
68 private String[] mSiteSuggestionUrls; 68 private String[] mSiteSuggestionUrls;
69 private FakeMostVisitedSites mMostVisitedSites; 69 private FakeMostVisitedSites mMostVisitedSites;
70 private EmbeddedTestServer mTestServer; 70 private EmbeddedTestServer mTestServer;
71 71
72 @Override 72 @Override
73 protected void setUp() throws Exception { 73 protected void setUp() throws Exception {
74 mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation ().getContext()); 74 mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation ().getContext());
75 mSiteSuggestionUrls = new String[] {mTestServer.getURL(TEST_PAGE)}; 75 mSiteSuggestionUrls = new String[] {mTestServer.getURL(TEST_PAGE)};
76
77 mMostVisitedSites = new FakeMostVisitedSites();
78 mMostVisitedSites.setTileSuggestions(FAKE_MOST_VISITED_TITLES, mSiteSugg estionUrls,
79 FAKE_MOST_VISITED_WHITELIST_ICON_PATHS, FAKE_MOST_VISITED_SOURCE S);
80 TileGroupDelegateImpl.setMostVisitedSitesForTests(mMostVisitedSites);
76 super.setUp(); 81 super.setUp();
77 } 82 }
78 83
79 @Override 84 @Override
80 protected void tearDown() throws Exception { 85 protected void tearDown() throws Exception {
81 mTestServer.stopAndDestroyServer(); 86 mTestServer.stopAndDestroyServer();
87 TileGroupDelegateImpl.setMostVisitedSitesForTests(null);
82 super.tearDown(); 88 super.tearDown();
83 } 89 }
84 90
85 @Override 91 @Override
86 public void startMainActivity() throws InterruptedException { 92 public void startMainActivity() throws InterruptedException {
87 startMainActivityOnBlankPage(); 93 startMainActivityWithURL(UrlConstants.NTP_URL);
88 mTab = getActivity().getActivityTab(); 94 mTab = getActivity().getActivityTab();
89
90 try {
91 runTestOnUiThread(new Runnable() {
92 @Override
93 public void run() {
94 // Create FakeMostVisitedSites after starting the activity, since it depends on
95 // native code.
96 mMostVisitedSites = new FakeMostVisitedSites(mTab.getProfile ());
97 mMostVisitedSites.setTileSuggestions(FAKE_MOST_VISITED_TITLE S,
98 mSiteSuggestionUrls, FAKE_MOST_VISITED_WHITELIST_ICO N_PATHS,
99 FAKE_MOST_VISITED_SOURCES);
100 }
101 });
102 } catch (Throwable t) {
103 fail(t.getMessage());
104 }
105 TileGroupDelegateImpl.setMostVisitedSitesForTests(mMostVisitedSites);
106
107 loadUrl(UrlConstants.NTP_URL);
108 NewTabPageTestUtils.waitForNtpLoaded(mTab); 95 NewTabPageTestUtils.waitForNtpLoaded(mTab);
109 96
110 assertTrue(mTab.getNativePage() instanceof NewTabPage); 97 assertTrue(mTab.getNativePage() instanceof NewTabPage);
111 mNtp = (NewTabPage) mTab.getNativePage(); 98 mNtp = (NewTabPage) mTab.getNativePage();
112 mFakebox = mNtp.getView().findViewById(R.id.search_box); 99 mFakebox = mNtp.getView().findViewById(R.id.search_box);
113 mTileGridLayout = (ViewGroup) mNtp.getView().findViewById(R.id.tile_grid _layout); 100 mTileGridLayout = (ViewGroup) mNtp.getView().findViewById(R.id.tile_grid _layout);
114 assertEquals(mSiteSuggestionUrls.length, mTileGridLayout.getChildCount() ); 101 assertEquals(mSiteSuggestionUrls.length, mTileGridLayout.getChildCount() );
115 } 102 }
116 103
117 @MediumTest 104 @MediumTest
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 */ 522 */
536 private void waitForFakeboxTopPosition(final NewTabPage ntp, int position) { 523 private void waitForFakeboxTopPosition(final NewTabPage ntp, int position) {
537 CriteriaHelper.pollUiThread(Criteria.equals(position, new Callable<Integ er>() { 524 CriteriaHelper.pollUiThread(Criteria.equals(position, new Callable<Integ er>() {
538 @Override 525 @Override
539 public Integer call() { 526 public Integer call() {
540 return getFakeboxTop(ntp); 527 return getFakeboxTop(ntp);
541 } 528 }
542 })); 529 }));
543 } 530 }
544 } 531 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698