chromium/ui/views/controls/menu/menu_item_view_unittest.cc

// Copyright 2014 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/menu/menu_item_view.h"

#include <memory>
#include <string>
#include <utility>

#include "base/memory/raw_ptr.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/bind.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/themed_vector_icon.h"
#include "ui/compositor/canvas_painter.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/strings/grit/ui_strings.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/controls/menu/submenu_view.h"
#include "ui/views/controls/menu/test_menu_item_view.h"
#include "ui/views/test/menu_test_utils.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/vector_icons.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_test_api.h"
#include "ui/views/view_utils.h"

namespace views {

MenuItemViewUnitTest;

TEST_F(MenuItemViewUnitTest, AddAndRemoveChildren) {}

namespace {

// A simple View class that will match its height to the available width.
class SquareView : public views::View {};

BEGIN_METADATA()

}  // namespace

TEST_F(MenuItemViewUnitTest, TestMenuItemViewWithFlexibleWidthChild) {}

// Tests that a menu item with hidden children should contain the "(empty)" menu
// item to display.
TEST_F(MenuItemViewUnitTest, TestEmptyWhenAllItemsAreHidden) {}

TEST_F(MenuItemViewUnitTest, UseMnemonicOnPlatform) {}

TEST_F(MenuItemViewUnitTest, NotifiesSelectedChanged) {}

TEST_F(MenuItemViewUnitTest, AccessibleKeyShortcutsTest) {}

class TouchableMenuItemViewTest : public ViewsTestBase {};

// Test that touchable menu items are sized to fit the menu item titles within
// the allowed minimum and maximum width.
TEST_F(TouchableMenuItemViewTest, MinAndMaxWidth) {}

class MenuItemViewLayoutTest : public ViewsTestBase {};

// Tests that MenuItemView takes into account the child's margins and preferred
// size when laying out in container mode.
TEST_F(MenuItemViewLayoutTest, ContainerLayoutRespectsMarginsAndPreferredSize) {}

class MenuItemViewPaintUnitTest : public ViewsTestBase {};

// Provides assertion coverage for painting, secondary label, minor text and
// icons.
TEST_F(MenuItemViewPaintUnitTest, MinorTextAndIconAssertionCoverage) {}

// Provides assertion coverage for painting with custom colors.
// icons.
TEST_F(MenuItemViewPaintUnitTest, CustomColorAssertionCoverage) {}

// Verifies a call to MenuItemView::OnPaint() doesn't trigger a call to
// MenuItemView::submenu_arrow_image_view_::SchedulePaint(). This is a
// regression test for https://crbug.com/1245854.
TEST_F(MenuItemViewPaintUnitTest, DontSchedulePaintFromOnPaint) {}

// Tests to ensure that selection based state is not updated if a menu item or
// an anscestor item has been scheduled for deletion. This guards against
// removed but not-yet-deleted MenuItemViews using stale model data to update
// state.
TEST_F(MenuItemViewPaintUnitTest,
       SelectionBasedStateNotUpdatedWhenScheduledForDeletion) {}

TEST_F(MenuItemViewPaintUnitTest, SelectionBasedStateUpdatedWhenIconChanges) {}

TEST_F(MenuItemViewPaintUnitTest, SelectionBasedStateUpdatedDuringDragAndDrop) {}

TEST_F(MenuItemViewPaintUnitTest, AccessibleCheckedStateChange) {}

// Sets up a custom MenuDelegate that expects functions aren't called. See
// DontAskForFontsWhenAddingSubmenu.
class MenuItemViewAccessTest : public MenuItemViewPaintUnitTest {};

// Verifies AppendSubMenu() doesn't trigger calls to the delegate with the
// command being supplied. The delegate can be called after AppendSubMenu(),
// but not before.
TEST_F(MenuItemViewAccessTest, DontAskForFontsWhenAddingSubmenu) {}

MenuItemViewA11yTest;

// A MenuItemView that has a submenu should open the submenu on kExpand and
// close the submenu on kCollapse.
TEST_F(MenuItemViewA11yTest, HandlesExpandCollapseActions) {}

TEST_F(MenuItemViewA11yTest, AccessibleSelectedTest) {}

}  // namespace views