chromium/chrome/browser/ui/views/toolbar/toolbar_action_hover_card_bubble_view_interactive_uitest.cc

// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/extensions/permissions/scripting_permissions_modifier.h"
#include "chrome/browser/extensions/permissions/site_permissions_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_container.h"
#include "chrome/browser/ui/views/extensions/extensions_toolbar_interactive_uitest.h"
#include "chrome/browser/ui/views/toolbar/toolbar_action_hover_card_bubble_view.h"
#include "chrome/browser/ui/views/toolbar/toolbar_action_hover_card_controller.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/policy/core/browser/browser_policy_connector.h"
#include "components/policy/core/common/mock_configuration_policy_provider.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/policy_constants.h"
#include "components/sessions/content/session_tab_helper.h"
#include "content/public/browser/web_contents.h"
#include "content/public/test/browser_test.h"
#include "extensions/browser/extension_action_manager.h"
#include "extensions/common/extension_features.h"
#include "extensions/test/permissions_manager_waiter.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/events/types/event_type.h"
#include "ui/gfx/animation/animation_test_api.h"
#include "ui/views/test/widget_test.h"

namespace {

SiteInteraction;

// Similar to views::test::WidgetDestroyedWaiter but waiting after the widget
// has been closed is a no-op rather than an error.
class SafeWidgetDestroyedWaiter : public views::WidgetObserver {};

}  // namespace

class ToolbarActionHoverCardBubbleViewUITest : public ExtensionsToolbarUITest {};

IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewUITest, InvokeUi) {}

// Verify hover card is visible while hovering and not visible outside of the
// extensions container.
IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewUITest,
                       WidgetVisibleOnHover) {}

// Verify hover card content and anchor is correctly updated when moving hover
// from one action view to another. Note that hover card content based on site
// access is tested more in depth in ExtensionActionViewController unittest,
// since such class computes the hover card state.
IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewUITest,
                       WidgetUpdatedWhenHoveringBetweenActionViews) {}

// Verify hover card content is dynamically updated when toolbar action title is
// updated.
IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewUITest,
                       WidgetContentDynamicallyUpdated) {}

// Verify site access content in hover card is dynamically updated when the
// extension site access is updated.
IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewUITest,
                       WidgetContentDynamicallyUpdated_SiteAccessUpdated) {}

// Verify hover card is not visible when mouse moves inside the extensions
// container to a button that is not a toolbar icon view (which has its own
// 'on mouse moved' event listener).
IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewUITest,
                       WidgetNotVisibleOnExtensionsControl) {}

// Verify hover card is not visible after clicking on a toolbar action view.
IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewUITest,
                       WidgetNotVisibleOnToolbarActionViewClick) {}

// Verify hover card is not visible on focus, similar to tooltip behavior.
IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewUITest,
                       WidgetNotVisibleOnFocus) {}

// Verify that the hover card is not visible when any key is pressed.
IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewUITest,
                       WidgetNotVisibleOnAnyKeyPressInSameWindow) {}

class ToolbarActionHoverCardBubbleViewDisabledFeatureUITest
    : public ToolbarActionHoverCardBubbleViewUITest {};

// Verify hover card is not visible on toolbar action view hover when the
// feature is disabled.
IN_PROC_BROWSER_TEST_F(ToolbarActionHoverCardBubbleViewDisabledFeatureUITest,
                       WidgetNotVisibleWhenDisabledFeature) {}