chromium/third_party/blink/renderer/core/frame/web_frame_widget_test.cc

// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/functional/callback_helpers.h"
#include "base/run_loop.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/unguessable_token.h"
#include "build/build_config.h"
#include "cc/layers/solid_color_layer.h"
#include "cc/test/property_tree_test_utils.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/input/synthetic_web_input_event_builders.h"
#include "third_party/blink/renderer/core/css/properties/css_property_ref.h"
#include "third_party/blink/renderer/core/css/properties/longhands.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/dom/events/add_event_listener_options_resolved.h"
#include "third_party/blink/renderer/core/dom/events/native_event_listener.h"
#include "third_party/blink/renderer/core/editing/editing_utilities.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/web_frame_widget_impl.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/geometry/dom_rect.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/html_text_area_element.h"
#include "third_party/blink/renderer/core/html/html_div_element.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/paint/paint_layer_scrollable_area.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/scheduler/test/fake_task_runner.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/widget/input/widget_input_handler_manager.h"
#include "third_party/blink/renderer/platform/widget/widget_base.h"
#include "ui/base/ui_base_types.h"

namespace blink {

_;

bool operator==(const InputHandlerProxy::DidOverscrollParams& lhs,
                const InputHandlerProxy::DidOverscrollParams& rhs) {}

namespace {

class TouchMoveEventListener final : public NativeEventListener {};

}  // namespace

class WebFrameWidgetSimTest : public SimTest {};

// Tests that if a WebView is auto-resized, the associated
// WebFrameWidgetImpl requests a new viz::LocalSurfaceId to be allocated on the
// impl thread.
TEST_F(WebFrameWidgetSimTest, AutoResizeAllocatedLocalSurfaceId) {}

TEST_F(WebFrameWidgetSimTest, FrameSinkIdHitTestAPI) {}

#if BUILDFLAG(IS_ANDROID)
TEST_F(WebFrameWidgetSimTest, ForceSendMetadataOnInput) {
  const cc::LayerTreeHost* layer_tree_host =
      WebView().MainFrameViewWidget()->LayerTreeHostForTesting();
  // We should not have any force send metadata requests at start.
  EXPECT_FALSE(
      layer_tree_host->pending_commit_state()->force_send_metadata_request);
  // ShowVirtualKeyboard will trigger a text input state update.
  WebView().MainFrameViewWidget()->ShowVirtualKeyboard();
  // We should now have a force send metadata request.
  EXPECT_TRUE(
      layer_tree_host->pending_commit_state()->force_send_metadata_request);
}
#endif  // BUILDFLAG(IS_ANDROID)

// A test that forces a RemoteMainFrame to be created.
class WebFrameWidgetImplRemoteFrameSimTest : public SimTest {};

// Tests that the value of VisualProperties::is_pinch_gesture_active is
// propagated to the LayerTreeHost when properties are synced for child local
// roots.
TEST_F(WebFrameWidgetImplRemoteFrameSimTest,
       ActivePinchGestureUpdatesLayerTreeHostSubFrame) {}

const char EVENT_LISTENER_RESULT_HISTOGRAM[] =;

// Keep in sync with enum defined in
// RenderWidgetInputHandler::LogPassiveEventListenersUma.
enum {};

// Since std::unique_ptr<InputHandlerProxy::DidOverscrollParams> isn't copyable
// we can't use the MockCallback template.
class MockHandledEventCallback {};

class MockWebFrameWidgetImpl : public frame_test_helpers::TestWebFrameWidget {};

class WebFrameWidgetImplSimTest : public SimTest {};

TEST_F(WebFrameWidgetImplSimTest, CursorChange) {}

TEST_F(WebFrameWidgetImplSimTest, RenderWidgetInputEventUmaMetrics) {}

// Ensures that the compositor thread gets sent the gesture event & overscroll
// amount for an overscroll initiated by a touchpad.
TEST_F(WebFrameWidgetImplSimTest, SendElasticOverscrollForTouchpad) {}

// Ensures that the compositor thread gets sent the gesture event & overscroll
// amount for an overscroll initiated by a touchscreen.
TEST_F(WebFrameWidgetImplSimTest, SendElasticOverscrollForTouchscreen) {}

TEST_F(WebFrameWidgetImplSimTest, TestStartStylusWritingForInputElement) {}

TEST_F(WebFrameWidgetImplSimTest,
       TestStartStylusWritingForContentEditableElement) {}

TEST_F(WebFrameWidgetImplSimTest,
       TestStartStylusWritingForContentEditableChildElement) {}

class NotifySwapTimesWebFrameWidgetTest : public SimTest {};

// Verifies that the presentation callback is called after the first successful
// presentation (skips failed presentations in between).
TEST_F(NotifySwapTimesWebFrameWidgetTest, NotifyOnSuccessfulPresentation) {}

// Tests that the presentation callback is only triggered if there’s
// a successful commit to the compositor.
TEST_F(NotifySwapTimesWebFrameWidgetTest,
       ReportPresentationOnlyOnSuccessfulCommit) {}

// Tests that the value of VisualProperties::is_pinch_gesture_active is
// not propagated to the LayerTreeHost when properties are synced for main
// frame.
TEST_F(WebFrameWidgetSimTest, ActivePinchGestureUpdatesLayerTreeHost) {}

class WebFrameWidgetInputEventsSimTest
    : public WebFrameWidgetSimTest,
      public testing::WithParamInterface<bool> {};

INSTANTIATE_TEST_SUITE_P();

// Tests that dispatch buffered touch events does not process events during
// drag and devtools handling.
TEST_P(WebFrameWidgetInputEventsSimTest, DispatchBufferedTouchEvents) {}

// Tests that page scale is propagated to all remote frames controlled
// by a widget.
TEST_F(WebFrameWidgetSimTest, PropagateScaleToRemoteFrames) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsAreEmptyBeforeFocus) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsAreCorrectAfterFocusChange) {}

TEST_F(WebFrameWidgetSimTest, DisplayStateMatchesWindowShowState) {}

TEST_F(WebFrameWidgetSimTest, ResizableMatchesCanResize) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsAreCorrectAfterLayoutChange) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsAreCorrectAfterPageScroll) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsAreCorrectAfterElementScroll) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsAreCorrectAfterCommit) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsAreCorrectAfterDelete) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsInFrame) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsWithDifferentZoom) {}

TEST_F(WebFrameWidgetSimTest, TestLineBoundsAreClippedInSubframe) {}

class EventHandlingWebFrameWidgetSimTest : public SimTest {};

// Verifies that when a non-rAF-aligned event is handled without causing an
// update, swap promises will be broken.
TEST_F(EventHandlingWebFrameWidgetSimTest, NonRafAlignedEventWithoutUpdate) {}

// Verifies that when a non-rAF-aligned event is handled without causing an
// update while an update is already requested, swap promises won't be broken.
TEST_F(EventHandlingWebFrameWidgetSimTest,
       NonRafAlignedEventWithoutUpdateAfterUpdate) {}

// Verifies that when a non-rAF-aligned event is handled and causes an update,
// swap promises won't be broken.
TEST_F(EventHandlingWebFrameWidgetSimTest, NonRafAlignedEventWithUpdate) {}

// Verifies that when a rAF-aligned event is handled without causing an update,
// swap promises won't be broken.
TEST_F(EventHandlingWebFrameWidgetSimTest, RafAlignedEventWithoutUpdate) {}

// Verifies that when a rAF-aligned event is handled and causes an update, swap
// promises won't be broken.
TEST_F(EventHandlingWebFrameWidgetSimTest, RafAlignedEventWithUpdate) {}

}  // namespace blink