chromium/components/user_education/views/help_bubble_view_unittest.cc

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

#include "components/user_education/views/help_bubble_view.h"

#include <memory>
#include <vector>

#include "base/functional/bind.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/test/mock_callback.h"
#include "components/user_education/common/events.h"
#include "components/user_education/common/feature_promo_specification.h"
#include "components/user_education/common/help_bubble.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_views_test_util.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/interaction/element_identifier.h"
#include "ui/base/interaction/element_test_util.h"
#include "ui/base/interaction/element_tracker.h"
#include "ui/base/interaction/expect_call_in_scope.h"
#include "ui/base/interaction/interaction_test_util.h"
#include "ui/base/theme_provider.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/interaction/interaction_test_util_views.h"
#include "ui/views/layout/flex_layout_view.h"
#include "ui/views/layout/layout_types.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/test/views_test_utils.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_observer.h"

namespace user_education {

namespace {
DEFINE_LOCAL_ELEMENT_IDENTIFIER_VALUE();
const ui::ElementContext kTestElementContext{};
constexpr gfx::Rect kWidgetBounds{};
}  // namespace

// Unit tests for HelpBubbleView. Timeout functionality isn't tested here due to
// the vagaries of trying to get simulated timed events to run without a full
// execution environment (specifically, Mac tests were extremely flaky without
// the browser).
//
// Timeouts are tested in:
// chrome/browser/ui/views/user_education/help_bubble_view_timeout_unittest.cc
class HelpBubbleViewTest : public views::ViewsTestBase {};

TEST_F(HelpBubbleViewTest, DefaultMaxWidth) {}

TEST_F(HelpBubbleViewTest, ExpandedMaxWidth) {}

TEST_F(HelpBubbleViewTest, CallButtonCallback_Mouse) {}

TEST_F(HelpBubbleViewTest, CallButtonCallback_Keyboard) {}

TEST_F(HelpBubbleViewTest, StableButtonOrder) {}

TEST_F(HelpBubbleViewTest, AnchorToRect) {}

TEST_F(HelpBubbleViewTest, AnchorRectUpdated) {}

TEST_F(HelpBubbleViewTest, ScrollAnchorViewToVisible) {}

class HelpBubbleViewsTest : public HelpBubbleViewTest {};

// This duplicates the HelpBubbleViewTest, but with a HelpBubbleViews object.
TEST_F(HelpBubbleViewsTest, AnchorToRect) {}

// This duplicates the HelpBubbleViewTest, but with a HelpBubbleViews object.
TEST_F(HelpBubbleViewsTest, AnchorRectUpdated) {}

// This checks a case where the target anchor region scrolls partially out of
// the host view. The anchor rect should be the intersection of the two.
TEST_F(HelpBubbleViewsTest, AnchorRectOverlapsEdge) {}

// This checks a case where the target anchor region scrolls fully out of
// the host view. The anchor rect should be a one-pixel slice on the edge
// closest to the actual anchor.
TEST_F(HelpBubbleViewsTest, AnchorOutsideBoundsHorizontal) {}

// This checks a case where the target anchor region scrolls fully out of
// the host view. The anchor rect should be a one-pixel slice on the edge
// closest to the actual anchor.
TEST_F(HelpBubbleViewsTest, AnchorOutsideBoundsVertical) {}

// Verifies that a bubble anchored to a region will still move with the owning
// Widget.
TEST_F(HelpBubbleViewsTest, MoveAnchorWidget) {}

}  // namespace user_education