chromium/third_party/blink/renderer/platform/widget/input/main_thread_event_queue_unittest.cc

// Copyright 2016 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 "third_party/blink/renderer/platform/widget/input/main_thread_event_queue.h"

#include <stddef.h>

#include <new>
#include <tuple>
#include <utility>

#include "base/auto_reset.h"
#include "base/containers/adapters.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ref.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_util.h"
#include "base/test/test_simple_task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "cc/metrics/event_metrics.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/input/synthetic_web_input_event_builders.h"
#include "third_party/blink/public/common/input/web_input_event_attribution.h"
#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
#include "third_party/blink/public/platform/scheduler/test/web_mock_thread_scheduler.h"
#include "third_party/blink/renderer/platform/scheduler/test/fake_widget_scheduler.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/wtf/vector.h"

namespace blink {
namespace {

// Simulate a 16ms frame signal.
const base::TimeDelta kFrameInterval =;

bool Equal(const WebTouchEvent& lhs, const WebTouchEvent& rhs) {}

bool Equal(const WebMouseWheelEvent& lhs, const WebMouseWheelEvent& rhs) {}

}  // namespace

class HandledTask {};

class HandledEvent : public HandledTask {};

class HandledClosure : public HandledTask {};

enum class CallbackReceivedState {};

void PrintTo(CallbackReceivedState state, std::ostream* os) {}

class ReceivedCallback {};

class HandledEventCallbackTracker {};

MATCHER_P3(IsHandledTouchEvent, event_type, touch_id, dispatch_type, "") {}

class MockWidgetScheduler : public scheduler::FakeWidgetScheduler {};

class MainThreadEventQueueTest : public testing::Test,
                                 public testing::WithParamInterface<bool>,
                                 public MainThreadEventQueueClient,
                                 private ScopedUnblockTouchMoveEarlierForTest {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(MainThreadEventQueueTest, ClientDoesntHandleInputEvent) {}

TEST_P(MainThreadEventQueueTest, NonBlockingWheel) {}

TEST_P(MainThreadEventQueueTest, NonBlockingTouch) {}

TEST_P(MainThreadEventQueueTest, BlockingTouch) {}

TEST_P(MainThreadEventQueueTest, InterleavedEvents) {}

TEST_P(MainThreadEventQueueTest, RafAlignedMouseInput) {}

TEST_P(MainThreadEventQueueTest, RafAlignedTouchInput) {}

TEST_P(MainThreadEventQueueTest, RafAlignedTouchInputCoalescedMoves) {}

TEST_P(MainThreadEventQueueTest, RafAlignedTouchInputThrottlingMoves) {}

TEST_P(MainThreadEventQueueTest, LowLatency) {}

TEST_P(MainThreadEventQueueTest, BlockingTouchesDuringFling) {}

TEST_P(MainThreadEventQueueTest, BlockingTouchesOutsideFling) {}

TEST_P(MainThreadEventQueueTest, QueueingEventTimestampRecorded) {}

TEST_P(MainThreadEventQueueTest, QueuingTwoClosures) {}

TEST_P(MainThreadEventQueueTest, QueuingClosureWithRafEvent) {}

TEST_P(MainThreadEventQueueTest, QueuingClosuresBetweenEvents) {}

TEST_P(MainThreadEventQueueTest, BlockingTouchMoveBecomesNonBlocking) {}

TEST_P(MainThreadEventQueueTest, BlockingTouchMoveWithTouchEnd) {}

TEST_P(MainThreadEventQueueTest,
       UnblockTouchMoveAfterTouchStartAndFirstTouchMoveNotConsumed) {}

TEST_P(MainThreadEventQueueTest, UnbufferedDispatchTouchEvent) {}

TEST_P(MainThreadEventQueueTest, PointerEventsCoalescing) {}

TEST_P(MainThreadEventQueueTest, PointerRawUpdateEvents) {}

TEST_P(MainThreadEventQueueTest, UnbufferedDispatchMouseEvent) {}

// This test verifies that the events marked with kRelativeMotionEvent modifier
// are not coalesced with other events. During pointer lock,
// kRelativeMotionEvent is sent to the Renderer only to update the new screen
// position. Events of this kind shouldn't be dispatched or coalesced.
TEST_P(MainThreadEventQueueTest, PointerEventsWithRelativeMotionCoalescing) {}

// Verifies that after rAF-aligned or non-rAF-aligned events are dispatched,
// clients are notified that the dispatch is done.
TEST_P(MainThreadEventQueueTest, InputEventsDispatchedNotified) {}

}  // namespace blink