chromium/chrome/browser/ui/views/user_education/help_bubble_view_interactive_uitest.cc

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

#include <array>
#include <memory>
#include <vector>

#include "build/build_config.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/contents_web_view.h"
#include "chrome/browser/ui/views/tabs/tab_group_header.h"
#include "chrome/browser/ui/views/toolbar/toolbar_view.h"
#include "chrome/browser/ui/views/user_education/browser_help_bubble_event_relay.h"
#include "chrome/browser/ui/views/user_education/browser_user_education_service.h"
#include "chrome/browser/user_education/user_education_service.h"
#include "chrome/browser/user_education/user_education_service_factory.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/interaction/interactive_browser_test.h"
#include "components/user_education/common/help_bubble.h"
#include "components/user_education/common/help_bubble_factory.h"
#include "components/user_education/common/help_bubble_factory_registry.h"
#include "components/user_education/common/help_bubble_params.h"
#include "components/user_education/views/help_bubble_delegate.h"
#include "components/user_education/views/help_bubble_factory_views.h"
#include "components/user_education/views/help_bubble_view.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/expect_call_in_scope.h"
#include "ui/base/interaction/framework_specific_implementation.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/gfx/geometry/size.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/interaction/element_tracker_views.h"
#include "ui/views/interaction/interaction_test_util_views.h"
#include "ui/views/interaction/widget_focus_observer.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_utils.h"

HelpBubbleArrow;
HelpBubbleParams;
HelpBubbleView;

namespace  // namespace

class HelpBubbleViewInteractiveUiTest : public InteractiveBrowserTest {};

IN_PROC_BROWSER_TEST_F(HelpBubbleViewInteractiveUiTest,
                       WidgetNotActivatedByDefault) {}

// This is a regression test to ensure that help bubbles prevent other bubbles
// they are anchored to from closing on loss of focus. Failing to do this
// results in situations where a user can abort a user education journey by
// entering accessible keyboard navigation commands to try to read the help
// bubble, or by trying to interact with the help bubble with the mouse to e.g.
// close it.
IN_PROC_BROWSER_TEST_F(HelpBubbleViewInteractiveUiTest,
                       BubblePreventsCloseOnLossOfFocus) {}

IN_PROC_BROWSER_TEST_F(HelpBubbleViewInteractiveUiTest,
                       ElementIdentifierFindsButton) {}

namespace {

constexpr char kLinuxWaylandErrorMessage[] =;

// Determines whether the current system is Linux + Wayland and the current test
// should be skipped for reasons described in the error message above.
bool SkipIfLinuxWayland() {}

}  // namespace

#if BUILDFLAG(IS_LINUX)
// For some reason, windows in Linux builds tend to either move around or
// misreport their positions; it's not clear why this happens, but it can
// (rarely) cause the test to flake. See e.g. crbug.com/349545780.
#define MAYBE_AnnotateMenu
#else
#define MAYBE_AnnotateMenu
#endif
// This is a combined test for both help bubbles anchored to menus and menu
// annotation.
IN_PROC_BROWSER_TEST_F(HelpBubbleViewInteractiveUiTest, MAYBE_AnnotateMenu) {}

// Verifies that we can safely show and then close two help bubbles attached to
// the same menu. This may happen transiently during tutorials.
IN_PROC_BROWSER_TEST_F(HelpBubbleViewInteractiveUiTest, TwoMenuHelpBubbles) {}

// Verifies that a help bubble can attach to a bubble which cannot activate or
// receive events, and that events are still routed correctly to the help
// bubble.
#if BUILDFLAG(IS_LINUX)
// For some reason, windows in Linux builds tend to either move around or
// misreport their positions; it's not clear why this happens, but it can
// (rarely) cause the test to flake. See e.g. crbug.com/349545780.
#define MAYBE_AnchorToTransparentBubble
#else
#define MAYBE_AnchorToTransparentBubble
#endif
IN_PROC_BROWSER_TEST_F(HelpBubbleViewInteractiveUiTest,
                       MAYBE_AnchorToTransparentBubble) {}