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

[Start] Don't show previously visited URL when tapping on the omnibox.

The bug was caused by not resetting the text of the URL bar when an
empty text is passed via setUrlBarFocus() API.

Bug: 1159352
Change-Id: I6b134fd91ae96b8f956fc0ac30c77862c5ebcde4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2622875
Commit-Queue: Xi Han <hanxi@chromium.org>
Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Reviewed-by: default avatarFilip Gorski <fgorski@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843766}
parent 7ebaeaf2
......@@ -47,10 +47,12 @@ import android.content.Intent;
import android.os.Build;
import android.support.test.InstrumentationRegistry;
import android.support.test.uiautomator.UiDevice;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import androidx.test.espresso.UiController;
......@@ -915,10 +917,7 @@ public class StartSurfaceTest {
if (!mImmediateReturn) {
onView(withId(org.chromium.chrome.tab_ui.R.id.home_button)).perform(click());
}
CriteriaHelper.pollUiThread(
()
-> mActivityTestRule.getActivity().getLayoutManager() != null
&& mActivityTestRule.getActivity().getLayoutManager().overviewVisible());
CriteriaHelper.pollUiThread(this::isOverviewVisible);
waitForTabModel();
assertThat(
mActivityTestRule.getActivity().getTabModelSelector().getCurrentModel().getCount(),
......@@ -932,6 +931,19 @@ public class StartSurfaceTest {
assertThat(
mActivityTestRule.getActivity().getTabModelSelector().getCurrentModel().getCount(),
equalTo(2));
TestThreadUtils.runOnUiThreadBlocking(
() -> mActivityTestRule.getActivity().getTabCreator(false).launchNTP());
CriteriaHelper.pollUiThread(this::isOverviewVisible);
onView(allOf(withId(R.id.search_box_text), isDisplayed()));
TextView urlBar = mActivityTestRule.getActivity().findViewById(R.id.url_bar);
onView(withId(R.id.search_box_text)).perform(click());
Assert.assertTrue(TextUtils.isEmpty(urlBar.getText()));
}
private boolean isOverviewVisible() {
return mActivityTestRule.getActivity().getLayoutManager() != null
&& mActivityTestRule.getActivity().getLayoutManager().overviewVisible();
}
@Test
......
......@@ -505,9 +505,13 @@ public class ToolbarManager implements UrlFocusChangeListener, ThemeColorObserve
mActivityTabSupplier.set(tab);
// ActivityTabProvider will null out the tab passed to onObservingDifferentTab when
// the tab is non-interactive (e.g. when entering the TabSwitcher), but in those
// cases we actually still want to use the most recently selected tab.
if (tab == null) return;
// the tab is non-interactive (e.g. when entering the TabSwitcher or Start surface).
// In those cases we actually still want to use the most recently selected tab, but
// will update the URL.
if (tab == null) {
mLocationBarModel.notifyUrlChanged();
return;
}
refreshSelectedTab(tab);
onTabOrModelChanged();
......
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