chromium/chrome/browser/ui/views/bookmarks/saved_tab_groups/saved_tab_group_interactive_uitest.cc

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/test/bind.h"
#include "base/test/gtest_util.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_keyed_service.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_service_factory.h"
#include "chrome/browser/ui/tabs/saved_tab_groups/saved_tab_group_utils.h"
#include "chrome/browser/ui/tabs/tab_group.h"
#include "chrome/browser/ui/tabs/tab_group_model.h"
#include "chrome/browser/ui/tabs/tab_menu_model.h"
#include "chrome/browser/ui/toolbar/app_menu_model.h"
#include "chrome/browser/ui/toolbar/bookmark_sub_menu_model.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/bookmarks/saved_tab_groups/saved_tab_group_bar.h"
#include "chrome/browser/ui/views/bookmarks/saved_tab_groups/saved_tab_group_button.h"
#include "chrome/browser/ui/views/bookmarks/saved_tab_groups/saved_tab_group_everything_menu.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/tabs/tab.h"
#include "chrome/browser/ui/views/tabs/tab_group_header.h"
#include "chrome/browser/ui/views/tabs/tab_strip.h"
#include "chrome/test/interaction/interaction_test_util_browser.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "chrome/test/interaction/tracked_element_webcontents.h"
#include "chrome/test/interaction/webcontents_interaction_test_util.h"
#include "components/bookmarks/common/bookmark_pref_names.h"
#include "components/power_bookmarks/core/power_bookmark_features.h"
#include "components/prefs/pref_service.h"
#include "components/saved_tab_groups/features.h"
#include "components/saved_tab_groups/saved_tab_group_model.h"
#include "components/saved_tab_groups/tab_group_sync_service.h"
#include "components/tab_groups/tab_group_color.h"
#include "components/tab_groups/tab_group_id.h"
#include "content/public/test/browser_test.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/interaction/interaction_sequence.h"
#include "ui/base/page_transition_types.h"
#include "ui/base/test/ui_controls.h"
#include "ui/base/ui_base_features.h"
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/test/event_generator.h"
#include "ui/events/types/event_type.h"
#include "ui/views/interaction/element_tracker_views.h"
#include "ui/views/interaction/interaction_test_util_views.h"
#include "ui/views/view_utils.h"
#include "ui/views/widget/widget_utils.h"
#include "url/url_constants.h"

namespace tab_groups {

class SavedTabGroupInteractiveTest
    : public InteractiveBrowserTest,
      public ::testing::WithParamInterface<bool> {};

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest, CreateGroupAndSave) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       UnsaveGroupFromTabGroupHeader) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       UnsaveGroupFromButtonMenu) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest, UnpinGroupFromButtonMenu) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       ContextMenuShowForEverythingMenuTabGroupItem) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       SubmenuShowForAppMenuTabGroups) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       OpenGroupFromAppMenuTabGroupSubmenu) {}

// TODO(crbug.com/40934084): Deflake this test before enabling
#if BUILDFLAG(IS_MAC)
#define MAYBE_MoveGroupToNewWindowFromAppMenuTabGroupSubmenu
#else
#define MAYBE_MoveGroupToNewWindowFromAppMenuTabGroupSubmenu
#endif  // BUILDFLAG(IS_MAC)
IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       MAYBE_MoveGroupToNewWindowFromAppMenuTabGroupSubmenu) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       UnpinGroupFromAppMenuTabGroupSubmenu) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       DeleteGroupFromAppMenuTabGroupSubmenu) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       OpenTabFromAppMenuTabGroupSubmenu) {}

// TODO(crbug.com/40934084): Deflake this test before enabling
#if BUILDFLAG(IS_MAC)
#define MAYBE_MoveGroupToNewWindowFromButtonMenu
#else
#define MAYBE_MoveGroupToNewWindowFromButtonMenu
#endif  // BUILDFLAG(IS_MAC)
IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       MAYBE_MoveGroupToNewWindowFromButtonMenu) {}

IN_PROC_BROWSER_TEST_P(
    SavedTabGroupInteractiveTest,
    MoveGroupToNewWindowFromButtonMenuDoesNothingIfOnlyGroupInWindow) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       FirstTabIsFocusedInReopenedSavedGroup) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       MoveTabInsideAndOutsideGroup) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       UpdateButtonWhenTabGroupVisualDataChanges) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       CreateNewTabGroupFromEverythingMenu) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       OpenSavedGroupFromEverythingMenu) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       CreateNewTabGroupFromAppMenuSubmenu) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       EverythingButtonAlwaysShowsForV2) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       FiveSavedGroupsShowsOverflowMenuButton) {}

// TODO(crbug.com/40264110): Re-enable this test once it doesn't get stuck in
// drag and drop. Maybe related issue - the relative positioning seems to be
// interpreted as an absolute position.
IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       DISABLED_DragGroupWithinBar) {}

IN_PROC_BROWSER_TEST_P(SavedTabGroupInteractiveTest,
                       OverflowMenuClosesWhenNoMoreButtons) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace tab_groups