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

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

Issue 2670863004: 🏠 Add instrumentation test for Suggestions BottomSheet (Closed)
Patch Set: rebase, properly fix test initialisation, address 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/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 80debdf66b6cbb50763e9c3b80f938dcd2f6bdb1..274e9f1627fd457b5a9932a9264a36713e876abe 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
@@ -23,6 +23,7 @@
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ObserverList;
+import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.NativePageHost;
import org.chromium.chrome.browser.TabLoadStatus;
@@ -148,7 +149,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.
*/
@@ -235,6 +236,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);
@@ -291,6 +293,7 @@ public boolean onTouchEvent(MotionEvent e) {
if (mSettleAnimator == null) {
// Negate velocity so a positive number indicates a swipe up.
float currentVelocity = -mVelocityTracker.getYVelocity();
+ @SheetState
int targetState = getTargetSheetState(getSheetOffsetFromBottom(), currentVelocity);
setSheetState(targetState, true);
@@ -455,7 +458,7 @@ private void onExitPeekState() {
/**
* Show content in the bottom sheet's content area.
- * @param page The BottomSheetContent to show.
+ * @param content The {@link BottomSheetContent} to show.
*/
private void showContent(BottomSheetContent content) {
// If the desired content is already showing, do nothing.
@@ -679,6 +682,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.
@@ -709,7 +717,10 @@ 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];
+
+ @SheetState
int prevState = nextState;
for (int i = 0; i < sStates.length; i++) {
prevState = nextState;

Powered by Google App Engine
This is Rietveld 408576698