chromium/ui/events/test/event_generator.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.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "ui/events/test/event_generator.h"

#include <stddef.h>
#include <stdint.h>

#include <memory>
#include <utility>

#include "base/check.h"
#include "base/containers/adapters.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/tick_clock.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "ui/events/event.h"
#include "ui/events/event_source.h"
#include "ui/events/event_utils.h"
#include "ui/events/test/events_test_utils.h"
#include "ui/gfx/geometry/vector2d_conversions.h"

#if BUILDFLAG(IS_WIN)
#include <windows.h>

#include "ui/events/keycodes/keyboard_code_conversion.h"
#endif

#if BUILDFLAG(IS_OZONE)
#include "ui/events/ozone/events_ozone.h"
#endif

namespace ui {
namespace test {

// A TickClock that advances time by one millisecond on each call to NowTicks().
class TestTickClock : public base::TickClock {};

namespace {

void DummyCallback(EventType, const gfx::Vector2dF&) {}

ui::TouchEvent CreateTestTouchEvent(ui::EventType type,
                                    const gfx::Point& root_location,
                                    int touch_id,
                                    int flags,
                                    base::TimeTicks timestamp) {}

const int kAllButtonMask =;

EventGeneratorDelegate::FactoryFunction g_event_generator_delegate_factory;

bool g_event_generator_allowed =;

struct ModifierKey {};

constexpr ModifierKey kModifierKeys[] =;

}  // namespace

// static
void EventGeneratorDelegate::SetFactoryFunction(FactoryFunction factory) {}

// static
void EventGenerator::BanEventGenerator() {}

EventGenerator::EventGenerator(std::unique_ptr<EventGeneratorDelegate> delegate)
    :{}

EventGenerator::EventGenerator(gfx::NativeWindow root_window) {}

EventGenerator::EventGenerator(gfx::NativeWindow root_window,
                               const gfx::Point& point)
    :{}

EventGenerator::EventGenerator(gfx::NativeWindow root_window,
                               gfx::NativeWindow target_window) {}

EventGenerator::~EventGenerator() {}

void EventGenerator::SetTargetWindow(gfx::NativeWindow target_window) {}

void EventGenerator::PressButton(int flag) {}

void EventGenerator::ReleaseButton(int flag) {}

void EventGenerator::PressLeftButton() {}

void EventGenerator::ReleaseLeftButton() {}

void EventGenerator::ClickLeftButton() {}

void EventGenerator::ClickRightButton() {}

void EventGenerator::DoubleClickLeftButton() {}

void EventGenerator::PressRightButton() {}

void EventGenerator::ReleaseRightButton() {}

void EventGenerator::MoveMouseWheel(int delta_x, int delta_y) {}

void EventGenerator::SendMouseEnter() {}

void EventGenerator::SendMouseExit() {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
void EventGenerator::MoveMouseToWithNative(const gfx::Point& point_in_host,
                                           const gfx::Point& point_for_native) {
  // Ozone uses the location in native event as a system location.
  // Create a fake event with the point in host, which will be passed
  // to the non native event, then update the native event with the native
  // (root) one.
  std::unique_ptr<ui::MouseEvent> native_event(
      new ui::MouseEvent(ui::EventType::kMouseMoved, point_in_host,
                         point_in_host, ui::EventTimeForNow(), flags_, 0));
  ui::MouseEvent mouseev(native_event.get());
  mouseev.set_source_device_id(mouse_source_device_id_);
  native_event->set_location(point_for_native);
  Dispatch(&mouseev);

  SetCurrentScreenLocation(point_in_host);
  delegate()->ConvertPointFromHost(current_target_, &current_screen_location_);
}
#endif

void EventGenerator::MoveMouseToInHost(const gfx::Point& point_in_host) {}

void EventGenerator::MoveMouseTo(const gfx::Point& point_in_screen,
                                 int count) {}

void EventGenerator::MoveMouseRelativeTo(const EventTarget* window,
                                         const gfx::Point& point_in_parent) {}

void EventGenerator::DragMouseTo(const gfx::Point& point) {}

void EventGenerator::MoveMouseToCenterOf(EventTarget* window) {}

void EventGenerator::EnterPenPointerMode() {}

void EventGenerator::ExitPenPointerMode() {}

void EventGenerator::SetTouchRadius(float x, float y) {}

void EventGenerator::SetTouchTilt(float x, float y) {}

void EventGenerator::PressTouch(
    const std::optional<gfx::Point>& touch_location_in_screen) {}

void EventGenerator::PressTouchId(
    int touch_id,
    const std::optional<gfx::Point>& touch_location_in_screen) {}

void EventGenerator::MoveTouch(const gfx::Point& point) {}

void EventGenerator::MoveTouchId(const gfx::Point& point, int touch_id) {}

void EventGenerator::ReleaseTouch() {}

void EventGenerator::ReleaseTouchId(int touch_id) {}

void EventGenerator::CancelTouch() {}

void EventGenerator::CancelTouchId(int touch_id) {}

void EventGenerator::PressMoveAndReleaseTouchTo(const gfx::Point& point) {}

void EventGenerator::PressMoveAndReleaseTouchToCenterOf(EventTarget* window) {}

void EventGenerator::GestureTapAt(const gfx::Point& location) {}

void EventGenerator::GestureTapDownAndUp(const gfx::Point& location) {}

base::TimeDelta EventGenerator::CalculateScrollDurationForFlingVelocity(
    const gfx::Point& start,
    const gfx::Point& end,
    float velocity,
    int steps) {}

void EventGenerator::GestureScrollSequence(const gfx::Point& start,
                                           const gfx::Point& end,
                                           const base::TimeDelta& step_delay,
                                           int steps) {}

void EventGenerator::GestureScrollSequenceWithCallback(
    const gfx::Point& start,
    const gfx::Point& end,
    const base::TimeDelta& step_delay,
    int steps,
    const ScrollStepCallback& callback) {}

void EventGenerator::GestureMultiFingerScrollWithDelays(
    int count,
    const gfx::Point start[],
    const gfx::Vector2d delta[],
    const int delay_adding_finger_ms[],
    const int delay_releasing_finger_ms[],
    int event_separation_time_ms,
    int steps) {}

void EventGenerator::GestureMultiFingerScrollWithDelays(
    int count,
    const gfx::Point start[],
    const int delay_adding_finger_ms[],
    int event_separation_time_ms,
    int steps,
    int move_x,
    int move_y) {}

void EventGenerator::GestureMultiFingerScroll(int count,
                                              const gfx::Point start[],
                                              int event_separation_time_ms,
                                              int steps,
                                              int move_x,
                                              int move_y) {}

void EventGenerator::ScrollSequence(const gfx::Point& start,
                                    const base::TimeDelta& step_delay,
                                    float x_offset,
                                    float y_offset,
                                    int steps,
                                    int num_fingers,
                                    ScrollSequenceType end_state) {}

void EventGenerator::GenerateTrackpadRest() {}

void EventGenerator::CancelTrackpadRest() {}

void EventGenerator::PressKey(ui::KeyboardCode key_code,
                              int flags,
                              int source_device_id) {}

void EventGenerator::ReleaseKey(ui::KeyboardCode key_code,
                                int flags,
                                int source_device_id) {}

void EventGenerator::PressAndReleaseKey(KeyboardCode key_code,
                                        int flags,
                                        int source_device_id) {}

void EventGenerator::PressModifierKeys(int flags, int source_device_id) {}

void EventGenerator::ReleaseModifierKeys(int flags, int source_device_id) {}

void EventGenerator::PressKeyAndModifierKeys(KeyboardCode key_code,
                                             int flags,
                                             int source_device_id) {}

void EventGenerator::ReleaseKeyAndModifierKeys(KeyboardCode key_code,
                                               int flags,
                                               int source_device_id) {}

void EventGenerator::PressAndReleaseKeyAndModifierKeys(KeyboardCode key_code,
                                                       int flags,
                                                       int source_device_id) {}

void EventGenerator::Dispatch(ui::Event* event) {}

void EventGenerator::AdvanceClock(const base::TimeDelta& delta) {}

void EventGenerator::Init(gfx::NativeWindow root_window,
                          gfx::NativeWindow target_window) {}

void EventGenerator::DispatchKeyEvent(bool is_press,
                                      ui::KeyboardCode key_code,
                                      int flags,
                                      int source_device_id) {}

void EventGenerator::SetCurrentScreenLocation(const gfx::Point& point) {}

void EventGenerator::UpdateCurrentDispatcher(const gfx::Point& point) {}

gfx::Point EventGenerator::GetLocationInCurrentRoot() const {}

gfx::Point EventGenerator::CenterOfWindow(const EventTarget* window) const {}

void EmulateFullKeyPressReleaseSequence(test::EventGenerator* generator,
                                        KeyboardCode key,
                                        bool control,
                                        bool shift,
                                        bool alt,
                                        bool command) {}

}  // namespace test
}  // namespace ui