#include "third_party/blink/renderer/platform/widget/input/input_handler_proxy.h"
#include <memory>
#include "base/containers/circular_deque.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/lazy_instance.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/simple_test_tick_clock.h"
#include "base/test/task_environment.h"
#include "base/test/trace_event_analyzer.h"
#include "base/types/optional_ref.h"
#include "build/build_config.h"
#include "cc/base/features.h"
#include "cc/input/browser_controls_offset_tags_info.h"
#include "cc/input/main_thread_scrolling_reason.h"
#include "cc/test/fake_impl_task_runner_provider.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/latency_info_swap_promise_monitor.h"
#include "cc/trees/layer_tree_settings.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/input/web_input_event_attribution.h"
#include "third_party/blink/public/common/input/web_keyboard_event.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
#include "third_party/blink/public/common/input/web_pointer_event.h"
#include "third_party/blink/public/common/input/web_touch_event.h"
#include "third_party/blink/renderer/platform/widget/input/compositor_thread_event_queue.h"
#include "third_party/blink/renderer/platform/widget/input/event_with_callback.h"
#include "third_party/blink/renderer/platform/widget/input/input_handler_proxy.h"
#include "third_party/blink/renderer/platform/widget/input/input_handler_proxy_client.h"
#include "third_party/blink/renderer/platform/widget/input/scroll_predictor.h"
#include "ui/events/types/scroll_input_type.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/latency/latency_info.h"
InputHandler;
ScrollBeginThreadState;
TouchAction;
_;
AllOf;
DoAll;
Eq;
Field;
Mock;
NiceMock;
Property;
Return;
SetArgPointee;
StrictMock;
namespace blink {
namespace test {
namespace {
MATCHER_P(WheelEventsMatch, expected, "") { … }
std::unique_ptr<WebInputEvent> CreateGestureScrollPinch(
WebInputEvent::Type type,
WebGestureDevice source_device,
base::TimeTicks event_time,
float delta_y_or_scale = 0,
int x = 0,
int y = 0) { … }
class FakeCompositorDelegateForInput : public cc::CompositorDelegateForInput { … };
base::LazyInstance<FakeCompositorDelegateForInput>::Leaky
g_fake_compositor_delegate = …;
class MockInputHandler : public cc::InputHandler { … };
class MockSynchronousInputHandler : public SynchronousInputHandler { … };
class MockInputHandlerProxyClient : public InputHandlerProxyClient { … };
WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state,
float x,
float y) { … }
const cc::InputHandler::ScrollStatus kImplThreadScrollState{ … };
const cc::InputHandler::ScrollStatus kRequiresMainThreadHitTestState{ … };
constexpr auto kSampleMainThreadScrollingReason = …;
const cc::InputHandler::ScrollStatus kScrollIgnoredScrollState{ … };
}
class TestInputHandlerProxy : public InputHandlerProxy { … };
enum class ScrollerType { … };
enum class HandlerType { … };
class InputHandlerProxyTest : public testing::Test,
public testing::WithParamInterface<
std::tuple<ScrollerType, HandlerType>> { … };
InputHandlerProxy::EventDisposition HandleInputEventWithLatencyInfo(
TestInputHandlerProxy* input_handler,
const WebInputEvent& event) { … }
InputHandlerProxy::EventDisposition HandleInputEventAndFlushEventQueue(
testing::StrictMock<MockInputHandler>& mock_input_handler,
TestInputHandlerProxy* input_handler,
const WebInputEvent& event) { … }
class InputHandlerProxyEventQueueTest : public testing::Test { … };
TEST_P(InputHandlerProxyTest, NestedGestureBasedScrollsDifferentSourceDevice) { … }
TEST_P(InputHandlerProxyTest, MouseWheelNoListener) { … }
TEST_P(InputHandlerProxyTest, MouseWheelPassiveListener) { … }
TEST_P(InputHandlerProxyTest, MouseWheelBlockingListener) { … }
TEST_P(InputHandlerProxyTest, MouseWheelBlockingAndPassiveListener) { … }
TEST_P(InputHandlerProxyTest, MouseWheelEventOutsideBlockingListener) { … }
TEST_P(InputHandlerProxyTest,
MouseWheelEventOutsideBlockingListenerWithPassiveListener) { … }
TEST_P(InputHandlerProxyTest, ScrollbarScrollEndOnDeviceChange) { … }
void InputHandlerProxyTest::GestureScrollStarted() { … }
TEST_P(InputHandlerProxyTest, GestureScrollStarted) { … }
TEST_P(InputHandlerProxyTest, GestureScrollIgnored) { … }
TEST_P(InputHandlerProxyTest, GestureScrollByPage) { … }
TEST_P(InputHandlerProxyTest, GestureScrollBeginThatTargetViewport) { … }
void InputHandlerProxyTest::FlingAndSnap() { … }
TEST_P(InputHandlerProxyTest, SnapFlingIgnoresFollowingGSUAndGSE) { … }
TEST_P(InputHandlerProxyTest, GesturePinch) { … }
TEST_P(InputHandlerProxyTest,
GestureScrollOnImplThreadFlagClearedAfterScrollEnd) { … }
TEST_P(InputHandlerProxyTest,
BeginScrollWhenGestureScrollOnImplThreadFlagIsSet) { … }
TEST_P(InputHandlerProxyTest, HitTestTouchEventNonNullTouchAction) { … }
TEST_F(InputHandlerProxyEventQueueTest,
NestedGestureBasedScrollsSameSourceDevice) { … }
TEST_F(InputHandlerProxyEventQueueTest, AckTouchActionNonBlockingForFling) { … }
TEST_P(InputHandlerProxyTest, HitTestTouchEventNullTouchAction) { … }
TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) { … }
TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) { … }
TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) { … }
TEST_P(InputHandlerProxyTest, TouchTrackingEndsOnCancel) { … }
TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) { … }
TEST_P(InputHandlerProxyTest, TouchMoveBlockingAddedAfterPassiveTouchStart) { … }
TEST_P(InputHandlerProxyTest, UpdateBrowserControlsState) { … }
class UnifiedScrollingInputHandlerProxyTest : public testing::Test { … };
TEST_F(UnifiedScrollingInputHandlerProxyTest, MainThreadHitTestRequired) { … }
TEST_F(UnifiedScrollingInputHandlerProxyTest, MainThreadHitTestEvent) { … }
TEST_F(UnifiedScrollingInputHandlerProxyTest, MainThreadHitTestMetrics) { … }
TEST_F(UnifiedScrollingInputHandlerProxyTest,
ScrollEndAndBeginsDuringMainThreadHitTest) { … }
TEST_F(UnifiedScrollingInputHandlerProxyTest, MainThreadHitTestFailed) { … }
TEST(SynchronousInputHandlerProxyTest, StartupShutdown) { … }
TEST(SynchronousInputHandlerProxyTest, UpdateRootLayerState) { … }
TEST(SynchronousInputHandlerProxyTest, SetOffset) { … }
TEST_F(InputHandlerProxyEventQueueTest,
MouseEventOnScrollbarInitiatesGestureScroll) { … }
TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) { … }
#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER) || \
defined(MEMORY_SANITIZER) || defined(UNDEFINED_SANITIZER)
#define MAYBE_VSyncAlignedGestureScrollPinchScroll …
#else
#define MAYBE_VSyncAlignedGestureScrollPinchScroll …
#endif
TEST_F(InputHandlerProxyEventQueueTest,
MAYBE_VSyncAlignedGestureScrollPinchScroll) { … }
TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) { … }
TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceScrollAndPinch) { … }
TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceTouchpadPinch) { … }
TEST_F(InputHandlerProxyEventQueueTest, OriginalEventsTracing) { … }
TEST_F(InputHandlerProxyEventQueueTest, TouchpadGestureScrollEndFlushQueue) { … }
TEST_F(InputHandlerProxyEventQueueTest, CoalescedLatencyInfo) { … }
TEST_F(InputHandlerProxyEventQueueTest, ScrollPredictorTest) { … }
TEST_F(InputHandlerProxyEventQueueTest, DeliverInputWithHighLatencyMode) { … }
TEST_F(InputHandlerProxyEventQueueTest, KeyEventAttribution) { … }
TEST_F(InputHandlerProxyEventQueueTest, MouseEventAttribution) { … }
TEST_F(InputHandlerProxyEventQueueTest, MouseWheelEventAttribution) { … }
TEST_F(InputHandlerProxyEventQueueTest, TouchEventAttribution) { … }
TEST_F(InputHandlerProxyEventQueueTest, GestureEventAttribution) { … }
class InputHandlerProxyMainThreadScrollingReasonTest
: public InputHandlerProxyTest { … };
#define EXPECT_NON_MAIN_THREAD_GESTURE_SCROLL_SAMPLE() …
#define EXPECT_NON_MAIN_THREAD_WHEEL_SCROLL_SAMPLE() …
#define EXPECT_MAIN_THREAD_GESTURE_SCROLL_SAMPLE(reason) …
#define EXPECT_MAIN_THREAD_WHEEL_SCROLL_SAMPLE(reason) …
#define EXPECT_MAIN_THREAD_WHEEL_SCROLL_SAMPLE_2(reason1, reason2) …
TEST_P(InputHandlerProxyMainThreadScrollingReasonTest, ReasonToBucket) { … }
TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
GestureScrollNotScrollOnMain) { … }
TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
GestureScrollTouchEventHandlerRegion) { … }
TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
ImplHandled_MainThreadHitTest) { … }
TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
ImplHandled_MainThreadRepaint) { … }
TEST_P(InputHandlerProxyMainThreadScrollingReasonTest, WheelScrollHistogram) { … }
TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
WheelScrollNotScrollingOnMain) { … }
TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
WheelScrollWheelEventHandlerRegion) { … }
class InputHandlerProxyTouchScrollbarTest : public InputHandlerProxyTest { … };
TEST_P(InputHandlerProxyTouchScrollbarTest,
TouchOnScrollbarIsHandledByCompositorThread) { … }
const auto kTestCombinations = …;
const auto kSuffixGenerator = …::string name = …;
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
}
}