Commit 7751fadb authored by Jonathan Ross's avatar Jonathan Ross Committed by Commit Bot

Mock Viz Hit Testing in RenderWidgetHostInputEventRouterTest

RenderWidgetHostInputEventRouterTest has some heavy overrides of the classic hit testing path, to force what target is used when. With these the test never actually set sizes, or correct FrameSinkIds, on the views in use.

However in Viz RenderWidgetHostInputEventRouter::FindViewAtLocation uses a
completely different method for determining targets while in Viz Hit Testing
Mode.

This change updates the test to als provide mock hit testing data.

A test wrapper HostFrameSinkManagerTestApi was added to allow for the setting
of hit testing data while in unittests. Or in testing where Viz is not actually
initialized.

TEST=RenderWidgetHostInputEventRouterTest

Bug: 796605
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: I66c4322f70fdd8c5be07c3560110519153370cff
Reviewed-on: https://chromium-review.googlesource.com/1145773
Commit-Queue: Jonathan Ross <jonross@chromium.org>
Reviewed-by: default avatarRia Jiang <riajiang@chromium.org>
Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578723}
parent 2e857b37
...@@ -179,6 +179,7 @@ class VIZ_HOST_EXPORT HostFrameSinkManager ...@@ -179,6 +179,7 @@ class VIZ_HOST_EXPORT HostFrameSinkManager
uint32_t frame_token) override; uint32_t frame_token) override;
private: private:
friend class HostFrameSinkManagerTestApi;
friend class HostFrameSinkManagerTestBase; friend class HostFrameSinkManagerTestBase;
struct FrameSinkData { struct FrameSinkData {
......
...@@ -25,6 +25,8 @@ viz_static_library("test_support") { ...@@ -25,6 +25,8 @@ viz_static_library("test_support") {
"fake_output_surface.h", "fake_output_surface.h",
"fake_surface_observer.cc", "fake_surface_observer.cc",
"fake_surface_observer.h", "fake_surface_observer.h",
"host_frame_sink_manager_test_api.cc",
"host_frame_sink_manager_test_api.h",
"mock_compositor_frame_sink_client.cc", "mock_compositor_frame_sink_client.cc",
"mock_compositor_frame_sink_client.h", "mock_compositor_frame_sink_client.h",
"mock_display_client.cc", "mock_display_client.cc",
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/viz/test/host_frame_sink_manager_test_api.h"
namespace viz {
HostFrameSinkManagerTestApi::HostFrameSinkManagerTestApi(
HostFrameSinkManager* host_frame_sink_manager)
: host_frame_sink_manager_(host_frame_sink_manager) {}
void HostFrameSinkManagerTestApi::SetDisplayHitTestQuery(
HostFrameSinkManager::DisplayHitTestQueryMap map) {
host_frame_sink_manager_->display_hit_test_query_.clear();
host_frame_sink_manager_->display_hit_test_query_ = std::move(map);
}
} // namespace viz
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_VIZ_TEST_HOST_FRAME_SINK_MANAGER_TEST_API_H_
#define COMPONENTS_VIZ_TEST_HOST_FRAME_SINK_MANAGER_TEST_API_H_
#include "base/macros.h"
#include "components/viz/host/host_frame_sink_manager.h"
namespace viz {
// A test wrapper for HostFrameSinkManager. For use in unit testing, where the
// Viz Host never instanciates Viz. Without Viz, HostFrameSinkManager can never
// actually establish connections to compositor frame sinks.
//
// This allows for the explicit overriding of the hit test data with the
// HostFrameSinkManager. So that unit tests can test event routing without Viz
// providing the hit test data.
class HostFrameSinkManagerTestApi {
public:
explicit HostFrameSinkManagerTestApi(
HostFrameSinkManager* host_frame_sink_manager);
~HostFrameSinkManagerTestApi() = default;
// Clears out the currently set hit test queries, and overrides it with |map|.
// The HostFrameSinkManager will take ownership of |map|. There should only be
// one HitTestQuery per root FrameSinkId.
void SetDisplayHitTestQuery(HostFrameSinkManager::DisplayHitTestQueryMap map);
private:
// Not owned.
HostFrameSinkManager* host_frame_sink_manager_;
DISALLOW_COPY_AND_ASSIGN(HostFrameSinkManagerTestApi);
};
} // namespace viz
#endif // COMPONENTS_VIZ_TEST_HOST_FRAME_SINK_MANAGER_TEST_API_H_
# Not finding the correct target crbug.com/796605
-RenderWidgetHostInputEventRouterTest.DoNotChangeTargetViewDuringTouchScrollGesture
-RenderWidgetHostInputEventRouterTest.DoNotCoalesceGestureEvents
-RenderWidgetHostInputEventRouterTest.DoNotCoalesceTouchEvents
# TODO(crbug.com/601869): Reflector needs to be rewritten for viz. # TODO(crbug.com/601869): Reflector needs to be rewritten for viz.
-ReflectorImplTest.* -ReflectorImplTest.*
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment