Commit 5c3ba407 authored by Xi Han's avatar Xi Han Committed by Chromium LUCI CQ

[Start] Incognito tab switcher should be shown on resume.

When tab switcher return "immediate" is enabled, we shouldn't show the
Incognito Start surface (single) when resuming Chrome. Instead, we will
show the Incognito tab switcher.

Bug: 1153713
Change-Id: I2710e1bad9bca3f577354367e2b1363e72561812
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2565730
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832109}
parent 23e27ce2
......@@ -930,6 +930,9 @@ class StartSurfaceMediator
? StartSurfaceState.SHOWN_HOMEPAGE
: mPreviousStartSurfaceState;
} else if (mStartSurfaceState == StartSurfaceState.SHOWING_START) {
if (mTabModelSelector.isIncognitoSelected() && !mShowStackTabSwitcher) {
return StartSurfaceState.SHOWN_TABSWITCHER;
}
return StartSurfaceState.SHOWN_HOMEPAGE;
} else if (mStartSurfaceState == StartSurfaceState.SHOWING_TABSWITCHER) {
return StartSurfaceState.SHOWN_TABSWITCHER;
......
......@@ -808,12 +808,14 @@ public class StartSurfaceTest {
@Test
@MediumTest
@Feature({"StartSurface"})
// clang-format off
@CommandLineFlags.Add({BASE_PARAMS + "/single/exclude_mv_tiles/true"
+ "/show_last_active_tab_only/true/show_stack_tab_switcher/true"})
public void
testShow_SingleAsHomepageV2_FromResumeShowStart() throws Exception {
public void testShow_SingleAsHomepageV2_FromResumeShowStart() throws Exception {
// clang-format on
if (!mImmediateReturn) return;
if (!mImmediateReturn) {
onView(withId(org.chromium.chrome.tab_ui.R.id.home_button)).perform(click());
}
ChromeTabbedActivity cta = mActivityTestRule.getActivity();
CriteriaHelper.pollUiThread(
......@@ -833,11 +835,60 @@ public class StartSurfaceTest {
// Simulates pressing Chrome's icon and launching Chrome from warm start.
mActivityTestRule.resumeMainActivityFromLauncher();
waitForTabModel();
if (mImmediateReturn) {
CriteriaHelper.pollUiThread(()
-> cta.getLayoutManager() != null
&& cta.getLayoutManager().overviewVisible());
// Verifies that with the vertical tab switcher, the regular Start surface is shown when
// resuming.
assertFalse(cta.getTabModelSelector().getCurrentModel().isIncognito());
assertThat(cta.getTabModelSelector().getCurrentModel().getCount(), equalTo(0));
} else {
assertTrue(cta.getTabModelSelector().getCurrentModel().isIncognito());
onViewWaiting(allOf(withId(R.id.new_tab_incognito_container), isDisplayed()));
}
}
@Test
@MediumTest
@Feature({"StartSurface"})
// clang-format off
@CommandLineFlags.Add({BASE_PARAMS + "/single"})
public void testShow_SingleAsHomepage_FromResumeShowStart() throws Exception {
// clang-format on
if (!mImmediateReturn) {
onView(withId(org.chromium.chrome.tab_ui.R.id.home_button)).perform(click());
}
ChromeTabbedActivity cta = mActivityTestRule.getActivity();
CriteriaHelper.pollUiThread(
() -> cta.getLayoutManager() != null && cta.getLayoutManager().overviewVisible());
waitForTabModel();
assertFalse(cta.getTabModelSelector().getCurrentModel().isIncognito());
assertThat(cta.getTabModelSelector().getCurrentModel().getCount(), equalTo(0));
TestThreadUtils.runOnUiThreadBlocking(
() -> { cta.getTabModelSelector().getModel(false).closeAllTabs(); });
TabUiTestHelper.verifyTabModelTabCount(cta, 0, 0);
assertTrue(cta.getLayoutManager().overviewVisible());
TestThreadUtils.runOnUiThreadBlocking(
() -> cta.getTabCreator(true /*incognito*/).launchNTP());
TabUiTestHelper.verifyTabModelTabCount(cta, 0, 1);
// Simulates pressing the Android's home button and bringing Chrome to the background.
pressHome();
// Simulates pressing Chrome's icon and launching Chrome from warm start.
mActivityTestRule.resumeMainActivityFromLauncher();
waitForTabModel();
assertTrue(cta.getTabModelSelector().getCurrentModel().isIncognito());
if (mImmediateReturn) {
CriteriaHelper.pollUiThread(()
-> cta.getLayoutManager() != null
&& cta.getLayoutManager().overviewVisible());
onViewWaiting(allOf(withId(R.id.secondary_tasks_surface_view), isDisplayed()));
} else {
onViewWaiting(allOf(withId(R.id.new_tab_incognito_container), isDisplayed()));
}
}
@Test
......
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