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

Unified Diff: chrome/test/android/javatests/src/org/chromium/chrome/test/BottomSheetTestCaseBase.java

Issue 2698613006: [Home] Add lifecycle events and some tests (Closed)
Patch Set: fix previous patch 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
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/widget/BottomSheetObserverTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/android/javatests/src/org/chromium/chrome/test/BottomSheetTestCaseBase.java
diff --git a/chrome/test/android/javatests/src/org/chromium/chrome/test/BottomSheetTestCaseBase.java b/chrome/test/android/javatests/src/org/chromium/chrome/test/BottomSheetTestCaseBase.java
index 6a81592403e5b85097e68ee01ecfc4907f768ebe..c3043f769df7050ca1ec80879a073de5a2132b74 100644
--- a/chrome/test/android/javatests/src/org/chromium/chrome/test/BottomSheetTestCaseBase.java
+++ b/chrome/test/android/javatests/src/org/chromium/chrome/test/BottomSheetTestCaseBase.java
@@ -20,6 +20,9 @@ import org.chromium.chrome.test.util.browser.RecyclerViewTestUtils;
@CommandLineFlags.Add({"enable-features=ChromeHome"})
@Restriction(RESTRICTION_TYPE_PHONE) // ChromeHome is only enabled on phones
public abstract class BottomSheetTestCaseBase extends ChromeTabbedActivityTestBase {
+ /** A handle to the bottom sheet. */
+ protected BottomSheet mBottomSheet;
+
private boolean mOldChromeHomeFlagValue;
@Override
protected void setUp() throws Exception {
@@ -41,6 +44,8 @@ public abstract class BottomSheetTestCaseBase extends ChromeTabbedActivityTestBa
});
RecyclerViewTestUtils.waitForStableRecyclerView(
getBottomSheetContent().getScrollingContentView());
+
+ mBottomSheet = getActivity().getBottomSheet();
}
@Override
@@ -54,6 +59,33 @@ public abstract class BottomSheetTestCaseBase extends ChromeTabbedActivityTestBa
ChromePreferenceManager.getInstance().setChromeHomeEnabled(mOldChromeHomeFlagValue);
}
+ /**
+ * Set the bottom sheet's state on the UI thread.
+ * @param state The state to set the sheet to.
+ * @param animate If the sheet should animate to the provided state.
+ */
+ protected void setSheetState(final int state, final boolean animate) {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mBottomSheet.setSheetState(state, animate);
+ }
+ });
+ }
+
+ /**
+ * Set the bottom sheet's offset from the bottom of the screen on the UI thread.
+ * @param offset The offset from the bottom that the sheet should be.
+ */
+ protected void setSheetOffsetFromBottom(final float offset) {
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ mBottomSheet.setSheetOffsetFromBottomForTesting(offset);
+ }
+ });
+ }
+
protected BottomSheetContent getBottomSheetContent() {
return getActivity().getBottomSheet().getCurrentSheetContent();
}
« no previous file with comments | « chrome/android/javatests/src/org/chromium/chrome/browser/widget/BottomSheetObserverTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698