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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java

Issue 2670863004: 🏠 Add instrumentation test for Suggestions BottomSheet (Closed)
Patch Set: Wait for recyclerview to stabilise and check view type 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/java/src/org/chromium/chrome/browser/widget/BottomSheet.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java
index 997e0c111f72c601330bc934538684f170464b0c..339f3c2d07b1ee6cb9a2627f7d6eef0012017b1e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java
@@ -22,6 +22,7 @@
import android.widget.FrameLayout;
import org.chromium.base.ApiCompatibilityUtils;
+import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.fullscreen.ChromeFullscreenManager;
import org.chromium.chrome.browser.suggestions.SuggestionsBottomSheetContent;
@@ -130,7 +131,7 @@
*/
public interface BottomSheetContent {
/**
- * Gets the {@link ScrollingView} that holds the content to be displayed in the Chrome Home
+ * Gets the {@link RecyclerView} that holds the content to be displayed in the Chrome Home
* bottom sheet.
* @return The scrolling content view.
*/
@@ -218,6 +219,7 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
// Figure out the projected state of the sheet and animate there. Note that a swipe up
// will have a negative velocity, swipe down will have a positive velocity. Negate this
// values so that the logic is more intuitive.
+ @SheetState
int targetState = getTargetSheetState(
getSheetOffsetFromBottom() + getFlingDistance(-velocityY), -velocityY);
setSheetState(targetState, true);
@@ -274,6 +276,7 @@ public boolean onTouchEvent(MotionEvent e) {
if (mSettleAnimator == null) {
// Negate velocity so a positive number indicates a swipe up.
float currentVelocity = -mVelocityTracker.getYVelocity();
+ @SheetState
gone 2017/02/10 18:17:08 I'd just put @SheetState on the same line to make
dgn 2017/02/13 14:25:39 That's the style recommended by `git cl format`. I
gone 2017/02/13 19:22:39 The problem is that git cl format doesn't work wel
gone 2017/02/14 02:01:38 Could you poke Nico Weber about this? I'm not sur
dgn 2017/02/14 16:07:39 Done.
int targetState = getTargetSheetState(getSheetOffsetFromBottom(), currentVelocity);
setSheetState(targetState, true);
@@ -399,7 +402,7 @@ private void onExitPeekState() {
/**
* Show content in the bottom sheet's content area.
- * @param page The BottomSheetContent to show.
+ * @param content The BottomSheetContent to show.
gone 2017/02/10 18:17:08 {@link BottomSheetContent}
dgn 2017/02/13 14:25:39 Done.
*/
private void showContent(BottomSheetContent content) {
// If the desired content is already showing, do nothing.
@@ -578,6 +581,11 @@ public boolean isRunningSettleAnimation() {
return mSettleAnimator != null;
}
+ @VisibleForTesting
+ public BottomSheetContent getCurrentSheetContent() {
+ return mSheetContent;
+ }
+
/**
* Gets the height of the bottom sheet based on a provided state.
* @param state The state to get the height from.
@@ -600,7 +608,9 @@ private int getTargetSheetState(float sheetHeight, float yVelocity) {
if (sheetHeight >= getMaxOffset()) return SHEET_STATE_FULL;
// First, find the two states that the sheet height is between.
+ @SheetState
int nextState = sStates[0];
gone 2017/02/10 18:17:08 Ditto about same line annotations.
+ @SheetState
int prevState = nextState;
for (int i = 0; i < sStates.length; i++) {
prevState = nextState;

Powered by Google App Engine
This is Rietveld 408576698