Commit 19139973 authored by Xi Han's avatar Xi Han Committed by Commit Bot

[Instant Start] Show page-info icon in omnibox.

In LocationBarLayout#onFinishNativeInitialization,
LocationBarPhone#setShowIconsWhenUrlFocused() is called to update the
|mFirstVisibleFocusedView| from UrlBar to StatusView. This means the
LocationBarPhone doesn't populate extra fade animation in
populateFadeAnimations(). However, when Instant Start is enabled, the
ToolbarPhone#triggerUrlFocusAnimation() will populate the URL focusing
animation before the LocationBarPhone is initialized. Thus,
unnecessary animation is created and results in the missing of page
info icon. To fix it, ToolbarPhone#triggerUrlFocusAnimation() will early
exit before native initialization.

Bug: 1137973
Change-Id: I5ce8031df2d0d618495e34cf8badc779e5d639dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521199
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825419}
parent 03782a91
......@@ -74,6 +74,7 @@ import org.chromium.chrome.browser.flags.CachedFeatureFlags;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.flags.ChromeSwitches;
import org.chromium.chrome.browser.homepage.HomepageManager;
import org.chromium.chrome.browser.omnibox.UrlBar;
import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.tab.TabState;
......@@ -95,6 +96,7 @@ import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.ChromeTabbedActivityTestRule;
import org.chromium.chrome.test.R;
import org.chromium.chrome.test.util.ChromeRenderTestRule;
import org.chromium.chrome.test.util.OmniboxTestUtils;
import org.chromium.chrome.test.util.ViewUtils;
import org.chromium.chrome.test.util.browser.Features;
import org.chromium.chrome.test.util.browser.Features.EnableFeatures;
......@@ -700,6 +702,42 @@ public class InstantStartTest {
// make sure post-native single-tab card looks the same.
}
@Test
@MediumTest
@Feature({"RenderTest"})
@Restriction({UiRestriction.RESTRICTION_TYPE_PHONE})
// clang-format off
@EnableFeatures({ChromeFeatureList.OMNIBOX_SEARCH_ENGINE_LOGO,
ChromeFeatureList.TAB_SWITCHER_ON_RETURN + "<Study,",
ChromeFeatureList.START_SURFACE_ANDROID + "<Study"})
@CommandLineFlags.Add({ChromeSwitches.DISABLE_NATIVE_INITIALIZATION,
"force-fieldtrials=Study/Group",
IMMEDIATE_RETURN_PARAMS +
"/start_surface_variation/single" +
"/exclude_mv_tiles/true" +
"/show_last_active_tab_only/true" +
"/show_stack_tab_switcher/true"})
public void renderSingleAsHomepageV2_PageInfoIconShown()
throws IOException {
// clang-format on
startMainActivityFromLauncher();
Assert.assertTrue(CachedFeatureFlags.isEnabled(ChromeFeatureList.INSTANT_START));
CriteriaHelper.pollUiThread(
() -> mActivityTestRule.getActivity().getLayoutManager().overviewVisible());
startAndWaitNativeInitialization();
waitForTabModel();
// Click on the search box. Omnibox should show up.
onView(withId(R.id.search_box_text)).perform(click());
UrlBar urlBar = (UrlBar) mActivityTestRule.getActivity().findViewById(R.id.url_bar);
OmniboxTestUtils.waitForFocusAndKeyboardActive(urlBar, true);
View surface = mActivityTestRule.getActivity().findViewById(R.id.location_bar);
ChromeRenderTestRule.sanitize(surface);
mRenderTestRule.render(surface, "singleV2_omniboxClickedShowLogo");
}
@Test
@SmallTest
@Restriction({UiRestriction.RESTRICTION_TYPE_PHONE})
......@@ -921,4 +959,9 @@ public class InstantStartTest {
}
};
}
private void waitForTabModel() {
CriteriaHelper.pollUiThread(
mActivityTestRule.getActivity().getTabModelSelector()::isTabStateInitialized);
}
}
......@@ -47,6 +47,7 @@ import androidx.core.graphics.drawable.DrawableCompat;
import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.MathUtils;
import org.chromium.base.TraceEvent;
import org.chromium.base.library_loader.LibraryLoader;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.device.DeviceClassManager;
import org.chromium.chrome.browser.feature_engagement.TrackerFactory;
......@@ -1844,7 +1845,12 @@ public class ToolbarPhone extends ToolbarLayout implements OnClickListener, TabC
getMenuButtonCoordinator().setVisibility(!inTabSwitcherMode);
triggerUrlFocusAnimation(inTabSwitcherMode && !urlHasFocus());
// The URL focusing animator set shouldn't be populated before native initialization. It is
// possible that this function is called before native initialization when Instant Start
// is enabled.
if (LibraryLoader.getInstance().isInitialized()) {
triggerUrlFocusAnimation(inTabSwitcherMode && !urlHasFocus());
}
if (inTabSwitcherMode) mUrlBar.setText("");
......
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