#include "ui/views/interaction/interaction_test_util_mouse.h"
#include <memory>
#include <utility>
#include <variant>
#include "base/auto_reset.h"
#include "base/check.h"
#include "base/containers/contains.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread.h"
#include "build/build_config.h"
#include "ui/base/test/ui_controls.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/widget/widget.h"
#if defined(USE_AURA)
#include "ui/aura/client/drag_drop_client.h"
#include "ui/aura/client/drag_drop_client_observer.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#define TOUCH_INPUT_SUPPORTED …
#else
#define TOUCH_INPUT_SUPPORTED …
#endif
namespace views::test {
namespace {
raw_ptr<InteractionTestUtilMouse> g_current_mouse_util = …;
void PostTask(base::OnceClosure task) { … }
#if TOUCH_INPUT_SUPPORTED
ui_controls::TouchType GetTouchAction(ui_controls::MouseButtonState state) {
switch (state) {
case ui_controls::DOWN:
return ui_controls::kTouchPress;
case ui_controls::UP:
return ui_controls::kTouchRelease;
}
}
int GetTouchCount(ui_controls::MouseButton button) {
switch (button) {
case ui_controls::LEFT:
return 1;
case ui_controls::MIDDLE:
return 3;
case ui_controls::RIGHT:
return 2;
}
}
#endif
}
#if defined(USE_AURA)
class InteractionTestUtilMouse::DragEnder
: public aura::client::DragDropClientObserver,
public aura::WindowObserver { … };
#endif
InteractionTestUtilMouse::InteractionTestUtilMouse(views::Widget* widget)
: … { … }
InteractionTestUtilMouse::~InteractionTestUtilMouse() { … }
InteractionTestUtilMouse::MouseGesture InteractionTestUtilMouse::MoveTo(
gfx::Point point) { … }
InteractionTestUtilMouse::MouseGesture InteractionTestUtilMouse::MouseDown(
ui_controls::MouseButton button) { … }
InteractionTestUtilMouse::MouseGesture InteractionTestUtilMouse::MouseUp(
ui_controls::MouseButton button) { … }
InteractionTestUtilMouse::MouseGestures InteractionTestUtilMouse::Click(
ui_controls::MouseButton button) { … }
InteractionTestUtilMouse::MouseGestures InteractionTestUtilMouse::DragAndHold(
gfx::Point destination) { … }
InteractionTestUtilMouse::MouseGestures
InteractionTestUtilMouse::DragAndRelease(gfx::Point destination) { … }
bool InteractionTestUtilMouse::ShouldCancelDrag() const { … }
void InteractionTestUtilMouse::CancelFutureDrag() { … }
void InteractionTestUtilMouse::CancelDragNow() { … }
bool InteractionTestUtilMouse::SendButtonPress(
const MouseButtonGesture& gesture,
gfx::NativeWindow window_hint,
bool sync,
base::OnceClosure on_complete) { … }
bool InteractionTestUtilMouse::SendMove(const MouseMoveGesture& gesture,
gfx::NativeWindow window_hint,
bool sync,
base::OnceClosure on_complete) { … }
bool InteractionTestUtilMouse::SetTouchMode(bool touch_mode) { … }
bool InteractionTestUtilMouse::GetTouchMode() const { … }
bool InteractionTestUtilMouse::PerformGesturesImpl(
MouseGestures gestures,
gfx::NativeWindow window_hint) { … }
void InteractionTestUtilMouse::CancelAllGestures() { … }
InteractionTestUtilMouse::InteractionTestUtilMouse(gfx::NativeWindow window)
#if defined(USE_AURA)
: … { … }
void InteractionTestUtilMouse::AddGestures(MouseGestures& gestures,
MouseGesture to_add) { … }
void InteractionTestUtilMouse::AddGestures(MouseGestures& gestures,
MouseGestures to_add) { … }
}