chromium/content/common/input/synthetic_gesture_controller_unittest.cc

// Copyright 2013 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/342213636): Remove this and spanify to fix the errors.
#pragma allow_unsafe_buffers
#endif

#include "content/common/input/synthetic_gesture_controller.h"

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

#include <memory>
#include <utility>

#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "content/common/input/synthetic_gesture.h"
#include "content/common/input/synthetic_gesture_target.h"
#include "content/common/input/synthetic_pinch_gesture.h"
#include "content/common/input/synthetic_pinch_gesture_params.h"
#include "content/common/input/synthetic_pointer_action.h"
#include "content/common/input/synthetic_smooth_drag_gesture.h"
#include "content/common/input/synthetic_smooth_drag_gesture_params.h"
#include "content/common/input/synthetic_smooth_move_gesture.h"
#include "content/common/input/synthetic_smooth_scroll_gesture.h"
#include "content/common/input/synthetic_smooth_scroll_gesture_params.h"
#include "content/common/input/synthetic_tap_gesture.h"
#include "content/common/input/synthetic_tap_gesture_params.h"
#include "content/common/input/synthetic_touchpad_pinch_gesture.h"
#include "content/common/input/synthetic_touchscreen_pinch_gesture.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/geometry/vector2d_f.h"

WebInputEvent;
WebMouseEvent;
WebMouseWheelEvent;
WebTouchEvent;
WebTouchPoint;

namespace content {

namespace {

const int kFlushInputRateInMs =;
const int kPointerAssumedStoppedTimeMs =;
const float kTouchSlopInDips =;
const float kMinScalingSpanInDips =;
const int kTouchPointersLength =;
const int kMouseWheelTickMultiplier =;

enum TouchGestureType {};

WebTouchPoint::State ToWebTouchPointState(
    SyntheticPointerActionParams::PointerActionType action_type) {}

WebInputEvent::Type ToWebMouseEventType(
    SyntheticPointerActionParams::PointerActionType action_type) {}

WebInputEvent::Type WebTouchPointStateToEventType(
    blink::WebTouchPoint::State state) {}

class MockGestureParams : public SyntheticGestureParams {};

class MockSyntheticGesture : public SyntheticGestureBase<MockGestureParams> {};

class MockSyntheticGestureTarget : public SyntheticGestureTarget {};

class MockMoveGestureTarget : public MockSyntheticGestureTarget {};

class MockScrollMouseTarget : public MockMoveGestureTarget {};

class MockMoveTouchTarget : public MockMoveGestureTarget {};

class MockFlingGestureTarget : public MockMoveGestureTarget {};

class MockDragMouseTarget : public MockMoveGestureTarget {};

class MockSyntheticTouchscreenPinchTouchTarget
    : public MockSyntheticGestureTarget {};

class MockSyntheticTouchpadPinchTouchTarget
    : public MockSyntheticGestureTarget {};

class MockSyntheticTapGestureTarget : public MockSyntheticGestureTarget {};

class MockSyntheticTapTouchTarget : public MockSyntheticTapGestureTarget {};

class MockSyntheticTapMouseTarget : public MockSyntheticTapGestureTarget {};

class MockSyntheticPointerActionTarget : public MockSyntheticGestureTarget {};

class MockSyntheticPointerTouchActionTarget
    : public MockSyntheticPointerActionTarget {};

class MockSyntheticPointerMouseActionTarget
    : public MockSyntheticPointerActionTarget {};

class DummySyntheticGestureControllerDelegate
    : public SyntheticGestureController::Delegate {};

}  // namespace

class SyntheticGestureControllerTestBase {};

class SyntheticGestureControllerTest
    : public SyntheticGestureControllerTestBase,
      public testing::Test {};

class SyntheticGestureControllerTestWithParam
    : public SyntheticGestureControllerTestBase,
      public testing::TestWithParam<bool> {};

TEST_F(SyntheticGestureControllerTest, SingleGesture) {}

TEST_F(SyntheticGestureControllerTest, GestureFailed) {}

TEST_F(SyntheticGestureControllerTest, SuccessiveGestures) {}

TEST_F(SyntheticGestureControllerTest, TwoGesturesInFlight) {}

TEST_F(SyntheticGestureControllerTest, GestureCompletedOnDidFlushInput) {}

gfx::Vector2d AddTouchSlopToVector(const gfx::Vector2dF& vector,
                                   SyntheticGestureTarget* target) {}

TEST_P(SyntheticGestureControllerTestWithParam,
       SingleMoveGestureTouchVertical) {}

TEST_P(SyntheticGestureControllerTestWithParam,
       SingleScrollGestureTouchHorizontal) {}

void CheckIsWithinRangeSingle(float scroll_distance,
                              int target_distance,
                              SyntheticGestureTarget* target) {}

void CheckSingleScrollDistanceIsWithinRange(
    const gfx::Vector2dF& scroll_distance,
    const gfx::Vector2dF& target_distance,
    SyntheticGestureTarget* target) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchDiagonal) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchLongStop) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchFling) {}

TEST_P(SyntheticGestureControllerTestWithParam,
       SingleScrollGestureTouchZeroDistance) {}

TEST_P(SyntheticGestureControllerTestWithParam,
       SingleScrollGestureTouchFromDebugger) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseVertical) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseHorizontal) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseDiagonal) {}

TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouse) {}

TEST_F(SyntheticGestureControllerTest, MultiScrollGestureMouseHorizontal) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureTouchpadSwipe) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMousePreciseScroll) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseScrollByPage) {}

TEST_F(SyntheticGestureControllerTest, SingleScrollGestureMouseFromDebugger) {}

void CheckIsWithinRangeMulti(float scroll_distance,
                             int target_distance,
                             SyntheticGestureTarget* target) {}

void CheckMultiScrollDistanceIsWithinRange(
    const gfx::Vector2dF& scroll_distance,
    const gfx::Vector2dF& target_distance,
    SyntheticGestureTarget* target) {}

TEST_F(SyntheticGestureControllerTest, MultiScrollGestureTouch) {}

TEST_P(SyntheticGestureControllerTestWithParam,
       MultiScrollGestureTouchVertical) {}

INSTANTIATE_TEST_SUITE_P();

TEST_F(SyntheticGestureControllerTest, SingleDragGestureMouseDiagonal) {}

TEST_F(SyntheticGestureControllerTest, SingleDragGestureMouseZeroDistance) {}

TEST_F(SyntheticGestureControllerTest, MultiDragGestureMouse) {}

TEST_F(SyntheticGestureControllerTest,
       SyntheticSmoothDragTestUsingSingleMouseDrag) {}

TEST_F(SyntheticGestureControllerTest,
       SyntheticSmoothDragTestUsingSingleMouseDragFromDebugger) {}

TEST_F(SyntheticGestureControllerTest,
       SyntheticSmoothDragTestUsingSingleTouchDrag) {}

TEST_F(SyntheticGestureControllerTest,
       SyntheticSmoothDragTestUsingSingleTouchDragFromDebugger) {}

TEST_F(SyntheticGestureControllerTest,
       SyntheticSmoothScrollTestUsingSingleTouchScroll) {}

TEST_F(SyntheticGestureControllerTest,
       SyntheticSmoothScrollTestUsingSingleTouchScrollFromDebugger) {}

TEST_F(SyntheticGestureControllerTest,
       SyntheticSmoothScrollTestUsingSingleMouseScroll) {}

TEST_F(SyntheticGestureControllerTest,
       SyntheticSmoothScrollTestUsingSingleMouseScrollFromDebugger) {}

TEST_F(SyntheticGestureControllerTest,
       TouchscreenTouchpadPinchGestureTouchZoomIn) {}

TEST_F(SyntheticGestureControllerTest,
       TouchscreenTouchpadPinchGestureTouchZoomOut) {}

TEST_F(SyntheticGestureControllerTest,
       TouchscreenTouchpadPinchGestureTouchNoScaling) {}

TEST_F(SyntheticGestureControllerTest,
       TouchscreenTouchpadPinchGestureTouchFromDebugger) {}

TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchZoomIn) {}

TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchZoomOut) {}

TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchNoScaling) {}

TEST_F(SyntheticGestureControllerTest, TouchpadPinchGestureTouchFromDebugger) {}

// Ensure that if SyntheticPinchGesture is instantiated with TOUCH_INPUT it
// correctly creates a touchscreen gesture.
TEST_F(SyntheticGestureControllerTest, PinchGestureExplicitTouch) {}

// Ensure that if SyntheticPinchGesture is instantiated with MOUSE_INPUT it
// correctly creates a touchpad gesture.
TEST_F(SyntheticGestureControllerTest, PinchGestureExplicitMouse) {}

// Ensure that if SyntheticPinchGesture is instantiated with DEFAULT_INPUT it
// correctly creates a touchscreen gesture for a touchscreen controller.
TEST_F(SyntheticGestureControllerTest, PinchGestureDefaultTouch) {}

// Ensure that if SyntheticPinchGesture is instantiated with DEFAULT_INPUT it
// correctly creates a touchpad gesture for a touchpad controller.
TEST_F(SyntheticGestureControllerTest, PinchGestureDefaultMouse) {}

TEST_F(SyntheticGestureControllerTest, TapGestureTouch) {}

TEST_F(SyntheticGestureControllerTest, TapGestureTouchFromDebugger) {}

TEST_F(SyntheticGestureControllerTest, TapGestureMouse) {}

TEST_F(SyntheticGestureControllerTest, TapGestureMouseFromDebugger) {}

TEST_F(SyntheticGestureControllerTest, PointerTouchAction) {}

TEST_F(SyntheticGestureControllerTest, PointerMouseAction) {}

TEST_F(SyntheticGestureControllerTest, PointerPenAction) {}

class MockSyntheticGestureTargetManualAck : public MockSyntheticGestureTarget {};

// Ensure the first time a gesture is queued, we wait for a renderer ACK before
// starting the gesture. Following gestures should start immediately. This test
// the renderer_known_to_be_initialized_ bit in the controller.
TEST_F(SyntheticGestureControllerTest, WaitForRendererInitialization) {}

}  // namespace content