Revert "[Tab Group Parity] Add a shared pref and utils for tab group colors"

This reverts commit e99fb098fb0faacc5e89be762c15de797c280e36.

Reason for revert: ChromeTabSwitcherTest#testTabSwitcher failing on android bots. See bug for details.

Original change's description:
> [Tab Group Parity] Add a shared pref and utils for tab group colors
>
> Add a shared pref to store a tab group's color and will include backend logic for updating changes to the color.
>
> This CL will also include logic to assign a default color to each existing tab group on a least-used algorithm.
>
> Bug: 41490324
> Change-Id: I7cf9e83f525a0ac4567d356b41d516a60d267ab7
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5293278
> Reviewed-by: Calder Kitagawa <ckitagawa@chromium.org>
> Commit-Queue: Brandon Fong <bjfong@google.com>
> Cr-Commit-Position: refs/heads/main@{#1265986}

Bug: 41490324, 327273584
Change-Id: I0e6d12784e1e42a3f4b8827f54b82b80fb91b907
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5329728
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Friedrich Horschig <fhorschig@chromium.org>
Owners-Override: Friedrich Horschig <fhorschig@chromium.org>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Cr-Commit-Position: refs/heads/main@{#1266306}
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
index 76aee47b..97b8366 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java
@@ -209,8 +209,6 @@
 import org.chromium.chrome.browser.tasks.ReturnToChromeUtil;
 import org.chromium.chrome.browser.tasks.ReturnToChromeUtil.ReturnToChromeBackPressHandler;
 import org.chromium.chrome.browser.tasks.TasksUma;
-import org.chromium.chrome.browser.tasks.tab_groups.TabGroupColorUtils;
-import org.chromium.chrome.browser.tasks.tab_groups.TabGroupModelFilter;
 import org.chromium.chrome.browser.tasks.tab_management.CloseAllTabsDialog;
 import org.chromium.chrome.browser.tasks.tab_management.TabGroupUi;
 import org.chromium.chrome.browser.tasks.tab_management.TabManagementDelegateProvider;
@@ -2303,20 +2301,6 @@
                         this::getSnackbarManager,
                         dialogVisibilitySupplier);
 
-        if (ChromeFeatureList.sTabGroupParityAndroid.isEnabled()) {
-            TabModelUtils.runOnTabStateInitialized(
-                    getTabModelSelectorSupplier().get(),
-                    (tabModelSelectorReturn) -> {
-                        TabGroupColorUtils.assignTabGroupColorsIfApplicable(
-                                (TabGroupModelFilter)
-                                        tabModelSelectorReturn
-                                                .getTabModelFilterProvider()
-                                                .getCurrentTabModelFilter());
-                    });
-        } else {
-            PostTask.postTask(TaskTraits.UI_DEFAULT, TabGroupColorUtils::clearTabGroupColorInfo);
-        }
-
         mInactivityTracker =
                 new ChromeInactivityTracker(
                         ChromePreferenceKeys.TABBED_ACTIVITY_LAST_BACKGROUNDED_TIME_MS_PREF);
diff --git a/chrome/browser/tab_group/BUILD.gn b/chrome/browser/tab_group/BUILD.gn
index 22788aeb..a4d40cf0 100644
--- a/chrome/browser/tab_group/BUILD.gn
+++ b/chrome/browser/tab_group/BUILD.gn
@@ -9,7 +9,6 @@
 android_library("java") {
   sources = [
     "java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroup.java",
-    "java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupColorUtils.java",
     "java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilter.java",
     "java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterObserver.java",
     "java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupTitleUtils.java",
@@ -21,15 +20,12 @@
     "//chrome/browser/flags:java",
     "//chrome/browser/tab:java",
     "//chrome/browser/tabmodel:java",
-    "//components/tab_groups:tab_groups_java",
     "//third_party/androidx:androidx_annotation_annotation_java",
-    "//third_party/androidx:androidx_collection_collection_java",
   ]
 }
 
 robolectric_library("junit") {
   sources = [
-    "junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupColorUtilsUnitTest.java",
     "junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java",
     "junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupTitleUtilsUnitTest.java",
   ]
@@ -45,7 +41,6 @@
     "//chrome/test/android:chrome_java_unit_test_support",
     "//third_party/android_deps:espresso_java",
     "//third_party/androidx:androidx_annotation_annotation_java",
-    "//third_party/androidx:androidx_collection_collection_java",
     "//third_party/hamcrest:hamcrest_core_java",
     "//third_party/jni_zero:jni_zero_java",
     "//third_party/junit",
diff --git a/chrome/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupColorUtils.java b/chrome/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupColorUtils.java
deleted file mode 100644
index 0457d57..0000000
--- a/chrome/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupColorUtils.java
+++ /dev/null
@@ -1,169 +0,0 @@
-// Copyright 2024 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.tasks.tab_groups;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-import androidx.collection.ArrayMap;
-
-import org.chromium.base.ContextUtils;
-import org.chromium.chrome.browser.tab.Tab;
-import org.chromium.components.tab_groups.TabGroupColorId;
-
-import java.util.Map;
-import java.util.Set;
-
-/** Helper class to handle tab group color related utilities. */
-public class TabGroupColorUtils {
-    private static final String TAB_GROUP_COLORS_FILE_NAME = "tab_group_colors";
-    private static final String MIGRATION_CHECK = "migration_check";
-    private static final int INVALID_COLOR_ID = -1;
-    private static final int MIGRATION_NOT_DONE = 0;
-    private static final int MIGRATION_DONE = 1;
-
-    /**
-     * This method stores tab group colors with reference to {@code tabRootId}.
-     *
-     * @param tabRootId The tab root ID which is used as a reference to store group colors.
-     * @param color The tab group color {@link TabGroupColorId} to store.
-     */
-    public static void storeTabGroupColor(int tabRootId, int color) {
-        assert tabRootId != Tab.INVALID_TAB_ID;
-        getSharedPreferences().edit().putInt(String.valueOf(tabRootId), color).apply();
-    }
-
-    /**
-     * This method deletes a specific stored tab group color with reference to {@code tabRootId}.
-     *
-     * @param tabRootId The tab root ID whose related tab group color will be deleted.
-     */
-    public static void deleteTabGroupColor(int tabRootId) {
-        assert tabRootId != Tab.INVALID_TAB_ID;
-        getSharedPreferences().edit().remove(String.valueOf(tabRootId)).apply();
-    }
-
-    /**
-     * This method fetches tab group colors for the related tab group root ID.
-     *
-     * @param tabRootId The tab root ID whose related tab group color will be fetched.
-     * @return The stored color of the target tab group, default value is -1 (INVALID_COLOR_ID).
-     */
-    public static int getTabGroupColor(int tabRootId) {
-        assert tabRootId != Tab.INVALID_TAB_ID;
-        return getSharedPreferences().getInt(String.valueOf(tabRootId), INVALID_COLOR_ID);
-    }
-
-    /**
-     * This method assigns a color to all tab groups which do not have an assigned tab color at
-     * startup. If a migration for all existing tabs has already been performed, skip this logic.
-     *
-     * @param tabGroupModelFilter The {@TabGroupModelFilter} that governs the current tab groups.
-     */
-    public static void assignTabGroupColorsIfApplicable(TabGroupModelFilter tabGroupModelFilter) {
-        // TODO(b/41490324): Consider removing the migration logic when tab group colors are
-        // launched. There may be an argument to keep this around in case the color info is somehow
-        // lost between startups, in which case this will at least set some default colors up. In
-        // theory, once the migrations have been applied to everyone there won't be a need for this.
-        //
-        // If the migration is already done, skip the below logic.
-        if (getSharedPreferences().getInt(MIGRATION_CHECK, MIGRATION_NOT_DONE) == MIGRATION_DONE) {
-            return;
-        }
-
-        Map<Integer, Integer> currentColorCountMap = getCurrentColorCountMap(tabGroupModelFilter);
-        Set<Integer> rootIds = tabGroupModelFilter.getAllTabGroupRootIds();
-
-        // Assign a color to all tab groups that don't have a color.
-        for (Integer rootId : rootIds) {
-            int colorId = getTabGroupColor(rootId);
-
-            // Retrieve the next suggested colorId if the current tab group does not have a color.
-            if (colorId == INVALID_COLOR_ID) {
-                int suggestedColorId = getNextSuggestedColorId(currentColorCountMap);
-                storeTabGroupColor(rootId, suggestedColorId);
-                currentColorCountMap.put(
-                        suggestedColorId, currentColorCountMap.get(suggestedColorId) + 1);
-            }
-        }
-
-        // Mark that the initial migration of tab colors is complete.
-        getSharedPreferences().edit().putInt(MIGRATION_CHECK, MIGRATION_DONE).apply();
-    }
-
-    /**
-     * This method returns the next suggested colorId to be assigned to a tab group if that tab
-     * group has no color assigned to it. This algorithm uses a key-value map to store all usage
-     * counts of the current list of colors in other tab groups. It will select the least used color
-     * that appears first in the color list. The suggested color value should be a color id of type
-     * {@link TabGroupColorId}.
-     *
-     * @param tabGroupModelFilter The {@link TabGroupModelFilter} that governs all tab groups.
-     */
-    public static int getNextSuggestedColorId(TabGroupModelFilter tabGroupModelFilter) {
-        // Generate the currentColorCountMap.
-        Map<Integer, Integer> currentColorCountMap = getCurrentColorCountMap(tabGroupModelFilter);
-        return getNextSuggestedColorId(currentColorCountMap);
-    }
-
-    /**
-     * This method removes the shared preference file. TODO(b/41490324): Consider removing this when
-     * the feature is launched.
-     */
-    public static void clearTabGroupColorInfo() {
-        ContextUtils.getApplicationContext().deleteSharedPreferences(TAB_GROUP_COLORS_FILE_NAME);
-    }
-
-    private static SharedPreferences getSharedPreferences() {
-        return ContextUtils.getApplicationContext()
-                .getSharedPreferences(TAB_GROUP_COLORS_FILE_NAME, Context.MODE_PRIVATE);
-    }
-
-    /** Get a map that indicates the current usage count of each tab group color. */
-    private static Map<Integer, Integer> getCurrentColorCountMap(
-            TabGroupModelFilter tabGroupModelFilter) {
-        int colorListSize = TabGroupColorId.NUM_ENTRIES;
-        Map<Integer, Integer> colorCountMap = new ArrayMap<>(colorListSize);
-        for (int i = 0; i < colorListSize; i++) {
-            colorCountMap.put(i, 0);
-        }
-
-        Set<Integer> rootIds = tabGroupModelFilter.getAllTabGroupRootIds();
-
-        // Filter all tab groups for ones that already have a color assigned.
-        for (Integer rootId : rootIds) {
-            int colorId = getTabGroupColor(rootId);
-
-            // If the tab group has a color stored on shared prefs, increment the colorId map count.
-            if (colorId != INVALID_COLOR_ID) {
-                colorCountMap.put(colorId, colorCountMap.get(colorId) + 1);
-            }
-        }
-
-        return colorCountMap;
-    }
-
-    /** Impl of getNextSuggestedColorId which assumes a currentColorCountMap has been created. */
-    private static int getNextSuggestedColorId(Map<Integer, Integer> currentColorCountMap) {
-        int colorId = Integer.MAX_VALUE;
-        int colorCount = Integer.MAX_VALUE;
-
-        for (Map.Entry<Integer, Integer> entry : currentColorCountMap.entrySet()) {
-            if (entry.getValue() < colorCount) {
-                colorCount = entry.getValue();
-                colorId = entry.getKey();
-            } else if (entry.getValue() == colorCount) {
-                if (entry.getKey() < colorId) {
-                    colorId = entry.getKey();
-                }
-            }
-        }
-
-        // Assert that the current color count map exists and sets a valid colorId on loop
-        // iteration, otherwise default to an invalid colorId.
-        assert colorId != Integer.MAX_VALUE;
-        return colorId != Integer.MAX_VALUE ? colorId : INVALID_COLOR_ID;
-    }
-}
diff --git a/chrome/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilter.java b/chrome/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilter.java
index 28cb27d6f5..6688c35 100644
--- a/chrome/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilter.java
+++ b/chrome/browser/tab_group/java/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilter.java
@@ -9,7 +9,6 @@
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.annotation.VisibleForTesting;
-import androidx.collection.ArraySet;
 
 import org.chromium.base.MathUtils;
 import org.chromium.base.ObserverList;
@@ -1022,20 +1021,6 @@
         super.didMoveTab(tab, newIndex, curIndex);
     }
 
-    /** Get all tab group root ids that are associated with tab groups greater than size 1. */
-    public Set<Integer> getAllTabGroupRootIds() {
-        Set<Integer> uniqueTabGroupRootIds = new ArraySet<>();
-        TabList tabList = getTabModel();
-
-        for (int i = 0; i < tabList.getCount(); i++) {
-            Tab tab = tabList.getTabAt(i);
-            if (isTabInTabGroup(tab)) {
-                uniqueTabGroupRootIds.add(tab.getRootId());
-            }
-        }
-        return uniqueTabGroupRootIds;
-    }
-
     private boolean isMoveTabOutOfGroup(Tab movedTab) {
         return !mRootIdToGroupMap.containsKey(movedTab.getRootId());
     }
diff --git a/chrome/browser/tab_group/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupColorUtilsUnitTest.java b/chrome/browser/tab_group/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupColorUtilsUnitTest.java
deleted file mode 100644
index cfda4da..0000000
--- a/chrome/browser/tab_group/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupColorUtilsUnitTest.java
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright 2024 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package org.chromium.chrome.browser.tasks.tab_groups;
-
-import static androidx.test.espresso.matcher.ViewMatchers.assertThat;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-
-import androidx.collection.ArraySet;
-
-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;
-import org.robolectric.annotation.Config;
-
-import org.chromium.base.ContextUtils;
-import org.chromium.base.test.BaseRobolectricTestRunner;
-import org.chromium.base.test.util.Features;
-
-import java.util.Set;
-
-/** Tests for {@link TabGroupColorUtils}. */
-@RunWith(BaseRobolectricTestRunner.class)
-@Config(manifest = Config.NONE)
-public class TabGroupColorUtilsUnitTest {
-    @Rule public TestRule mProcessor = new Features.JUnitProcessor();
-
-    private static final String TAB_GROUP_COLORS_FILE_NAME = "tab_group_colors";
-    private static final String MIGRATION_CHECK = "migration_check";
-    private static final int INVALID_COLOR_ID = -1;
-    private static final int MIGRATION_DONE = 1;
-
-    private static final int ROOT_ID_1 = 123;
-    private static final int ROOT_ID_2 = 456;
-    private static final int ROOT_ID_3 = 789;
-    private static final int ROOT_ID_4 = 147;
-    private static final int ROOT_ID_5 = 258;
-    private static final int ROOT_ID_6 = 369;
-    private static final int ROOT_ID_7 = 159;
-    private static final int ROOT_ID_8 = 160;
-    private static final int ROOT_ID_9 = 161;
-    private static final int ROOT_ID_10 = 162;
-    private static final int COLOR_1 = 0;
-    private static final int COLOR_2 = 1;
-    private static final int COLOR_3 = 2;
-    private static final int COLOR_4 = 3;
-    private static final int COLOR_5 = 4;
-    private static final int COLOR_6 = 5;
-    private static final int COLOR_7 = 6;
-    private static final int COLOR_8 = 7;
-    private static final int COLOR_9 = 8;
-
-    @Mock Context mContext;
-    @Mock TabGroupModelFilter mFilter;
-    @Mock SharedPreferences mSharedPreferences;
-    @Mock SharedPreferences.Editor mEditor;
-    @Mock SharedPreferences.Editor mPutIntEditor;
-    @Mock SharedPreferences.Editor mRemoveEditor;
-
-    @Before
-    public void setUp() {
-        MockitoAnnotations.initMocks(this);
-
-        doReturn(mSharedPreferences)
-                .when(mContext)
-                .getSharedPreferences(TAB_GROUP_COLORS_FILE_NAME, Context.MODE_PRIVATE);
-        doReturn(mEditor).when(mSharedPreferences).edit();
-        doReturn(mRemoveEditor).when(mEditor).remove(any(String.class));
-        doReturn(mPutIntEditor).when(mEditor).putInt(any(String.class), any(Integer.class));
-        ContextUtils.initApplicationContextForTests(mContext);
-    }
-
-    @Test
-    public void testDeleteTabGroupColor() {
-        TabGroupColorUtils.deleteTabGroupColor(ROOT_ID_1);
-
-        verify(mEditor).remove(eq(String.valueOf(ROOT_ID_1)));
-        verify(mRemoveEditor).apply();
-    }
-
-    @Test
-    public void testGetTabGroupColor() {
-        // Mock that we have a stored tab group color with reference to ROOT_ID.
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_1), INVALID_COLOR_ID))
-                .thenReturn(COLOR_1);
-
-        assertThat(TabGroupColorUtils.getTabGroupColor(ROOT_ID_1), equalTo(COLOR_1));
-    }
-
-    @Test
-    public void testStoreTabGroupColor() {
-        TabGroupColorUtils.storeTabGroupColor(ROOT_ID_1, COLOR_1);
-
-        verify(mEditor).putInt(eq(String.valueOf(ROOT_ID_1)), eq(COLOR_1));
-        verify(mPutIntEditor).apply();
-    }
-
-    @Test
-    public void testAssignDefaultTabGroupColors() {
-        Set<Integer> rootIdsSet = new ArraySet<>();
-        rootIdsSet.add(ROOT_ID_1);
-        rootIdsSet.add(ROOT_ID_2);
-        rootIdsSet.add(ROOT_ID_3);
-
-        when(mFilter.getAllTabGroupRootIds()).thenReturn(rootIdsSet);
-        // Mock that there is no stored tab group color for these root ids.
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_1), INVALID_COLOR_ID))
-                .thenReturn(INVALID_COLOR_ID);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_2), INVALID_COLOR_ID))
-                .thenReturn(INVALID_COLOR_ID);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_3), INVALID_COLOR_ID))
-                .thenReturn(INVALID_COLOR_ID);
-
-        TabGroupColorUtils.assignTabGroupColorsIfApplicable(mFilter);
-
-        // Test the scenario where no tab groups have colors so the first colors in order are
-        // assigned.
-        verify(mEditor).putInt(eq(String.valueOf(ROOT_ID_1)), eq(COLOR_1));
-        verify(mEditor).putInt(eq(String.valueOf(ROOT_ID_2)), eq(COLOR_2));
-        verify(mEditor).putInt(eq(String.valueOf(ROOT_ID_3)), eq(COLOR_3));
-        verify(mEditor).putInt(eq(MIGRATION_CHECK), eq(MIGRATION_DONE));
-        verify(mPutIntEditor, times(4)).apply();
-    }
-
-    @Test
-    public void testNextSuggestedColorFirstAndThird() {
-        Set<Integer> rootIdsSet = new ArraySet<>();
-        rootIdsSet.add(ROOT_ID_1);
-        rootIdsSet.add(ROOT_ID_2);
-
-        when(mFilter.getAllTabGroupRootIds()).thenReturn(rootIdsSet);
-        // Mock that the first and third colors already exist.
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_1), INVALID_COLOR_ID))
-                .thenReturn(COLOR_1);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_2), INVALID_COLOR_ID))
-                .thenReturn(COLOR_3);
-
-        assertEquals(COLOR_2, TabGroupColorUtils.getNextSuggestedColorId(mFilter));
-    }
-
-    @Test
-    public void testNextSuggestedColorDoubleFirstAndSecond() {
-        Set<Integer> rootIdsSet = new ArraySet<>();
-        rootIdsSet.add(ROOT_ID_1);
-        rootIdsSet.add(ROOT_ID_2);
-        rootIdsSet.add(ROOT_ID_3);
-
-        when(mFilter.getAllTabGroupRootIds()).thenReturn(rootIdsSet);
-        // Mock that the first and second colors already exist.
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_1), INVALID_COLOR_ID))
-                .thenReturn(COLOR_1);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_2), INVALID_COLOR_ID))
-                .thenReturn(COLOR_1);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_3), INVALID_COLOR_ID))
-                .thenReturn(COLOR_2);
-
-        assertEquals(COLOR_3, TabGroupColorUtils.getNextSuggestedColorId(mFilter));
-    }
-
-    @Test
-    public void testNextSuggestedColorSecondColor() {
-        Set<Integer> rootIdsSet = new ArraySet<>();
-        rootIdsSet.add(ROOT_ID_1);
-
-        when(mFilter.getAllTabGroupRootIds()).thenReturn(rootIdsSet);
-        // Mock that only the second color already exists.
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_1), INVALID_COLOR_ID))
-                .thenReturn(COLOR_2);
-
-        assertEquals(COLOR_1, TabGroupColorUtils.getNextSuggestedColorId(mFilter));
-    }
-
-    @Test
-    public void testNextSuggestedColorAllColorsUsed() {
-        Set<Integer> rootIdsSet = new ArraySet<>();
-        rootIdsSet.add(ROOT_ID_1);
-        rootIdsSet.add(ROOT_ID_2);
-        rootIdsSet.add(ROOT_ID_3);
-        rootIdsSet.add(ROOT_ID_4);
-        rootIdsSet.add(ROOT_ID_5);
-        rootIdsSet.add(ROOT_ID_6);
-        rootIdsSet.add(ROOT_ID_7);
-        rootIdsSet.add(ROOT_ID_8);
-        rootIdsSet.add(ROOT_ID_9);
-
-        when(mFilter.getAllTabGroupRootIds()).thenReturn(rootIdsSet);
-        // Mock that all colors are used.
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_1), INVALID_COLOR_ID))
-                .thenReturn(COLOR_1);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_2), INVALID_COLOR_ID))
-                .thenReturn(COLOR_2);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_3), INVALID_COLOR_ID))
-                .thenReturn(COLOR_3);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_4), INVALID_COLOR_ID))
-                .thenReturn(COLOR_4);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_5), INVALID_COLOR_ID))
-                .thenReturn(COLOR_5);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_6), INVALID_COLOR_ID))
-                .thenReturn(COLOR_6);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_7), INVALID_COLOR_ID))
-                .thenReturn(COLOR_7);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_8), INVALID_COLOR_ID))
-                .thenReturn(COLOR_8);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_9), INVALID_COLOR_ID))
-                .thenReturn(COLOR_9);
-
-        assertEquals(COLOR_1, TabGroupColorUtils.getNextSuggestedColorId(mFilter));
-    }
-
-    @Test
-    public void testNextSuggestedColorContinuousSuggestion() {
-        Set<Integer> rootIdsSet = new ArraySet<>();
-        rootIdsSet.add(ROOT_ID_1);
-        rootIdsSet.add(ROOT_ID_2);
-        rootIdsSet.add(ROOT_ID_3);
-        rootIdsSet.add(ROOT_ID_4);
-        rootIdsSet.add(ROOT_ID_5);
-        rootIdsSet.add(ROOT_ID_6);
-        rootIdsSet.add(ROOT_ID_7);
-        rootIdsSet.add(ROOT_ID_8);
-
-        when(mFilter.getAllTabGroupRootIds()).thenReturn(rootIdsSet);
-        // Mock that all colors are used except for COLOR_8.
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_1), INVALID_COLOR_ID))
-                .thenReturn(COLOR_1);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_2), INVALID_COLOR_ID))
-                .thenReturn(COLOR_2);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_3), INVALID_COLOR_ID))
-                .thenReturn(COLOR_3);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_4), INVALID_COLOR_ID))
-                .thenReturn(COLOR_4);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_5), INVALID_COLOR_ID))
-                .thenReturn(COLOR_5);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_6), INVALID_COLOR_ID))
-                .thenReturn(COLOR_6);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_7), INVALID_COLOR_ID))
-                .thenReturn(COLOR_7);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_8), INVALID_COLOR_ID))
-                .thenReturn(COLOR_9);
-
-        assertEquals(COLOR_8, TabGroupColorUtils.getNextSuggestedColorId(mFilter));
-
-        // Mock that subsequent addition of the missing color directs the suggestion to COLOR_1.
-        rootIdsSet.add(ROOT_ID_9);
-        when(mFilter.getAllTabGroupRootIds()).thenReturn(rootIdsSet);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_9), INVALID_COLOR_ID))
-                .thenReturn(COLOR_8);
-        assertEquals(COLOR_1, TabGroupColorUtils.getNextSuggestedColorId(mFilter));
-
-        // Mock that subsequent addition of the first color directs the suggestion to COLOR_2.
-        rootIdsSet.add(ROOT_ID_10);
-        when(mFilter.getAllTabGroupRootIds()).thenReturn(rootIdsSet);
-        when(mSharedPreferences.getInt(String.valueOf(ROOT_ID_10), INVALID_COLOR_ID))
-                .thenReturn(COLOR_1);
-        assertEquals(COLOR_2, TabGroupColorUtils.getNextSuggestedColorId(mFilter));
-    }
-}
diff --git a/chrome/browser/tab_group/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java b/chrome/browser/tab_group/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java
index 2e5e009..af846e8f 100644
--- a/chrome/browser/tab_group/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java
+++ b/chrome/browser/tab_group/junit/src/org/chromium/chrome/browser/tasks/tab_groups/TabGroupModelFilterUnitTest.java
@@ -30,7 +30,6 @@
 import android.content.SharedPreferences;
 
 import androidx.annotation.Nullable;
-import androidx.collection.ArraySet;
 
 import org.junit.Before;
 import org.junit.Rule;
@@ -64,7 +63,6 @@
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import java.util.Set;
 
 /** Tests for {@link TabGroupModelFilter}. */
 @SuppressWarnings("ResultOfMethodCallIgnored")
@@ -1767,15 +1765,4 @@
         assertTrue(mTabGroupModelFilter.tabGroupExistsForRootId(mTab3.getRootId()));
         assertTrue(mTabGroupModelFilter.tabGroupExistsForRootId(mTab5.getRootId()));
     }
-
-    @Test
-    public void testGetAllTabGroupRootIds() {
-        // With the given setup, mTab2 and mTab3 are in a group and mTab5 and mTab6 are in another
-        // group.
-        Set<Integer> rootIds = new ArraySet<>();
-        rootIds.add(mTab2.getRootId());
-        rootIds.add(mTab5.getRootId());
-
-        assertEquals(rootIds, mTabGroupModelFilter.getAllTabGroupRootIds());
-    }
 }