Commit 83d5304f authored by Mei Liang's avatar Mei Liang Committed by Commit Bot

Gate the grouping suggestion by the TabGroupAndroids flag

Android Tab group is not enabled by default, to avoid fetching the
server for unnecessary grouping suggestions, we need to gate the
fetching logic by the TabGroupAndroids flag.

This CL disables TabSuggestionServerFetcher if TabGroupAndroids flag is
disabled.

Bug: 1076538
Change-Id: I5715438f4cf579a90aae015fee9ba076944d8184
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2488720
Commit-Queue: Mei Liang <meiliang@chromium.org>
Reviewed-by: default avatarDavid Maunder <davidjm@chromium.org>
Reviewed-by: default avatarWei-Yin Chen (陳威尹) <wychen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820128}
parent c90e7c4d
......@@ -17,6 +17,7 @@ import org.chromium.chrome.browser.endpoint_fetcher.EndpointResponse;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.IdentityServicesProvider;
import org.chromium.chrome.browser.tasks.tab_management.TabUiFeatureUtilities;
import java.util.Collections;
import java.util.LinkedList;
......@@ -134,7 +135,12 @@ public class TabSuggestionsServerFetcher implements TabSuggestionsFetcher {
@Override
public boolean isEnabled() {
return isSignedIn() && isServerFetcherFlagEnabled();
// TODO(crbug.com/1141722): Currently this Fetcher is only used for grouping suggestion,
// avoid fetching server if the TabGroupsAndroid flag is disabled. We need to move this
// flag checking logic to somewhere if this server fetcher supports suggestions other than
// grouping in the future.
return isSignedIn() && isServerFetcherFlagEnabled()
&& TabUiFeatureUtilities.isTabGroupsAndroidEnabled();
}
@VisibleForTesting
......
......@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.tasks.tab_management.suggestions;
import static org.hamcrest.Matchers.is;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.ArgumentMatchers.anyString;
......@@ -20,6 +21,7 @@ import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
......@@ -28,12 +30,14 @@ import org.mockito.stubbing.Answer;
import org.robolectric.annotation.Config;
import org.chromium.base.Callback;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.base.test.util.JniMocker;
import org.chromium.chrome.browser.endpoint_fetcher.EndpointFetcher;
import org.chromium.chrome.browser.endpoint_fetcher.EndpointFetcherJni;
import org.chromium.chrome.browser.endpoint_fetcher.EndpointResponse;
import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.testing.local.LocalRobolectricTestRunner;
import org.chromium.chrome.test.util.browser.Features;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -43,12 +47,16 @@ import java.util.List;
/**
* Tests for {@link TabSuggestionsServerFetcher}
*/
@RunWith(LocalRobolectricTestRunner.class)
@RunWith(BaseRobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@Features.EnableFeatures(ChromeFeatureList.TAB_GROUPS_ANDROID)
public class TabSuggestionsServerFetcherUnitTest {
@Rule
public JniMocker mMocker = new JniMocker();
@Rule
public TestRule mProcessor = new Features.JUnitProcessor();
private static final TabContext.TabInfo TAB_INFO_YANDEX = new TabContext.TabInfo(
0, "Yandex", "https://www.yandex.com", "", "", 1588817215266L, "");
private static final TabContext.TabInfo TAB_INFO_BING =
......@@ -214,6 +222,15 @@ public class TabSuggestionsServerFetcherUnitTest {
}
}
@Test
@Features.DisableFeatures(ChromeFeatureList.TAB_GROUPS_ANDROID)
public void testServerFetcherDisabledWithDisableGroup() {
TabSuggestionsServerFetcher fetcher = spy(new TabSuggestionsServerFetcher());
doReturn(true).when(fetcher).isSignedIn();
doReturn(true).when(fetcher).isServerFetcherFlagEnabled();
Assert.assertThat("The Fetcher is enabled", fetcher.isEnabled(), is(false));
}
@Test
public void testServerFetcherDisabledIncognito() throws InterruptedException {
TabContext tabContext =
......
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