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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetTest.java

Issue 2670863004: 🏠 Add instrumentation test for Suggestions BottomSheet (Closed)
Patch Set: fix compilation, comments 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..5344369fe7e1d35196a0816b4817127a91e8e0cd
--- /dev/null
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/suggestions/SuggestionsBottomSheetTest.java
@@ -0,0 +1,40 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.chrome.browser.suggestions;
+
+import android.os.SystemClock;
+import android.support.test.filters.MediumTest;
+import android.view.MotionEvent;
+
+import org.chromium.chrome.browser.ntp.cards.NewTabPageRecyclerView;
+import org.chromium.chrome.test.BottomSheetTestCaseBase;
+import org.chromium.content.browser.test.util.TestTouchUtils;
+
+/**
+ * Tests for the behaviour of the suggestions bottom sheet content.
Michael van Ouwerkerk 2017/02/03 20:20:33 How about this? "Instrumentation tests for {@code
dgn 2017/02/06 16:45:17 Done.
+ */
+public class SuggestionsBottomSheetTest extends BottomSheetTestCaseBase {
+ @MediumTest
+ public void testContextMenu() throws InterruptedException {
+ // TODO(dgn): set the initial adapter content to avoid network dependent behaviour.
+ NewTabPageRecyclerView recyclerView = getRecyclerView();
+ assertFalse(recyclerView.onInterceptTouchEvent(createTap()));
+
+ TestTouchUtils.longClickView(getInstrumentation(), recyclerView.findFirstCard().itemView);
Michael van Ouwerkerk 2017/02/03 20:20:33 Do we know for sure that the first card has been r
dgn 2017/02/06 16:45:18 Done.
+ assertTrue(recyclerView.onInterceptTouchEvent(createTap()));
+
+ getActivity().closeContextMenu();
+ assertFalse(recyclerView.onInterceptTouchEvent(createTap()));
+ }
+
+ private static MotionEvent createTap() {
Michael van Ouwerkerk 2017/02/03 20:20:33 Maybe "createTapEvent"?
dgn 2017/02/06 16:45:18 Done.
+ return MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
+ MotionEvent.ACTION_DOWN, 0f, 0f, 0);
+ }
+
+ private NewTabPageRecyclerView getRecyclerView() {
+ return (NewTabPageRecyclerView) getBottomSheetContent().getScrollingContentView();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698