#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/scoped_observation.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/ui/views/menu_test_base.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom.h"
#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/ozone_buildflags.h"
#include "ui/compositor/layer_tree_owner.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/controls/menu/menu_controller.h"
#include "ui/views/controls/menu/menu_item_view.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/controls/menu/submenu_view.h"
#include "ui/views/view.h"
#include "ui/views/widget/drop_helper.h"
namespace {
DragOperation;
const char16_t kTestNestedDragData[] = …;
const char16_t kTestTopLevelDragData[] = …;
class TestDragView : public views::View { … };
TestDragView::TestDragView() { … }
TestDragView::~TestDragView() { … }
int TestDragView::GetDragOperations(const gfx::Point& point) { … }
void TestDragView::WriteDragData(const gfx::Point& point,
ui::OSExchangeData* data) { … }
BEGIN_METADATA(…)
class TestTargetView : public views::View { … };
void TestTargetView::Init() { … }
bool TestTargetView::GetDropFormats(
int* formats,
std::set<ui::ClipboardFormatType>* format_types) { … }
bool TestTargetView::AreDropTypesRequired() { … }
bool TestTargetView::CanDrop(const OSExchangeData& data) { … }
void TestTargetView::OnDragEntered(const ui::DropTargetEvent& event) { … }
int TestTargetView::OnDragUpdated(const ui::DropTargetEvent& event) { … }
views::View::DropCallback TestTargetView::GetDropCallback(
const ui::DropTargetEvent& event) { … }
void TestTargetView::OnDragExited() { … }
void TestTargetView::PerformDrop(
const ui::DropTargetEvent& event,
ui::mojom::DragOperation& output_drag_op,
std::unique_ptr<ui::LayerTreeOwner> drag_image_layer_owner) { … }
BEGIN_METADATA(…)
}
class MenuViewDragAndDropTest : public MenuTestBase,
public views::WidgetObserver { … };
void MenuViewDragAndDropTest::BuildMenu(views::MenuItemView* menu) { … }
void MenuViewDragAndDropTest::DoTestWithMenuOpen() { … }
void MenuViewDragAndDropTest::TearDown() { … }
void MenuViewDragAndDropTest::OnDragEntered() { … }
bool MenuViewDragAndDropTest::GetDropFormats(
views::MenuItemView* menu,
int* formats,
std::set<ui::ClipboardFormatType>* format_types) { … }
bool MenuViewDragAndDropTest::AreDropTypesRequired(views::MenuItemView* menu) { … }
bool MenuViewDragAndDropTest::CanDrop(views::MenuItemView* menu,
const ui::OSExchangeData& data) { … }
DragOperation MenuViewDragAndDropTest::GetDropOperation(
views::MenuItemView* item,
const ui::DropTargetEvent& event,
DropPosition* position) { … }
views::View::DropCallback MenuViewDragAndDropTest::GetDropCallback(
views::MenuItemView* menu,
DropPosition position,
const ui::DropTargetEvent& event) { … }
bool MenuViewDragAndDropTest::CanDrag(views::MenuItemView* menu) { … }
void MenuViewDragAndDropTest::WriteDragData(
views::MenuItemView* sender, ui::OSExchangeData* data) { … }
int MenuViewDragAndDropTest::GetDragOperations(views::MenuItemView* sender) { … }
bool MenuViewDragAndDropTest::ShouldCloseOnDragComplete() { … }
void MenuViewDragAndDropTest::PerformDrop(
const ui::DropTargetEvent& event,
ui::mojom::DragOperation& output_drag_op,
std::unique_ptr<ui::LayerTreeOwner> drag_image_layer_owner) { … }
class MenuViewDragAndDropTestTestInMenuDrag : public MenuViewDragAndDropTest { … };
void MenuViewDragAndDropTestTestInMenuDrag::OnWidgetDragWillStart(
views::Widget* widget) { … }
void MenuViewDragAndDropTestTestInMenuDrag::OnWidgetDragComplete(
views::Widget* widget) { … }
void MenuViewDragAndDropTestTestInMenuDrag::DoTestWithMenuOpen() { … }
void MenuViewDragAndDropTestTestInMenuDrag::StartDrag() { … }
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
#define MAYBE_TestInMenuDrag …
#else
#define MAYBE_TestInMenuDrag …
#endif
VIEW_TEST(MenuViewDragAndDropTestTestInMenuDrag, MAYBE_TestInMenuDrag)
class MenuViewDragAndDropTestNestedDrag : public MenuViewDragAndDropTest { … };
void MenuViewDragAndDropTestNestedDrag::OnWidgetDragWillStart(
views::Widget* widget) { … }
void MenuViewDragAndDropTestNestedDrag::OnWidgetDragComplete(
views::Widget* widget) { … }
void MenuViewDragAndDropTestNestedDrag::DoTestWithMenuOpen() { … }
void MenuViewDragAndDropTestNestedDrag::OnDragEntered() { … }
void MenuViewDragAndDropTestNestedDrag::StartDrag() { … }
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_OZONE_WAYLAND)
#define MAYBE_MenuViewDragAndDropNestedDrag …
#else
#define MAYBE_MenuViewDragAndDropNestedDrag …
#endif
VIEW_TEST(MenuViewDragAndDropTestNestedDrag,
MAYBE_MenuViewDragAndDropNestedDrag)
class MenuViewDragAndDropForDropStayOpen : public MenuViewDragAndDropTest { … };
int MenuViewDragAndDropForDropStayOpen::GetMenuRunnerFlags() { … }
void MenuViewDragAndDropForDropStayOpen::DoTestWithMenuOpen() { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_MenuViewStaysOpenForNestedDrag …
#else
#define MAYBE_MenuViewStaysOpenForNestedDrag …
#endif
VIEW_TEST(MenuViewDragAndDropForDropStayOpen,
MAYBE_MenuViewStaysOpenForNestedDrag)
class MenuViewDragAndDropForDropCancel : public MenuViewDragAndDropTest { … };
int MenuViewDragAndDropForDropCancel::GetMenuRunnerFlags() { … }
void MenuViewDragAndDropForDropCancel::DoTestWithMenuOpen() { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_MenuViewCancelsForOwnDrag …
#else
#define MAYBE_MenuViewCancelsForOwnDrag …
#endif
VIEW_TEST(MenuViewDragAndDropForDropCancel, MAYBE_MenuViewCancelsForOwnDrag)