chromium/ui/events/gesture_detection/gesture_provider_unittest.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.

#include "ui/events/gesture_detection/gesture_provider.h"

#include <stddef.h>

#include <memory>

#include "base/check.h"
#include "base/location.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ui_base_features.h"
#include "ui/events/event_constants.h"
#include "ui/events/gesture_detection/gesture_event_data.h"
#include "ui/events/test/motion_event_test_utils.h"
#include "ui/events/types/event_type.h"
#include "ui/events/velocity_tracker/motion_event.h"
#include "ui/gfx/geometry/point_f.h"

TimeTicks;
MockMotionEvent;

namespace ui {
namespace {

const float kFakeCoordX =;
const float kFakeCoordY =;
const base::TimeDelta kOneSecond =;
const base::TimeDelta kOneMicrosecond =;
const base::TimeDelta kDeltaTimeForFlingSequences =;
const float kMockTouchRadius =;
const float kMaxTwoFingerTapSeparation =;

GestureProvider::Config CreateDefaultConfig() {}

gfx::RectF BoundsForSingleMockTouchAtLocation(float x, float y) {}

}  // namespace

class GestureProviderTest : public testing::Test, public GestureProviderClient {};

// Verify that a DOWN has the same unique_touch_event_id and
// primary_touch_event_id
TEST_F(GestureProviderTest, GestureTapPrimaryUniqueTouchEventId) {}

// Verify that a DOWN followed shortly by an UP will trigger a single tap.
TEST_F(GestureProviderTest, GestureTap) {}

// Verify that a DOWN followed shortly by an UP will trigger
// a EventType::kGestureTapUnconfirmed event if double-tap is enabled.
TEST_F(GestureProviderTest, GestureTapWithDelay) {}

// Verify that a DOWN followed by a MOVE will trigger fling, but won't trigger
// either short-press or long-press.
TEST_F(GestureProviderTest, GestureFlingAndCancelLongPress) {}

// Verify that for a normal scroll the following events are sent:
// - EventType::kGestureScrollBegin
// - EventType::kGestureScrollUpdate
// - EventType::kGestureScrollEnd
TEST_F(GestureProviderTest, ScrollEventActionUpSequence) {}

// Verify that for a cancelled scroll the following events are sent:
// - EventType::kGestureScrollBegin
// - EventType::kGestureScrollUpdate
// - EventType::kGestureScrollEnd
TEST_F(GestureProviderTest, ScrollEventActionCancelSequence) {}

// Verify that for a normal fling (fling after scroll) the following events are
// sent:
// - EventType::kGestureScrollBegin
// - EventType::kScrollFlingStart
TEST_F(GestureProviderTest, FlingEventSequence) {}

TEST_F(GestureProviderTest, GestureCancelledOnCancelEvent) {}

TEST_F(GestureProviderTest, GestureCancelledOnDetectionReset) {}

TEST_F(GestureProviderTest, TapPendingConfirmationCancelledOnCancelEvent) {}

TEST_F(GestureProviderTest, NoTapAfterScrollBegins) {}

TEST_F(GestureProviderTest, DoubleTap) {}

TEST_F(GestureProviderTest, DoubleTapDragZoomBasic) {}

// Generate a scroll gesture and verify that the resulting scroll motion event
// has both absolute and relative position information.
TEST_F(GestureProviderTest, ScrollUpdateValues) {}

// Verify that fractional scroll deltas are rounded as expected and that
// fractional scrolling doesn't break scroll snapping.
TEST_F(GestureProviderTest, FractionalScroll) {}

// Generate a scroll gesture and verify that the resulting scroll begin event
// has the expected hint values.
TEST_F(GestureProviderTest, ScrollBeginValues) {}

// The following three tests verify that slop regions are checked for
// one and two finger scrolls. Three-finger tap doesn't exist, so,
// no slop region check is needed for three-finger scrolls.

TEST_F(GestureProviderTest, SlopRegionCheckOnOneFingerScroll) {}

TEST_F(GestureProviderTest, SlopRegionCheckOnTwoFingerScroll) {}

// This test simulates cases like (crbug.com/704426) in which some of the events
// are missing from the event stream.
TEST_F(GestureProviderTest, SlopRegionCheckOnMissingSecondaryPointerDownEvent) {}

TEST_F(GestureProviderTest, NoSlopRegionCheckOnThreeFingerScroll) {}

TEST_F(GestureProviderTest, ScrollStartWithSecondaryPointer) {}

TEST_F(GestureProviderTest, NoFlingBeforeExeedingSlopRegion) {}

TEST_F(GestureProviderTest, LongPressAndTapCancelledWhenScrollBegins) {}

// Verify that LONG_TAP is triggered after LONG_PRESS followed by an UP.
TEST_F(GestureProviderTest, GestureLongTap) {}

TEST_F(GestureProviderTest, GestureLongPressDoesNotPreventScrolling) {}

TEST_F(GestureProviderTest, DeepPressAcceleratedLongPress) {}

TEST_F(GestureProviderTest, StylusButtonCausesLongPress) {}

TEST_F(GestureProviderTest, DisabledStylusButtonDoesNotCauseLongPress) {}

TEST_F(GestureProviderTest, NoGestureLongPressDuringDoubleTap) {}

// Verify that the touch slop region is removed from the first scroll delta to
// avoid a jump when starting to scroll.
TEST_F(GestureProviderTest, TouchSlopRemovedFromScroll) {}

// Verify that finger movement within the tap slop region does not
// initiate a scroll, and that movement outside the slop region does.
TEST_F(GestureProviderTest, NoTouchScrollWithinSlop) {}

// Verify that stylus movement within the tap slop region does not
// initiate a scroll, and that movement outside the slop region does.
TEST_F(GestureProviderTest, NoStylusScrollWithinSlop) {}

// Disabled because `SnapScrollController` still can't correctly treat all
// stylus moves within the slop region. If the first move action is within the
// stylus slop but outside the (smaller) touch slop, `SnapScrollController`
// ignores any orthogonal move actions even when they are outside the stylus
// slop.
//
// TODO([email protected]): Refactor SnapScrollController states to fix this.
TEST_F(GestureProviderTest, SnapScrollWithStylusSlop) {}

TEST_F(GestureProviderTest, NoDoubleTapWhenTooRapid) {}

TEST_F(GestureProviderTest, NoDoubleTapWhenExplicitlyDisabled) {}

TEST_F(GestureProviderTest, NoDoubleTapWhenConsumerDoesntWantIt) {}

TEST_F(GestureProviderTest, NoDelayedTapWhenDoubleTapSupportToggled) {}

TEST_F(GestureProviderTest, NoDoubleTapDragZoomWhenDisabledOnPlatform) {}

// Verify that double tap drag zoom feature is not invoked when the gesture
// handler is told to disable double tap gesture detection.
// The second tap sequence should be treated just as the first would be.
TEST_F(GestureProviderTest, NoDoubleTapDragZoomWhenDisabledOnPage) {}

// Verify that updating double tap support during a double tap drag zoom
// disables double tap detection after the gesture has ended.
TEST_F(GestureProviderTest, FixedPageScaleDuringDoubleTapDragZoom) {}

// Verify that pinch zoom sends the proper event sequence.
TEST_F(GestureProviderTest, PinchZoom) {}

// Verify that no accidental pinching occurs if the touch size is large relative
// to the min scaling span when the touch major value is used in scaling.
TEST_F(GestureProviderTest, NoPinchZoomWithFatFinger) {}

// Verify that multi-finger swipe sends the proper event sequence.
TEST_F(GestureProviderTest, MultiFingerSwipe) {}

// Verify that the timer of LONG_PRESS will be cancelled when scrolling begins
// so LONG_PRESS and LONG_TAP won't be triggered.
TEST_F(GestureProviderTest, GesturesCancelledAfterLongPressCausesLostFocus) {}

// Verify that inserting a touch cancel event will trigger proper touch and
// gesture sequence cancellation.
TEST_F(GestureProviderTest, CancelActiveTouchSequence) {}

TEST_F(GestureProviderTest, DoubleTapDragZoomCancelledOnSecondaryPointerDown) {}

// Verify that gesture begin and gesture end events are dispatched correctly.
TEST_F(GestureProviderTest, GestureBeginAndEnd) {}

// Verify that gesture begin and gesture end events are dispatched correctly
// when an Action::CANCEL is received.
TEST_F(GestureProviderTest, GestureBeginAndEndOnCancel) {}

// Test a simple two finger tap
TEST_F(GestureProviderTest, TwoFingerTap) {}

// Test preventing a two finger tap via finger movement.
TEST_F(GestureProviderTest, TwoFingerTapCancelledByFingerMovement) {}

// Test preventing a two finger tap by waiting too long before releasing the
// secondary pointer.
TEST_F(GestureProviderTest, TwoFingerTapCancelledByDelay) {}

// Test preventing a two finger tap by pressing the secondary pointer too far
// from the first
TEST_F(GestureProviderTest, TwoFingerTapCancelledByDistanceBetweenPointers) {}

// Verify that the event that starts the pinch-zoom by exceeding the touch-slop
// also generates an update.
TEST_F(GestureProviderTest, PinchExceedingSlopCausesUpdate) {}

// Verify that the event that stops the pinch-zoom by exceeding the min scaling
// span also generates an update.
TEST_F(GestureProviderTest, PinchBelowMinSpanCausesUpdate) {}

// Verify that the pinch isn't started until it becomes larger than the min
// scaling span.
TEST_F(GestureProviderTest, PinchExceedingSlopWithinMinScale) {}

// Verify that pinch zoom only sends updates which exceed the
// min_pinch_update_span_delta.
TEST_F(GestureProviderTest, PinchZoomWithThreshold) {}

// Verify that the min gesture bound setting is honored.
TEST_F(GestureProviderTest, MinGestureBoundsLength) {}

TEST_F(GestureProviderTest, MaxGestureBoundsLength) {}

TEST_F(GestureProviderTest, ZeroRadiusBoundingBox) {}

// Verify that the min/max gesture bound settings are not applied to stylus
// or mouse-derived MotionEvents.
TEST_F(GestureProviderTest, NoMinOrMaxGestureBoundsLengthWithStylusOrMouse) {}

#if BUILDFLAG(IS_MAC) && defined(ARCH_CPU_ARM64)
// https://crbug.com/1222659
#define MAYBE_BoundingBoxForShowPressAndTapGesture
#else
#define MAYBE_BoundingBoxForShowPressAndTapGesture
#endif
// Test the bounding box for show press and tap gestures.
TEST_F(GestureProviderTest, MAYBE_BoundingBoxForShowPressAndTapGesture) {}

TEST_F(GestureProviderTest, SingleTapRepeat) {}

TEST_F(GestureProviderTest, SingleTapRepeatLengthOfOne) {}

// Test for Event.MaxDragDistance.* histograms with taps.
TEST_F(GestureProviderTest, MaxDragDistanceHistogramsWithTap) {}

// Test for Event.MaxDragDistance.* histograms with drags.
TEST_F(GestureProviderTest, MaxDragDistanceHistogramsWithDrag) {}

}  // namespace ui