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

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

Issue 2673003003: Rename MostVisited ui bits to Tile(Grid). (Closed)
Patch Set: Rebase. Created 3 years, 10 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
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/MainActivityWithURLTest.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 private static final String TEST_PAGE = "/chrome/test/data/android/navigate/ simple.html"; 57 private static final String TEST_PAGE = "/chrome/test/data/android/navigate/ simple.html";
58 58
59 private static final String[] FAKE_MOST_VISITED_TITLES = new String[] { "Sim ple" }; 59 private static final String[] FAKE_MOST_VISITED_TITLES = new String[] { "Sim ple" };
60 private static final String[] FAKE_MOST_VISITED_WHITELIST_ICON_PATHS = new S tring[] { "" }; 60 private static final String[] FAKE_MOST_VISITED_WHITELIST_ICON_PATHS = new S tring[] { "" };
61 private static final int[] FAKE_MOST_VISITED_SOURCES = new int[] {NTPTileSou rce.TOP_SITES}; 61 private static final int[] FAKE_MOST_VISITED_SOURCES = new int[] {NTPTileSou rce.TOP_SITES};
62 62
63 private Tab mTab; 63 private Tab mTab;
64 private NewTabPage mNtp; 64 private NewTabPage mNtp;
65 private View mFakebox; 65 private View mFakebox;
66 private ViewGroup mMostVisitedLayout; 66 private ViewGroup mTileGridLayout;
67 private String[] mFakeMostVisitedUrls; 67 private String[] mFakeMostVisitedUrls;
68 private FakeMostVisitedSites mFakeMostVisitedSites; 68 private FakeMostVisitedSites mFakeMostVisitedSites;
69 private EmbeddedTestServer mTestServer; 69 private EmbeddedTestServer mTestServer;
70 70
71 @Override 71 @Override
72 protected void setUp() throws Exception { 72 protected void setUp() throws Exception {
73 mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation ().getContext()); 73 mTestServer = EmbeddedTestServer.createAndStartServer(getInstrumentation ().getContext());
74 mFakeMostVisitedUrls = new String[] {mTestServer.getURL(TEST_PAGE)}; 74 mFakeMostVisitedUrls = new String[] {mTestServer.getURL(TEST_PAGE)};
75 super.setUp(); 75 super.setUp();
76 } 76 }
(...skipping 24 matching lines...) Expand all
101 fail(t.getMessage()); 101 fail(t.getMessage());
102 } 102 }
103 TileGroupDelegateImpl.setMostVisitedSitesForTests(mFakeMostVisitedSites) ; 103 TileGroupDelegateImpl.setMostVisitedSitesForTests(mFakeMostVisitedSites) ;
104 104
105 loadUrl(UrlConstants.NTP_URL); 105 loadUrl(UrlConstants.NTP_URL);
106 NewTabPageTestUtils.waitForNtpLoaded(mTab); 106 NewTabPageTestUtils.waitForNtpLoaded(mTab);
107 107
108 assertTrue(mTab.getNativePage() instanceof NewTabPage); 108 assertTrue(mTab.getNativePage() instanceof NewTabPage);
109 mNtp = (NewTabPage) mTab.getNativePage(); 109 mNtp = (NewTabPage) mTab.getNativePage();
110 mFakebox = mNtp.getView().findViewById(R.id.search_box); 110 mFakebox = mNtp.getView().findViewById(R.id.search_box);
111 mMostVisitedLayout = (ViewGroup) mNtp.getView().findViewById(R.id.most_v isited_layout); 111 mTileGridLayout = (ViewGroup) mNtp.getView().findViewById(R.id.tile_grid _layout);
112 assertEquals(mFakeMostVisitedUrls.length, mMostVisitedLayout.getChildCou nt()); 112 assertEquals(mFakeMostVisitedUrls.length, mTileGridLayout.getChildCount( ));
113 } 113 }
114 114
115 @MediumTest 115 @MediumTest
116 @Feature({"NewTabPage", "RenderTest"}) 116 @Feature({"NewTabPage", "RenderTest"})
117 @CommandLineFlags.Add("enable-features=NTPSnippets") 117 @CommandLineFlags.Add("enable-features=NTPSnippets")
118 public void testRender() throws IOException { 118 public void testRender() throws IOException {
119 ViewRenderer viewRenderer = new ViewRenderer(getActivity(), 119 ViewRenderer viewRenderer = new ViewRenderer(getActivity(),
120 "chrome/test/data/android/render_tests", "NewTabPageTest"); 120 "chrome/test/data/android/render_tests", "NewTabPageTest");
121 viewRenderer.renderAndCompare(mMostVisitedLayout, "most_visited"); 121 viewRenderer.renderAndCompare(mTileGridLayout, "most_visited");
122 viewRenderer.renderAndCompare(mFakebox, "fakebox"); 122 viewRenderer.renderAndCompare(mFakebox, "fakebox");
123 viewRenderer.renderAndCompare(mNtp.getView().getRootView(), "new_tab_pag e"); 123 viewRenderer.renderAndCompare(mNtp.getView().getRootView(), "new_tab_pag e");
124 124
125 // Scroll to search bar 125 // Scroll to search bar
126 final NewTabPageRecyclerView recyclerView = mNtp.getNewTabPageView().get RecyclerView(); 126 final NewTabPageRecyclerView recyclerView = mNtp.getNewTabPageView().get RecyclerView();
127 127
128 ThreadUtils.runOnUiThreadBlocking(new Runnable() { 128 ThreadUtils.runOnUiThreadBlocking(new Runnable() {
129 @Override 129 @Override
130 public void run() { 130 public void run() {
131 recyclerView.smoothScrollBy(0, mFakebox.getTop()); 131 recyclerView.smoothScrollBy(0, mFakebox.getTop());
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 227
228 /** 228 /**
229 * Tests clicking on a most visited item. 229 * Tests clicking on a most visited item.
230 */ 230 */
231 @SmallTest 231 @SmallTest
232 @Feature({"NewTabPage"}) 232 @Feature({"NewTabPage"})
233 public void testClickMostVisitedItem() throws InterruptedException { 233 public void testClickMostVisitedItem() throws InterruptedException {
234 ChromeTabUtils.waitForTabPageLoaded(mTab, new Runnable() { 234 ChromeTabUtils.waitForTabPageLoaded(mTab, new Runnable() {
235 @Override 235 @Override
236 public void run() { 236 public void run() {
237 View mostVisitedItem = mMostVisitedLayout.getChildAt(0); 237 View mostVisitedItem = mTileGridLayout.getChildAt(0);
238 singleClickView(mostVisitedItem); 238 singleClickView(mostVisitedItem);
239 } 239 }
240 }); 240 });
241 assertEquals(mFakeMostVisitedUrls[0], mTab.getUrl()); 241 assertEquals(mFakeMostVisitedUrls[0], mTab.getUrl());
242 } 242 }
243 243
244 /** 244 /**
245 * Tests opening a most visited item in a new tab. 245 * Tests opening a most visited item in a new tab.
246 */ 246 */
247 @DisabledTest // Flaked on the try bot. http://crbug.com/543138 247 @DisabledTest // Flaked on the try bot. http://crbug.com/543138
248 @SmallTest 248 @SmallTest
249 @Feature({"NewTabPage"}) 249 @Feature({"NewTabPage"})
250 public void testOpenMostVisitedItemInNewTab() throws InterruptedException { 250 public void testOpenMostVisitedItemInNewTab() throws InterruptedException {
251 invokeContextMenuAndOpenInANewTab(mMostVisitedLayout.getChildAt(0), 251 invokeContextMenuAndOpenInANewTab(mTileGridLayout.getChildAt(0),
252 ContextMenuManager.ID_OPEN_IN_NEW_TAB, false, mFakeMostVisitedUr ls[0]); 252 ContextMenuManager.ID_OPEN_IN_NEW_TAB, false, mFakeMostVisitedUr ls[0]);
253 } 253 }
254 254
255 /** 255 /**
256 * Tests opening a most visited item in a new incognito tab. 256 * Tests opening a most visited item in a new incognito tab.
257 */ 257 */
258 @SmallTest 258 @SmallTest
259 @Feature({"NewTabPage"}) 259 @Feature({"NewTabPage"})
260 public void testOpenMostVisitedItemInIncognitoTab() throws InterruptedExcept ion { 260 public void testOpenMostVisitedItemInIncognitoTab() throws InterruptedExcept ion {
261 invokeContextMenuAndOpenInANewTab(mMostVisitedLayout.getChildAt(0), 261 invokeContextMenuAndOpenInANewTab(mTileGridLayout.getChildAt(0),
262 ContextMenuManager.ID_OPEN_IN_INCOGNITO_TAB, true, mFakeMostVisi tedUrls[0]); 262 ContextMenuManager.ID_OPEN_IN_INCOGNITO_TAB, true, mFakeMostVisi tedUrls[0]);
263 } 263 }
264 264
265 /** 265 /**
266 * Tests deleting a most visited item. 266 * Tests deleting a most visited item.
267 */ 267 */
268 @SmallTest 268 @SmallTest
269 @Feature({"NewTabPage"}) 269 @Feature({"NewTabPage"})
270 public void testRemoveMostVisitedItem() { 270 public void testRemoveMostVisitedItem() {
271 View mostVisitedItem = mMostVisitedLayout.getChildAt(0); 271 View mostVisitedItem = mTileGridLayout.getChildAt(0);
272 ArrayList<View> views = new ArrayList<>(); 272 ArrayList<View> views = new ArrayList<>();
273 mMostVisitedLayout.findViewsWithText(views, FAKE_MOST_VISITED_TITLES[0], 273 mTileGridLayout.findViewsWithText(
274 View.FIND_VIEWS_WITH_TEXT); 274 views, FAKE_MOST_VISITED_TITLES[0], View.FIND_VIEWS_WITH_TEXT);
275 assertEquals(1, views.size()); 275 assertEquals(1, views.size());
276 276
277 TestTouchUtils.longClickView(getInstrumentation(), mostVisitedItem); 277 TestTouchUtils.longClickView(getInstrumentation(), mostVisitedItem);
278 assertTrue(getInstrumentation().invokeContextMenuAction( 278 assertTrue(getInstrumentation().invokeContextMenuAction(
279 getActivity(), ContextMenuManager.ID_REMOVE, 0)); 279 getActivity(), ContextMenuManager.ID_REMOVE, 0));
280 280
281 assertTrue(mFakeMostVisitedSites.isUrlBlacklisted(mFakeMostVisitedUrls[0 ])); 281 assertTrue(mFakeMostVisitedSites.isUrlBlacklisted(mFakeMostVisitedUrls[0 ]));
282 } 282 }
283 283
284 @MediumTest 284 @MediumTest
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 */ 459 */
460 private void waitForFakeboxTopPosition(final NewTabPage ntp, int position) { 460 private void waitForFakeboxTopPosition(final NewTabPage ntp, int position) {
461 CriteriaHelper.pollUiThread(Criteria.equals(position, new Callable<Integ er>() { 461 CriteriaHelper.pollUiThread(Criteria.equals(position, new Callable<Integ er>() {
462 @Override 462 @Override
463 public Integer call() { 463 public Integer call() {
464 return getFakeboxTop(ntp); 464 return getFakeboxTop(ntp);
465 } 465 }
466 })); 466 }));
467 } 467 }
468 } 468 }
OLDNEW
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/MainActivityWithURLTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698