chromium/ui/views/controls/button/label_button_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/controls/button/label_button.h"

#include <algorithm>
#include <optional>
#include <string>
#include <utility>

#include "base/command_line.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/actions/actions.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/ui_base_switches.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/image/image_unittest_util.h"
#include "ui/gfx/text_utils.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/animation/ink_drop.h"
#include "ui/views/animation/test/ink_drop_host_test_api.h"
#include "ui/views/animation/test/test_ink_drop.h"
#include "ui/views/border.h"
#include "ui/views/buildflags.h"
#include "ui/views/controls/button/label_button_image_container.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/test/views_test_utils.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/view_test_api.h"
#include "ui/views/view_utils.h"
#include "ui/views/widget/widget_utils.h"

namespace views {

ASCIIToUTF16;

// Testing button that exposes protected methods.
class TestLabelButton : public LabelButton {};

BEGIN_METADATA()

class LabelButtonTest : public test::WidgetTest {};

TEST_F(LabelButtonTest, FocusBehavior) {}

TEST_F(LabelButtonTest, Init) {}

TEST_F(LabelButtonTest, Label) {}

// Tests LabelButton's usage of SetMaximumWidthSingleLine.
TEST_F(LabelButtonTest, LabelPreferredSizeWithMaxWidth) {}

TEST_F(LabelButtonTest, LabelShrinkDown) {}

TEST_F(LabelButtonTest, LabelShrinksDownOnManualSetBounds) {}

TEST_F(LabelButtonTest, LabelShrinksDownCanceledBySettingText) {}

TEST_F(
    LabelButtonTest,
    LabelShrinksDownImmediatelyIfAlreadySmallerThanPreferredSizeWithoutLabel) {}

// Test behavior of ViewAccessibility::GetAccessibleNodeData() for buttons when
// setting a label.
TEST_F(LabelButtonTest, AccessibleState) {}

// Test ViewAccessibility::GetAccessibleNodeData() for default buttons.
TEST_F(LabelButtonTest, AccessibleDefaultState) {}

TEST_F(LabelButtonTest, Image) {}

TEST_F(LabelButtonTest, ImageAlignmentWithMultilineLabel) {}

TEST_F(LabelButtonTest, LabelAndImage) {}

TEST_F(LabelButtonTest, LabelWrapAndImageAlignment) {}

// This test was added because GetHeightForWidth and GetPreferredSize were
// inconsistent. GetPreferredSize would account for image size + insets whereas
// GetHeightForWidth wouldn't. As of writing they share a large chunk of
// logic, but this remains in place so they don't diverge as easily.
TEST_F(LabelButtonTest, GetHeightForWidthConsistentWithGetPreferredSize) {}

// Ensure that the text used for button labels correctly adjusts in response
// to provided style::TextContext values.
TEST_F(LabelButtonTest, TextSizeFromContext) {}

TEST_F(LabelButtonTest, ChangeTextSize) {}

TEST_F(LabelButtonTest, ChangeLabelImageSpacing) {}

// Ensure the label gets the correct style when pressed or becoming default.
TEST_F(LabelButtonTest, HighlightedButtonStyle) {}

// Ensure the label resets the enabled color after LabelButton::OnThemeChanged()
// is invoked.
TEST_F(LabelButtonTest, OnThemeChanged) {}

TEST_F(LabelButtonTest, SetEnabledTextColorsResetsToThemeColors) {}

TEST_F(LabelButtonTest, SetEnabledTextColorIds) {}

TEST_F(LabelButtonTest, ImageOrLabelGetClipped) {}

TEST_F(LabelButtonTest, UpdateImageAfterSettingImageModel) {}

TEST_F(LabelButtonTest, AccessibiltyDefaultState) {}

// Test fixture for a LabelButton that has an ink drop configured.
class InkDropLabelButtonTest : public ViewsTestBase {};

TEST_F(InkDropLabelButtonTest, HoverStateAfterMouseEnterAndExitEvents) {}

// Verifies the target event handler View is the |LabelButton| and not any of
// the child Views.
TEST_F(InkDropLabelButtonTest, TargetEventHandler) {}

class LabelButtonVisualStateTest : public test::WidgetTest {};

TEST_F(LabelButtonVisualStateTest, IndependentWidget) {}

TEST_F(LabelButtonVisualStateTest, ChildWidget) {}

LabelButtonActionViewInterfaceTest;

TEST_F(LabelButtonActionViewInterfaceTest, TestActionChanged) {}

}  // namespace views