chromium/ui/views/bubble/bubble_frame_view_unittest.cc

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

#include "ui/views/bubble/bubble_frame_view.h"

#include <algorithm>
#include <memory>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/mojom/dialog_button.mojom.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/text_utils.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/bubble/bubble_border.h"
#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/bubble/footnote_container_view.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/metrics.h"
#include "ui/views/test/button_test_api.h"
#include "ui/views/test/test_layout_provider.h"
#include "ui/views/test/test_views.h"
#include "ui/views/test/view_metadata_test_utils.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/widget_interactive_uitest_utils.h"
#include "ui/views/window/dialog_client_view.h"

namespace views {

namespace {

constexpr BubbleBorder::Arrow kArrow =;
constexpr int kMargin =;
constexpr gfx::Size kMinimumClientSize =;
constexpr gfx::Size kPreferredClientSize =;
constexpr gfx::Size kMaximumClientSize =;

// These account for non-client areas like the title bar, footnote etc. However
// these do not take the bubble border into consideration.
gfx::Size AddAdditionalSize(gfx::Size size) {}

class TestBubbleFrameViewWidgetDelegate : public WidgetDelegate {};

class TestBubbleFrameView : public BubbleFrameView {};

}  // namespace

class BubbleFrameViewTest : public ViewsTestBase {};

TEST_F(BubbleFrameViewTest, GetBoundsForClientView) {}

TEST_F(BubbleFrameViewTest, GetBoundsForClientViewWithClose) {}

TEST_F(BubbleFrameViewTest, RemoveFootnoteView) {}

TEST_F(BubbleFrameViewTest,
       FootnoteContainerViewShouldMatchVisibilityOfFirstChild) {}

// Tests that the arrow is mirrored as needed to better fit the screen.
TEST_F(BubbleFrameViewTest, GetUpdatedWindowBounds) {}

// Tests that the arrow is not moved when the info-bubble does not fit the
// screen but moving it would make matter worse.
TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsMirroringFails) {}

TEST_F(BubbleFrameViewTest, TestMirroringForCenteredArrow) {}

// Test that the arrow will not be mirrored when
// |adjust_to_fit_available_bounds| is false.
TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsDontTryMirror) {}

// Test that the center arrow is moved as needed to fit the screen.
TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsCenterArrows) {}

// Tests that the arrow is mirrored as needed to better fit the anchor window's
// bounds.
TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsForBubbleWithAnchorWindow) {}

// Tests that the arrow is mirrored as needed to better fit the screen.
TEST_F(BubbleFrameViewTest,
       GetUpdatedWindowBoundsForBubbleWithAnchorWindowExitingScreen) {}

// Tests that bubbles with `use_anchor_window_bounds_` set to false will not
// apply an offset to try to make them fit inside the anchor window bounds.
TEST_F(BubbleFrameViewTest, BubbleNotUsingAnchorWindowBounds) {}

// Tests that the arrow is mirrored as needed to better fit the anchor window's
// bounds.
TEST_F(BubbleFrameViewTest, MirroringNotStickyForGetUpdatedWindowBounds) {}

// Tests that the arrow is offset as needed to better fit the window.
TEST_F(BubbleFrameViewTest, GetUpdatedWindowBoundsForBubbleSetToOffset) {}

// Tests that the arrow is offset as needed to better fit the window for
// windows larger than the available bounds.
TEST_F(BubbleFrameViewTest,
       GetUpdatedWindowBoundsForBubbleSetToOffsetLargerThanAvailableBounds) {}

TEST_F(BubbleFrameViewTest, GetPreferredSize) {}

TEST_F(BubbleFrameViewTest, GetPreferredSizeWithFootnote) {}

TEST_F(BubbleFrameViewTest, GetMinimumSize) {}

TEST_F(BubbleFrameViewTest, GetMaximumSize) {}

TEST_F(BubbleFrameViewTest, LayoutWithHeader) {}

TEST_F(BubbleFrameViewTest, LayoutWithHeaderAndCloseButton) {}

TEST_F(BubbleFrameViewTest, MetadataTest) {}

namespace {

class TestBubbleDialogDelegateView : public BubbleDialogDelegateView {};

BEGIN_METADATA()

class TestAnchor {};

// BubbleDialogDelegate with no margins to test width snapping.
class TestWidthSnapDelegate : public TestBubbleDialogDelegateView {};

BEGIN_METADATA()

}  // namespace

// This test ensures that if the installed LayoutProvider snaps dialog widths,
// BubbleFrameView correctly sizes itself to that width.
TEST_F(BubbleFrameViewTest, WidthSnaps) {}

// Tests edge cases when the frame's title view starts to wrap text. This is to
// ensure that the calculations BubbleFrameView does to determine the Widget
// size for a given client view are consistent with the eventual size that the
// client view takes after layout.
TEST_F(BubbleFrameViewTest, LayoutEdgeCases) {}

// Tests edge cases when the frame's title view starts to wrap text when a
// header view is set. This is to ensure the title leaves enough space for the
// close button when there is a header or not.
TEST_F(BubbleFrameViewTest, LayoutEdgeCasesWithHeader) {}

// Layout tests with Subtitle label.
// This will test adding a Subtitle and wrap-around case for Subtitle.
TEST_F(BubbleFrameViewTest, LayoutSubtitleEdgeCases) {}

TEST_F(BubbleFrameViewTest, LayoutWithIcon) {}

// Test the size of the bubble allows a |gfx::NO_ELIDE| title to fit, even if
// there is no content.
TEST_F(BubbleFrameViewTest, NoElideTitle) {}

TEST_F(BubbleFrameViewTest, LabelWithHeadingLevel) {}

// Ensures that clicks are ignored for short time after view has been shown.
TEST_F(BubbleFrameViewTest, IgnorePossiblyUnintendedClicksClose) {}

// Ensures that clicks are ignored for short time after view has been shown.
TEST_F(BubbleFrameViewTest, IgnorePossiblyUnintendedClicksMinimize) {}

// Ensures that clicks are ignored for short time after anchor view bounds
// changed.
TEST_F(BubbleFrameViewTest, IgnorePossiblyUnintendedClicksAnchorBoundsChanged) {}

// Ensures that layout is correct when the progress indicator is visible.
TEST_F(BubbleFrameViewTest, LayoutWithProgressIndicator) {}

// Close should be the next element after minimize.
TEST_F(BubbleFrameViewTest, MinimizeBeforeClose) {}

}  // namespace views