Commit 62bbaaef authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Simplify search term chip in Grid tab switcher

Search term chip went through FastPath++, and some tech debt were
introduced in order to pass formal equivalence checking.

Finch parameters for search term chip in Grid tab switcher
(enable_search_term_chip and enable_search_term_chip_adaptive_icon) are
now cached to simplify the tests.

Bug: 1048255
Change-Id: Ibe1b88a96dae07d3de2f0f49c00e8a53aaa73cde
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2114165Reviewed-by: default avatarMei Liang <meiliang@chromium.org>
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#752666}
parent 51b4afd9
...@@ -88,6 +88,7 @@ import org.chromium.chrome.browser.tasks.tab_management.TabSelectionEditorTestin ...@@ -88,6 +88,7 @@ import org.chromium.chrome.browser.tasks.tab_management.TabSelectionEditorTestin
import org.chromium.chrome.browser.tasks.tab_management.TabSuggestionMessageService; import org.chromium.chrome.browser.tasks.tab_management.TabSuggestionMessageService;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher; import org.chromium.chrome.browser.tasks.tab_management.TabSwitcher;
import org.chromium.chrome.browser.tasks.tab_management.TabSwitcherCoordinator; import org.chromium.chrome.browser.tasks.tab_management.TabSwitcherCoordinator;
import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities;
import org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper; import org.chromium.chrome.browser.tasks.tab_management.TabUiTestHelper;
import org.chromium.chrome.tab_ui.R; import org.chromium.chrome.tab_ui.R;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner; import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
...@@ -1484,6 +1485,7 @@ public class StartSurfaceLayoutTest { ...@@ -1484,6 +1485,7 @@ public class StartSurfaceLayoutTest {
@MediumTest @MediumTest
@CommandLineFlags.Add({BASE_PARAMS + "/enable_search_term_chip/true"}) @CommandLineFlags.Add({BASE_PARAMS + "/enable_search_term_chip/true"})
public void testSearchTermChip_noChip() throws InterruptedException { public void testSearchTermChip_noChip() throws InterruptedException {
assertTrue(TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue());
prepareTabs(1, 0, mUrl); prepareTabs(1, 0, mUrl);
enterGTSWithThumbnailChecking(); enterGTSWithThumbnailChecking();
...@@ -1495,6 +1497,7 @@ public class StartSurfaceLayoutTest { ...@@ -1495,6 +1497,7 @@ public class StartSurfaceLayoutTest {
@MediumTest @MediumTest
@CommandLineFlags.Add({BASE_PARAMS + "/enable_search_term_chip/true"}) @CommandLineFlags.Add({BASE_PARAMS + "/enable_search_term_chip/true"})
public void testSearchTermChip_withChip() throws InterruptedException { public void testSearchTermChip_withChip() throws InterruptedException {
assertTrue(TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue());
// Make sure we support RTL and CJKV languages. // Make sure we support RTL and CJKV languages.
String searchTermWithSpecialCodePoints = "a\n ئۇيغۇرچە\u200E漢字"; String searchTermWithSpecialCodePoints = "a\n ئۇيغۇرچە\u200E漢字";
// Special code points like new line (\n) and left-to-right marker (‎‎‎\u200E) should // Special code points like new line (\n) and left-to-right marker (‎‎‎\u200E) should
...@@ -1566,9 +1569,13 @@ public class StartSurfaceLayoutTest { ...@@ -1566,9 +1569,13 @@ public class StartSurfaceLayoutTest {
@Test @Test
@MediumTest @MediumTest
@CommandLineFlags. // clang-format off
Add({BASE_PARAMS + "/enable_search_term_chip/true/enable_search_term_chip_adaptive_icon/true"}) @CommandLineFlags.Add({BASE_PARAMS +
"/enable_search_term_chip/true/enable_search_term_chip_adaptive_icon/true"})
public void testSearchTermChip_adaptiveIcon() throws InterruptedException { public void testSearchTermChip_adaptiveIcon() throws InterruptedException {
// clang-format on
assertTrue(TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue());
assertTrue(TabUiFeatureUtilities.ENABLE_SEARCH_CHIP_ADAPTIVE.getValue());
String searchTerm = "hello world"; String searchTerm = "hello world";
// Do search, and verify the chip is still not shown. // Do search, and verify the chip is still not shown.
......
...@@ -127,7 +127,7 @@ class TabGridViewBinder { ...@@ -127,7 +127,7 @@ class TabGridViewBinder {
(int) res.getDimension(R.dimen.tab_list_selected_inset)); (int) res.getDimension(R.dimen.tab_list_selected_inset));
view.setForeground(model.get(TabProperties.IS_SELECTED) ? drawable : null); view.setForeground(model.get(TabProperties.IS_SELECTED) ? drawable : null);
} }
if (TabUiFeatureUtilities.isSearchTermChipEnabled()) { if (TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue()) {
ChipView searchButton = (ChipView) view.fastFindViewById(R.id.search_button); ChipView searchButton = (ChipView) view.fastFindViewById(R.id.search_button);
searchButton.getPrimaryTextView().setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); searchButton.getPrimaryTextView().setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START);
searchButton.getPrimaryTextView().setEllipsize(TextUtils.TruncateAt.END); searchButton.getPrimaryTextView().setEllipsize(TextUtils.TruncateAt.END);
...@@ -194,8 +194,7 @@ class TabGridViewBinder { ...@@ -194,8 +194,7 @@ class TabGridViewBinder {
updateColor(view, model.get(TabProperties.IS_INCOGNITO), TabProperties.UiType.CLOSABLE); updateColor(view, model.get(TabProperties.IS_INCOGNITO), TabProperties.UiType.CLOSABLE);
} else if (TabProperties.ACCESSIBILITY_DELEGATE == propertyKey) { } else if (TabProperties.ACCESSIBILITY_DELEGATE == propertyKey) {
view.setAccessibilityDelegate(model.get(TabProperties.ACCESSIBILITY_DELEGATE)); view.setAccessibilityDelegate(model.get(TabProperties.ACCESSIBILITY_DELEGATE));
} else if (TabUiFeatureUtilities.isSearchTermChipEnabled() } else if (TabProperties.SEARCH_QUERY == propertyKey) {
&& TabProperties.SEARCH_QUERY == propertyKey) {
String query = model.get(TabProperties.SEARCH_QUERY); String query = model.get(TabProperties.SEARCH_QUERY);
ChipView searchButton = (ChipView) view.fastFindViewById(R.id.search_button); ChipView searchButton = (ChipView) view.fastFindViewById(R.id.search_button);
if (TextUtils.isEmpty(query)) { if (TextUtils.isEmpty(query)) {
...@@ -204,8 +203,7 @@ class TabGridViewBinder { ...@@ -204,8 +203,7 @@ class TabGridViewBinder {
searchButton.setVisibility(View.VISIBLE); searchButton.setVisibility(View.VISIBLE);
searchButton.getPrimaryTextView().setText(query); searchButton.getPrimaryTextView().setText(query);
} }
} else if (TabUiFeatureUtilities.isSearchTermChipEnabled() } else if (TabProperties.SEARCH_LISTENER == propertyKey) {
&& TabProperties.SEARCH_LISTENER == propertyKey) {
TabListMediator.TabActionListener listener = model.get(TabProperties.SEARCH_LISTENER); TabListMediator.TabActionListener listener = model.get(TabProperties.SEARCH_LISTENER);
ChipView searchButton = (ChipView) view.fastFindViewById(R.id.search_button); ChipView searchButton = (ChipView) view.fastFindViewById(R.id.search_button);
if (listener == null) { if (listener == null) {
...@@ -216,8 +214,7 @@ class TabGridViewBinder { ...@@ -216,8 +214,7 @@ class TabGridViewBinder {
int tabId = model.get(TabProperties.TAB_ID); int tabId = model.get(TabProperties.TAB_ID);
listener.run(tabId); listener.run(tabId);
}); });
} else if (TabUiFeatureUtilities.isSearchTermChipEnabled() } else if (TabProperties.SEARCH_CHIP_ICON_DRAWABLE_ID == propertyKey) {
&& TabProperties.SEARCH_CHIP_ICON_DRAWABLE_ID == propertyKey) {
ChipView searchButton = (ChipView) view.fastFindViewById(R.id.search_button); ChipView searchButton = (ChipView) view.fastFindViewById(R.id.search_button);
int iconDrawableId = model.get(TabProperties.SEARCH_CHIP_ICON_DRAWABLE_ID); int iconDrawableId = model.get(TabProperties.SEARCH_CHIP_ICON_DRAWABLE_ID);
boolean shouldTint = iconDrawableId != R.drawable.ic_logo_googleg_24dp; boolean shouldTint = iconDrawableId != R.drawable.ic_logo_googleg_24dp;
......
...@@ -38,7 +38,6 @@ import org.chromium.base.metrics.RecordHistogram; ...@@ -38,7 +38,6 @@ import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.metrics.RecordUserAction; import org.chromium.base.metrics.RecordUserAction;
import org.chromium.base.task.PostTask; import org.chromium.base.task.PostTask;
import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager; import org.chromium.chrome.browser.compositor.layouts.content.TabContentManager;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; import org.chromium.chrome.browser.multiwindow.MultiWindowUtils;
import org.chromium.chrome.browser.native_page.NativePageFactory; import org.chromium.chrome.browser.native_page.NativePageFactory;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
...@@ -787,7 +786,7 @@ class TabListMediator { ...@@ -787,7 +786,7 @@ class TabListMediator {
}; };
} }
if (TabUiFeatureUtilities.isSearchTermChipEnabled()) { if (TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue()) {
mSearchChipIconDrawableId = getSearchChipIconDrawableId(); mSearchChipIconDrawableId = getSearchChipIconDrawableId();
mTemplateUrlObserver = () -> { mTemplateUrlObserver = () -> {
mSearchChipIconDrawableId = getSearchChipIconDrawableId(); mSearchChipIconDrawableId = getSearchChipIconDrawableId();
...@@ -1004,7 +1003,7 @@ class TabListMediator { ...@@ -1004,7 +1003,7 @@ class TabListMediator {
mModel.get(index).model.set(TabProperties.TITLE, getLatestTitleForTab(tab)); mModel.get(index).model.set(TabProperties.TITLE, getLatestTitleForTab(tab));
mModel.get(index).model.set(TabProperties.URL, getUrlForTab(tab)); mModel.get(index).model.set(TabProperties.URL, getUrlForTab(tab));
if (TabUiFeatureUtilities.isSearchTermChipEnabled() && mUiType == UiType.CLOSABLE) { if (TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue() && mUiType == UiType.CLOSABLE) {
mModel.get(index).model.set(TabProperties.SEARCH_QUERY, getLastSearchTerm(tab)); mModel.get(index).model.set(TabProperties.SEARCH_QUERY, getLastSearchTerm(tab));
mModel.get(index).model.set(TabProperties.SEARCH_LISTENER, mModel.get(index).model.set(TabProperties.SEARCH_LISTENER,
SearchTermChipUtils.getSearchQueryListener(tab, mTabSelectedListener)); SearchTermChipUtils.getSearchQueryListener(tab, mTabSelectedListener));
...@@ -1203,7 +1202,7 @@ class TabListMediator { ...@@ -1203,7 +1202,7 @@ class TabListMediator {
.with(CARD_TYPE, TAB) .with(CARD_TYPE, TAB)
.build(); .build();
if (TabUiFeatureUtilities.isSearchTermChipEnabled() && mUiType == UiType.CLOSABLE) { if (TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue() && mUiType == UiType.CLOSABLE) {
tabInfo.set(TabProperties.SEARCH_QUERY, getLastSearchTerm(tab)); tabInfo.set(TabProperties.SEARCH_QUERY, getLastSearchTerm(tab));
tabInfo.set(TabProperties.SEARCH_LISTENER, tabInfo.set(TabProperties.SEARCH_LISTENER,
SearchTermChipUtils.getSearchQueryListener(tab, mTabSelectedListener)); SearchTermChipUtils.getSearchQueryListener(tab, mTabSelectedListener));
...@@ -1257,7 +1256,7 @@ class TabListMediator { ...@@ -1257,7 +1256,7 @@ class TabListMediator {
} }
private String getLastSearchTerm(Tab tab) { private String getLastSearchTerm(Tab tab) {
assert TabUiFeatureUtilities.isSearchTermChipEnabled(); assert TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue();
if (mActionsOnAllRelatedTabs && TabUiFeatureUtilities.isTabGroupsAndroidEnabled() if (mActionsOnAllRelatedTabs && TabUiFeatureUtilities.isTabGroupsAndroidEnabled()
&& getRelatedTabsForId(tab.getId()).size() > 1) { && getRelatedTabsForId(tab.getId()).size() > 1) {
return null; return null;
...@@ -1267,7 +1266,7 @@ class TabListMediator { ...@@ -1267,7 +1266,7 @@ class TabListMediator {
private int getSearchChipIconDrawableId() { private int getSearchChipIconDrawableId() {
int iconDrawableId; int iconDrawableId;
if (isSearchChipAdaptiveIconEnabled()) { if (TabUiFeatureUtilities.ENABLE_SEARCH_CHIP_ADAPTIVE.getValue()) {
iconDrawableId = TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle() iconDrawableId = TemplateUrlServiceFactory.get().isDefaultSearchEngineGoogle()
? R.drawable.ic_logo_googleg_24dp ? R.drawable.ic_logo_googleg_24dp
: R.drawable.ic_search; : R.drawable.ic_search;
...@@ -1277,21 +1276,6 @@ class TabListMediator { ...@@ -1277,21 +1276,6 @@ class TabListMediator {
return iconDrawableId; return iconDrawableId;
} }
private boolean isSearchChipAdaptiveIconEnabled() {
if (SearchTermChipUtils.sIsSearchChipAdaptiveIconEnabledForTesting != null) {
return SearchTermChipUtils.sIsSearchChipAdaptiveIconEnabledForTesting;
}
if (!TabUiFeatureUtilities.isGridTabSwitcherEnabled() || !ChromeFeatureList.isInitialized()
|| !TabUiFeatureUtilities.isSearchTermChipEnabled()
|| !ChromeFeatureList
.getFieldTrialParamByFeature(ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID,
"enable_search_term_chip_adaptive_icon")
.equals("true")) {
return false;
}
return true;
}
private String getUrlForTab(Tab tab) { private String getUrlForTab(Tab tab) {
if (!TabUiFeatureUtilities.isTabGroupsAndroidContinuationEnabled()) return ""; if (!TabUiFeatureUtilities.isTabGroupsAndroidContinuationEnabled()) return "";
if (!mActionsOnAllRelatedTabs) return tab.getUrlString(); if (!mActionsOnAllRelatedTabs) return tab.getUrlString();
...@@ -1501,10 +1485,5 @@ class TabListMediator { ...@@ -1501,10 +1485,5 @@ class TabListMediator {
navigateToLastSearchQuery(originalTab); navigateToLastSearchQuery(originalTab);
}; };
} }
@VisibleForTesting
static void setIsSearchChipAdaptiveIconEnabledForTesting(Boolean isEnabled) {
sIsSearchChipAdaptiveIconEnabledForTesting = isEnabled;
}
} }
} }
...@@ -172,7 +172,7 @@ public class TabSwitcherCoordinator ...@@ -172,7 +172,7 @@ public class TabSwitcherCoordinator
} }
} }
if (TabUiFeatureUtilities.isSearchTermChipEnabled() if (TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.getValue()
&& mode != TabListCoordinator.TabListMode.CAROUSEL) { && mode != TabListCoordinator.TabListMode.CAROUSEL) {
mTabAttributeCache = new TabAttributeCache(mTabModelSelector); mTabAttributeCache = new TabAttributeCache(mTabModelSelector);
} }
......
...@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.tasks.tab_management; ...@@ -7,7 +7,6 @@ package org.chromium.chrome.browser.tasks.tab_management;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.chrome.browser.device.DeviceClassManager; import org.chromium.chrome.browser.device.DeviceClassManager;
...@@ -44,25 +43,17 @@ public class TabUiFeatureUtilities { ...@@ -44,25 +43,17 @@ public class TabUiFeatureUtilities {
new DoubleCachedFieldTrialParameter( new DoubleCachedFieldTrialParameter(
ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID, THUMBNAIL_ASPECT_RATIO_PARAM, 1.0); ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID, THUMBNAIL_ASPECT_RATIO_PARAM, 1.0);
private static Boolean sSearchTermChipEnabledForTesting; public static final String SEARCH_CHIP_PARAM = "enable_search_term_chip";
private static Boolean sTabManagementModuleSupportedForTesting; public static final BooleanCachedFieldTrialParameter ENABLE_SEARCH_CHIP =
private static Double sTabThumbnailAspectRatioForTesting; new BooleanCachedFieldTrialParameter(
ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID, SEARCH_CHIP_PARAM, false);
/** public static final String SEARCH_CHIP_ADAPTIVE_PARAM = "enable_search_term_chip_adaptive_icon";
* Set whether the search term chip in Grid tab switcher is enabled for testing. public static final BooleanCachedFieldTrialParameter ENABLE_SEARCH_CHIP_ADAPTIVE =
*/ new BooleanCachedFieldTrialParameter(
public static void setSearchTermChipEnabledForTesting(@Nullable Boolean enabled) { ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID, SEARCH_CHIP_ADAPTIVE_PARAM, false);
sSearchTermChipEnabledForTesting = enabled;
}
/** private static Boolean sTabManagementModuleSupportedForTesting;
* @return Whether the search term chip in Grid tab switcher is enabled.
*/
public static boolean isSearchTermChipEnabled() {
if (sSearchTermChipEnabledForTesting != null) return sSearchTermChipEnabledForTesting;
return ChromeFeatureList.getFieldTrialParamByFeatureAsBoolean(
ChromeFeatureList.TAB_GRID_LAYOUT_ANDROID, "enable_search_term_chip", false);
}
/** /**
* Set whether the tab management module is supported for testing. * Set whether the tab management module is supported for testing.
...@@ -141,22 +132,10 @@ public class TabUiFeatureUtilities { ...@@ -141,22 +132,10 @@ public class TabUiFeatureUtilities {
* @return Whether the thumbnail_aspect_ratio field trail is set. * @return Whether the thumbnail_aspect_ratio field trail is set.
*/ */
public static boolean isTabThumbnailAspectRatioNotOne() { public static boolean isTabThumbnailAspectRatioNotOne() {
double aspectRatio; return Double.compare(1.0, THUMBNAIL_ASPECT_RATIO.getValue()) != 0;
if (sTabThumbnailAspectRatioForTesting != null) {
aspectRatio = sTabThumbnailAspectRatioForTesting;
} else {
aspectRatio = THUMBNAIL_ASPECT_RATIO.getValue();
}
return Double.compare(1.0, aspectRatio) != 0;
} }
public static boolean isTabGridLayoutAndroidNewTabTileEnabled() { public static boolean isTabGridLayoutAndroidNewTabTileEnabled() {
return TextUtils.equals(TAB_GRID_LAYOUT_ANDROID_NEW_TAB_TILE.getValue(), "NewTabTile"); return TextUtils.equals(TAB_GRID_LAYOUT_ANDROID_NEW_TAB_TILE.getValue(), "NewTabTile");
} }
@VisibleForTesting
public static void setTabThumbnailAspectRatioForTesting(Double value) {
sTabThumbnailAspectRatioForTesting = value;
}
} }
...@@ -122,8 +122,6 @@ public class TabListViewHolderTest extends DummyUiActivityTestCase { ...@@ -122,8 +122,6 @@ public class TabListViewHolderTest extends DummyUiActivityTestCase {
@Override @Override
public void setUpTest() throws Exception { public void setUpTest() throws Exception {
super.setUpTest(); super.setUpTest();
TabUiFeatureUtilities.setTabThumbnailAspectRatioForTesting(1.0d);
TabUiFeatureUtilities.setSearchTermChipEnabledForTesting(true);
ViewGroup view = new LinearLayout(getActivity()); ViewGroup view = new LinearLayout(getActivity());
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
...@@ -585,8 +583,6 @@ public class TabListViewHolderTest extends DummyUiActivityTestCase { ...@@ -585,8 +583,6 @@ public class TabListViewHolderTest extends DummyUiActivityTestCase {
mStripMCP.destroy(); mStripMCP.destroy();
mGridMCP.destroy(); mGridMCP.destroy();
mSelectableMCP.destroy(); mSelectableMCP.destroy();
TabUiFeatureUtilities.setTabThumbnailAspectRatioForTesting(null);
TabUiFeatureUtilities.setSearchTermChipEnabledForTesting(null);
super.tearDownTest(); super.tearDownTest();
} }
} }
...@@ -252,7 +252,7 @@ public class TabListMediatorUnitTest { ...@@ -252,7 +252,7 @@ public class TabListMediatorUnitTest {
mMocker.mock(UrlUtilitiesJni.TEST_HOOKS, mUrlUtilitiesJniMock); mMocker.mock(UrlUtilitiesJni.TEST_HOOKS, mUrlUtilitiesJniMock);
CachedFeatureFlags.setForTesting(ChromeFeatureList.START_SURFACE_ANDROID, false); CachedFeatureFlags.setForTesting(ChromeFeatureList.START_SURFACE_ANDROID, false);
TabUiFeatureUtilities.setSearchTermChipEnabledForTesting(true); TabUiFeatureUtilities.ENABLE_SEARCH_CHIP.setForTesting(true);
mTab1 = prepareTab(TAB1_ID, TAB1_TITLE, TAB1_URL); mTab1 = prepareTab(TAB1_ID, TAB1_TITLE, TAB1_URL);
mTab2 = prepareTab(TAB2_ID, TAB2_TITLE, TAB2_URL); mTab2 = prepareTab(TAB2_ID, TAB2_TITLE, TAB2_URL);
mViewHolder1 = prepareViewHolder(TAB1_ID, POSITION1); mViewHolder1 = prepareViewHolder(TAB1_ID, POSITION1);
...@@ -318,7 +318,6 @@ public class TabListMediatorUnitTest { ...@@ -318,7 +318,6 @@ public class TabListMediatorUnitTest {
mModel = new TabListModel(); mModel = new TabListModel();
TemplateUrlServiceFactory.setInstanceForTesting(mTemplateUrlService); TemplateUrlServiceFactory.setInstanceForTesting(mTemplateUrlService);
TabListMediator.SearchTermChipUtils.setIsSearchChipAdaptiveIconEnabledForTesting(false);
mMediator = new TabListMediator(mContext, mModel, mTabModelSelector, mMediator = new TabListMediator(mContext, mModel, mTabModelSelector,
mTabContentManager::getTabThumbnailWithCallback, mTitleProvider, mTabContentManager::getTabThumbnailWithCallback, mTitleProvider,
mTabListFaviconProvider, false, null, mGridCardOnClickListenerProvider, null, mTabListFaviconProvider, false, null, mGridCardOnClickListenerProvider, null,
...@@ -332,7 +331,6 @@ public class TabListMediatorUnitTest { ...@@ -332,7 +331,6 @@ public class TabListMediatorUnitTest {
public void tearDown() { public void tearDown() {
RecordHistogram.setDisabledForTests(false); RecordHistogram.setDisabledForTests(false);
CachedFeatureFlags.setForTesting(ChromeFeatureList.START_SURFACE_ANDROID, null); CachedFeatureFlags.setForTesting(ChromeFeatureList.START_SURFACE_ANDROID, null);
TabUiFeatureUtilities.setSearchTermChipEnabledForTesting(null);
TabAttributeCache.clearAllForTesting(); TabAttributeCache.clearAllForTesting();
getGroupTitleSharedPreferences().edit().clear(); getGroupTitleSharedPreferences().edit().clear();
} }
...@@ -1913,7 +1911,6 @@ public class TabListMediatorUnitTest { ...@@ -1913,7 +1911,6 @@ public class TabListMediatorUnitTest {
public void testSearchChipAdaptiveIcon_Disabled() { public void testSearchChipAdaptiveIcon_Disabled() {
// Mock that google is the default search engine, and the search chip adaptive icon field // Mock that google is the default search engine, and the search chip adaptive icon field
// is set as false. // is set as false.
TabListMediator.SearchTermChipUtils.setIsSearchChipAdaptiveIconEnabledForTesting(false);
doReturn(true).when(mTemplateUrlService).isDefaultSearchEngineGoogle(); doReturn(true).when(mTemplateUrlService).isDefaultSearchEngineGoogle();
// Re-initialize the mediator to setup TemplateUrlServiceObserver if needed. // Re-initialize the mediator to setup TemplateUrlServiceObserver if needed.
...@@ -1937,7 +1934,7 @@ public class TabListMediatorUnitTest { ...@@ -1937,7 +1934,7 @@ public class TabListMediatorUnitTest {
public void testSearchChipAdaptiveIcon_ChangeWithSetting() { public void testSearchChipAdaptiveIcon_ChangeWithSetting() {
// Mock that google is the default search engine, and the search chip adaptive icon is // Mock that google is the default search engine, and the search chip adaptive icon is
// turned on. // turned on.
TabListMediator.SearchTermChipUtils.setIsSearchChipAdaptiveIconEnabledForTesting(true); TabUiFeatureUtilities.ENABLE_SEARCH_CHIP_ADAPTIVE.setForTesting(true);
doReturn(true).when(mTemplateUrlService).isDefaultSearchEngineGoogle(); doReturn(true).when(mTemplateUrlService).isDefaultSearchEngineGoogle();
// Re-initialize the mediator to setup TemplateUrlServiceObserver if needed. // Re-initialize the mediator to setup TemplateUrlServiceObserver if needed.
...@@ -2076,7 +2073,6 @@ public class TabListMediatorUnitTest { ...@@ -2076,7 +2073,6 @@ public class TabListMediatorUnitTest {
// TODO(crbug.com/1058196): avoid re-instanciate TabListMediator by using annotation. // TODO(crbug.com/1058196): avoid re-instanciate TabListMediator by using annotation.
CachedFeatureFlags.setForTesting(TAB_GROUPS_ANDROID, true); CachedFeatureFlags.setForTesting(TAB_GROUPS_ANDROID, true);
TabListMediator.SearchTermChipUtils.setIsSearchChipAdaptiveIconEnabledForTesting(false);
mMediator = new TabListMediator(mContext, mModel, mTabModelSelector, mMediator = new TabListMediator(mContext, mModel, mTabModelSelector,
mTabContentManager::getTabThumbnailWithCallback, mTitleProvider, mTabContentManager::getTabThumbnailWithCallback, mTitleProvider,
mTabListFaviconProvider, actionOnRelatedTabs, null, null, handler, mTabListFaviconProvider, actionOnRelatedTabs, null, null, handler,
......
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