#include "ui/views/controls/button/menu_button.h"
#include <memory>
#include <utility>
#include "base/functional/bind.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 "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/test/event_generator.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/controls/button/button.h"
#include "ui/views/controls/button/menu_button_controller.h"
#include "ui/views/drag_controller.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/widget/widget_utils.h"
#if defined(USE_AURA)
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/drag_drop_client_observer.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-shared.h"
#include "ui/events/event.h"
#include "ui/events/event_handler.h"
#endif
namespace views {
ASCIIToUTF16;
DragOperation;
class TestMenuButton : public MenuButton { … };
class MenuButtonTest : public ViewsTestBase { … };
class PressStateButton : public TestMenuButton { … };
class TestDragController : public DragController { … };
#if defined(USE_AURA)
class TestDragDropClient : public aura::client::DragDropClient,
public ui::EventHandler { … };
TestDragDropClient::TestDragDropClient() = default;
TestDragDropClient::~TestDragDropClient() = default;
DragOperation TestDragDropClient::StartDragAndDrop(
std::unique_ptr<ui::OSExchangeData> data,
aura::Window* root_window,
aura::Window* source_window,
const gfx::Point& screen_location,
int allowed_operations,
ui::mojom::DragEventSource source) { … }
void TestDragDropClient::DragCancel() { … }
bool TestDragDropClient::IsDragDropInProgress() { … }
void TestDragDropClient::OnMouseEvent(ui::MouseEvent* event) { … }
#endif
TEST_F(MenuButtonTest, ActivateDropDownOnMouseClick) { … }
TEST_F(MenuButtonTest, ActivateOnKeyPress) { … }
TEST_F(MenuButtonTest, InkDropCenterSetFromClick) { … }
#if BUILDFLAG(IS_CHROMEOS) && defined(MEMORY_SANITIZER)
#define MAYBE_InkDropCenterSetFromClickWithPressedLock …
#else
#define MAYBE_InkDropCenterSetFromClickWithPressedLock …
#endif
TEST_F(MenuButtonTest, MAYBE_InkDropCenterSetFromClickWithPressedLock) { … }
#if BUILDFLAG(IS_CHROMEOS) && defined(MEMORY_SANITIZER)
#define MAYBE_ButtonStateForMenuButtonsWithPressedLocks …
#else
#define MAYBE_ButtonStateForMenuButtonsWithPressedLocks …
#endif
TEST_F(MenuButtonTest, MAYBE_ButtonStateForMenuButtonsWithPressedLocks) { … }
#if BUILDFLAG(IS_CHROMEOS) && defined(MEMORY_SANITIZER)
#define MAYBE_DraggableMenuButtonActivatesOnRelease …
#else
#define MAYBE_DraggableMenuButtonActivatesOnRelease …
#endif
TEST_F(MenuButtonTest, MAYBE_DraggableMenuButtonActivatesOnRelease) { … }
#if BUILDFLAG(IS_CHROMEOS) && defined(MEMORY_SANITIZER)
#define MAYBE_InkDropStateForMenuButtonActivationsWithoutCallback …
#else
#define MAYBE_InkDropStateForMenuButtonActivationsWithoutCallback …
#endif
TEST_F(MenuButtonTest,
MAYBE_InkDropStateForMenuButtonActivationsWithoutCallback) { … }
#if BUILDFLAG(IS_CHROMEOS) && defined(MEMORY_SANITIZER)
#define MAYBE_InkDropStateForMenuButtonActivationsWithCallbackThatDoesntAcquireALock …
#else
#define MAYBE_InkDropStateForMenuButtonActivationsWithCallbackThatDoesntAcquireALock …
#endif
TEST_F(
MenuButtonTest,
MAYBE_InkDropStateForMenuButtonActivationsWithCallbackThatDoesntAcquireALock) { … }
TEST_F(
MenuButtonTest,
InkDropStateForMenuButtonActivationsWithCallbackThatDoesntReleaseAllLocks) { … }
TEST_F(MenuButtonTest,
InkDropStateForMenuButtonActivationsWithCallbackThatReleasesAllLocks) { … }
#if BUILDFLAG(IS_CHROMEOS) && defined(MEMORY_SANITIZER)
#define MAYBE_InkDropStateForMenuButtonsWithPressedLocks …
#else
#define MAYBE_InkDropStateForMenuButtonsWithPressedLocks …
#endif
TEST_F(MenuButtonTest, MAYBE_InkDropStateForMenuButtonsWithPressedLocks) { … }
#if BUILDFLAG(IS_CHROMEOS) && defined(MEMORY_SANITIZER)
#define MAYBE_OneInkDropAnimationForReentrantPressedLocks …
#else
#define MAYBE_OneInkDropAnimationForReentrantPressedLocks …
#endif
TEST_F(MenuButtonTest, MAYBE_OneInkDropAnimationForReentrantPressedLocks) { … }
#if BUILDFLAG(IS_CHROMEOS) && defined(MEMORY_SANITIZER)
#define MAYBE_InkDropStateForMenuButtonWithPressedLockBeforeActivation …
#else
#define MAYBE_InkDropStateForMenuButtonWithPressedLockBeforeActivation …
#endif
TEST_F(MenuButtonTest,
MAYBE_InkDropStateForMenuButtonWithPressedLockBeforeActivation) { … }
#if defined(USE_AURA)
#if BUILDFLAG(IS_CHROMEOS) && defined(MEMORY_SANITIZER)
#define MAYBE_DraggableMenuButtonDoesNotActivateOnDrag …
#else
#define MAYBE_DraggableMenuButtonDoesNotActivateOnDrag …
#endif
TEST_F(MenuButtonTest, MAYBE_DraggableMenuButtonDoesNotActivateOnDrag) { … }
#endif
#if !BUILDFLAG(IS_MAC) || defined(USE_AURA)
TEST_F(MenuButtonTest, ActivateDropDownOnGestureTap) { … }
TEST_F(MenuButtonTest, TouchFeedbackDuringTap) { … }
TEST_F(MenuButtonTest, TouchFeedbackDuringTapCancel) { … }
#endif
TEST_F(MenuButtonTest, InkDropHoverWhenShowingMenu) { … }
TEST_F(MenuButtonTest, InkDropIsHoveredAfterDismissingMenuWhenMouseOverButton) { … }
TEST_F(MenuButtonTest,
InkDropIsntHoveredAfterDismissingMenuWhenMouseOutsideButton) { … }
TEST_F(MenuButtonTest, DestroyButtonInGesture) { … }
TEST_F(MenuButtonTest, AccessibleDefaultActionVerb) { … }
}