Commit 9083dbe8 authored by Mia Glaese's avatar Mia Glaese Committed by Commit Bot

[Start Surface] Show on swipe down from locationbar.

Follow up to:
https://chromium-review.googlesource.com/c/chromium/src/+/1956187

Before: StartSurface state is not shown correctly when triggered through swipe down,
because StartSurface state is not set in LayoutManager.
StartSurface state is not always set in Activity.

After:
If state is not set (on swipe down), StartSurface defaults to SHOWING_HOME.
Start Surface state is always set correctly in ChromeTabbedActivity.

Bug: 1038276, 1038274
Change-Id: Ifbf7ece713a6866b2c9925d485f1ae3a27d24d51
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1981096
Commit-Queue: Mia Glaese <glamia@chromium.org>
Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Reviewed-by: default avatarGanggui Tang <gogerald@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728329}
parent 2f24bb27
...@@ -359,9 +359,16 @@ class StartSurfaceMediator ...@@ -359,9 +359,16 @@ class StartSurfaceMediator
mIsIncognito = mTabModelSelector.isIncognitoSelected(); mIsIncognito = mTabModelSelector.isIncognitoSelected();
mPropertyModel.set(IS_INCOGNITO, mIsIncognito); mPropertyModel.set(IS_INCOGNITO, mIsIncognito);
// if OvervieModeState is NOT_SHOWN, default to SHOWING_HOMEPAGE. This should only
// happen when entering Start through SwipeDown gesture on URL bar.
if (mOverviewModeState == OverviewModeState.NOT_SHOWN) {
mOverviewModeState = OverviewModeState.SHOWING_HOMEPAGE;
}
// set OverviewModeState // set OverviewModeState
@OverviewModeState @OverviewModeState
int shownState = computeOverviewStateShown(); int shownState = computeOverviewStateShown();
assert (isShownState(shownState));
setOverviewState(shownState); setOverviewState(shownState);
// Make sure FeedSurfaceCoordinator is built before the explore surface is showing by // Make sure FeedSurfaceCoordinator is built before the explore surface is showing by
......
...@@ -958,6 +958,59 @@ public class StartSurfaceMediatorUnitTest { ...@@ -958,6 +958,59 @@ public class StartSurfaceMediatorUnitTest {
assertThat(mediator.shouldShowTabSwitcherToolbar(), equalTo(true)); assertThat(mediator.shouldShowTabSwitcherToolbar(), equalTo(true));
} }
@Test
public void defaultStateSinglePane() {
doReturn(false).when(mTabModelSelector).isIncognitoSelected();
doReturn(mLocationBarVoiceRecognitionHandler)
.when(mFakeBoxDelegate)
.getLocationBarVoiceRecognitionHandler();
doReturn(true).when(mLocationBarVoiceRecognitionHandler).isVoiceSearchEnabled();
StartSurfaceMediator mediator = createStartSurfaceMediator(SurfaceMode.SINGLE_PANE);
verify(mMainTabGridController)
.addOverviewModeObserver(mOverviewModeObserverCaptor.capture());
assertThat(mediator.getOverviewState(), equalTo(OverviewModeState.NOT_SHOWN));
mediator.showOverview(false);
assertThat(mediator.getOverviewState(), equalTo(OverviewModeState.SHOWN_HOMEPAGE));
}
@Test
public void defaultStateTaskOnly() {
doReturn(false).when(mTabModelSelector).isIncognitoSelected();
doReturn(mLocationBarVoiceRecognitionHandler)
.when(mFakeBoxDelegate)
.getLocationBarVoiceRecognitionHandler();
doReturn(true).when(mLocationBarVoiceRecognitionHandler).isVoiceSearchEnabled();
StartSurfaceMediator mediator = createStartSurfaceMediator(SurfaceMode.TASKS_ONLY);
verify(mMainTabGridController)
.addOverviewModeObserver(mOverviewModeObserverCaptor.capture());
assertThat(mediator.getOverviewState(), equalTo(OverviewModeState.NOT_SHOWN));
mediator.showOverview(false);
assertThat(mediator.getOverviewState(),
equalTo(OverviewModeState.SHOWN_TABSWITCHER_TASKS_ONLY));
}
@Test
public void defaultStateTwoPanes() {
doReturn(false).when(mTabModelSelector).isIncognitoSelected();
doReturn(mLocationBarVoiceRecognitionHandler)
.when(mFakeBoxDelegate)
.getLocationBarVoiceRecognitionHandler();
doReturn(true).when(mLocationBarVoiceRecognitionHandler).isVoiceSearchEnabled();
StartSurfaceMediator mediator = createStartSurfaceMediator(SurfaceMode.TWO_PANES);
verify(mMainTabGridController)
.addOverviewModeObserver(mOverviewModeObserverCaptor.capture());
assertThat(mediator.getOverviewState(), equalTo(OverviewModeState.NOT_SHOWN));
mediator.showOverview(false);
assertThat(mediator.getOverviewState(),
equalTo(OverviewModeState.SHOWN_TABSWITCHER_TWO_PANES));
}
@Test @Test
public void showAndHideTabSwitcherToolbarTabswitcher() { public void showAndHideTabSwitcherToolbarTabswitcher() {
doReturn(false).when(mTabModelSelector).isIncognitoSelected(); doReturn(false).when(mTabModelSelector).isIncognitoSelected();
......
...@@ -1879,7 +1879,7 @@ public class ChromeTabbedActivity extends ChromeActivity implements ScreenshotMo ...@@ -1879,7 +1879,7 @@ public class ChromeTabbedActivity extends ChromeActivity implements ScreenshotMo
getCurrentTabModel().closeTab(tabToClose, false, true, false); getCurrentTabModel().closeTab(tabToClose, false, true, false);
// If there is no next tab to open, enter overview mode. // If there is no next tab to open, enter overview mode.
if (!hasNextTab) mOverviewModeController.showOverview(false); if (!hasNextTab) showOverview(OverviewModeState.SHOWING_START);
}, CLOSE_TAB_ON_MINIMIZE_DELAY_MS); }, CLOSE_TAB_ON_MINIMIZE_DELAY_MS);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment