Commit 04bbdd2e authored by Xi Han's avatar Xi Han Committed by Commit Bot

[Instant Start] Disable InstantStart when AccessibilityLayout is

enabled.

Without the check, it will trigger InstantStart code path and shows
the overview list layout. A crash would happen since the overview list
layout is null.

Bug: 1110791
Change-Id: If8dfd07118effe71a001286fcf9cb0e7279c8f31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2336306
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#795445}
parent 686499a2
...@@ -60,6 +60,7 @@ import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromeTablet; ...@@ -60,6 +60,7 @@ import org.chromium.chrome.browser.compositor.layouts.LayoutManagerChromeTablet;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeState; import org.chromium.chrome.browser.compositor.layouts.OverviewModeState;
import org.chromium.chrome.browser.compositor.layouts.StaticLayout; import org.chromium.chrome.browser.compositor.layouts.StaticLayout;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
import org.chromium.chrome.browser.device.DeviceClassManager;
import org.chromium.chrome.browser.flags.CachedFeatureFlags; import org.chromium.chrome.browser.flags.CachedFeatureFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches; import org.chromium.chrome.browser.flags.ChromeSwitches;
...@@ -79,6 +80,7 @@ import org.chromium.chrome.browser.tasks.pseudotab.TabAttributeCache; ...@@ -79,6 +80,7 @@ import org.chromium.chrome.browser.tasks.pseudotab.TabAttributeCache;
import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities; import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities;
import org.chromium.chrome.browser.toolbar.top.StartSurfaceToolbarCoordinator; import org.chromium.chrome.browser.toolbar.top.StartSurfaceToolbarCoordinator;
import org.chromium.chrome.browser.toolbar.top.TopToolbarCoordinator; import org.chromium.chrome.browser.toolbar.top.TopToolbarCoordinator;
import org.chromium.chrome.browser.util.ChromeAccessibilityUtil;
import org.chromium.chrome.test.ChromeActivityTestRule; import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule; import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
...@@ -786,6 +788,33 @@ public class InstantStartTest { ...@@ -786,6 +788,33 @@ public class InstantStartTest {
Assert.assertEquals(123, ((StaticLayout) activeLayout).getCurrentTabIdForTesting()); Assert.assertEquals(123, ((StaticLayout) activeLayout).getCurrentTabIdForTesting());
} }
@Test
@SmallTest
@Restriction({UiRestriction.RESTRICTION_TYPE_PHONE})
@EnableFeatures({ChromeFeatureList.START_SURFACE_ANDROID + "<Study"})
@CommandLineFlags.
Add({ChromeSwitches.ENABLE_ACCESSIBILITY_TAB_SWITCHER, "force-fieldtrials=Study/Group",
IMMEDIATE_RETURN_PARAMS + "/start_surface_variation/single"})
public void
testInstantStartNotCrashWhenAccessibilityLayoutEnabled() throws IOException {
TestThreadUtils.runOnUiThreadBlocking(
() -> ChromeAccessibilityUtil.get().setAccessibilityEnabledForTesting(true));
Assert.assertTrue(DeviceClassManager.enableAccessibilityLayout());
createTabStateFile(new int[] {123});
mActivityTestRule.startMainActivityFromLauncher();
Assert.assertFalse(TabUiFeatureUtilities.supportInstantStart(false));
Assert.assertTrue(CachedFeatureFlags.isEnabled(ChromeFeatureList.INSTANT_START));
Assert.assertTrue(StartSurfaceConfiguration.isStartSurfaceEnabled());
Assert.assertEquals(1,
mActivityTestRule.getActivity().getTabModelSelector().getCurrentModel().getCount());
Layout activeLayout = mActivityTestRule.getActivity().getLayoutManager().getActiveLayout();
Assert.assertTrue(activeLayout instanceof StaticLayout);
Assert.assertEquals(123, ((StaticLayout) activeLayout).getCurrentTabIdForTesting());
}
/** /**
* Toggles the header and checks whether the header has the right status. * Toggles the header and checks whether the header has the right status.
* *
......
...@@ -167,7 +167,8 @@ public class TabUiFeatureUtilities { ...@@ -167,7 +167,8 @@ public class TabUiFeatureUtilities {
public static boolean supportInstantStart(boolean isTablet) { public static boolean supportInstantStart(boolean isTablet) {
// TODO(crbug.com/1076449): Support instant start when the stack tab switcher is // TODO(crbug.com/1076449): Support instant start when the stack tab switcher is
// enabled. // enabled.
return CachedFeatureFlags.isEnabled(ChromeFeatureList.INSTANT_START) && !isTablet return !DeviceClassManager.enableAccessibilityLayout()
&& CachedFeatureFlags.isEnabled(ChromeFeatureList.INSTANT_START) && !isTablet
&& !StartSurfaceConfiguration.isStartSurfaceStackTabSwitcherEnabled(); && !StartSurfaceConfiguration.isStartSurfaceStackTabSwitcherEnabled();
} }
} }
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