Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java |
index 390bf363b09a702d5aa4cb5fe3e0d078111e4f76..7af52d2a42ee05294961db130a369d3d0a15bd84 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanelBase.java |
@@ -810,8 +810,6 @@ abstract class ContextualSearchPanelBase implements ContextualSearchPromoHost { |
* @param reason The reason for a change in the panel's state. |
*/ |
public void setPanelState(PanelState state, StateChangeReason reason) { |
- mPanelState = state; |
- |
if (state == PanelState.CLOSED) { |
mIsShowing = false; |
onClosed(reason); |
@@ -819,6 +817,12 @@ abstract class ContextualSearchPanelBase implements ContextualSearchPromoHost { |
|| (state == PanelState.MAXIMIZED && !isFullscreenSizePanel())) { |
showPromoViewAtYPosition(getPromoYPx()); |
} |
+ |
+ // We should only set the state at the end of this method, in oder to make sure that |
+ // all callbacks will be fired before changing the state of the Panel. This prevents |
+ // some flakiness on tests since they rely on changes of state to determine when a |
+ // particular action has been completed. |
+ mPanelState = state; |
} |
/** |