Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(950)

Unified Diff: content/renderer/mus/compositor_mus_connection_unittest.cc

Issue 2265393002: Refactor compositor event handling path to be callback-based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: creis's review, rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/mus/compositor_mus_connection_unittest.cc
diff --git a/content/renderer/mus/compositor_mus_connection_unittest.cc b/content/renderer/mus/compositor_mus_connection_unittest.cc
index e9ee52f4fef6231bd28ed800e5f25ec50489b80c..36bc22eb49266e10434596d0ebacbe26c21ce4ac 100644
--- a/content/renderer/mus/compositor_mus_connection_unittest.cc
+++ b/content/renderer/mus/compositor_mus_connection_unittest.cc
@@ -79,10 +79,10 @@ class TestInputHandlerManager : public content::InputHandlerManager {
void SetHandleInputEventResult(content::InputEventAckState result);
// content::InputHandlerManager:
- content::InputEventAckState HandleInputEvent(
- int routing_id,
- const blink::WebInputEvent* input_event,
- ui::LatencyInfo* latency_info) override;
+ void HandleInputEvent(int routing_id,
+ ui::ScopedWebInputEvent input_event,
+ const ui::LatencyInfo& latency_info,
+ const InputEventAckStateCallback& callback) override;
private:
// If true content::InputHandlerManager::HandleInputEvent is not called.
@@ -104,14 +104,17 @@ void TestInputHandlerManager::SetHandleInputEventResult(
result_ = result;
}
-content::InputEventAckState TestInputHandlerManager::HandleInputEvent(
+void TestInputHandlerManager::HandleInputEvent(
int routing_id,
- const blink::WebInputEvent* input_event,
- ui::LatencyInfo* latency_info) {
- if (override_result_)
- return result_;
- return content::InputHandlerManager::HandleInputEvent(routing_id, input_event,
- latency_info);
+ ui::ScopedWebInputEvent input_event,
+ const ui::LatencyInfo& latency_info,
+ const InputEventAckStateCallback& callback) {
+ if (override_result_) {
+ callback.Run(result_, std::move(input_event), latency_info, nullptr);
+ return;
+ }
+ content::InputHandlerManager::HandleInputEvent(
+ routing_id, std::move(input_event), latency_info, callback);
}
// Empty implementation of InputHandlerManagerClient.
@@ -422,7 +425,7 @@ TEST_F(CompositorMusConnectionTest, LostAck) {
}
// Tests that when an input handler consumes the event, that
-// CompositorMusConnection does not consume the ack, nor calls it.
+// CompositorMusConnection will consume the ack, but call as UNHANDLED.
TEST_F(CompositorMusConnectionTest, InputHandlerConsumes) {
input_handler_manager()->SetHandleInputEventResult(
InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED);
@@ -435,13 +438,14 @@ TEST_F(CompositorMusConnectionTest, InputHandlerConsumes) {
OnWindowInputEvent(&test_window, *event.get(), &ack_callback);
- EXPECT_TRUE(ack_callback.get());
+ EXPECT_FALSE(ack_callback.get());
VerifyAndRunQueues(false, false);
- EXPECT_FALSE(test_callback->called());
+ EXPECT_TRUE(test_callback->called());
+ EXPECT_EQ(EventResult::UNHANDLED, test_callback->result());
}
// Tests that when the renderer will not ack an event, that
-// CompositorMusConnection does not consume the ack, nor calls it.
+// CompositorMusConnection will consume the ack, but call as UNHANDLED.
TEST_F(CompositorMusConnectionTest, RendererWillNotSendAck) {
ui::TestWindow test_window;
ui::PointerEvent event(
@@ -455,10 +459,11 @@ TEST_F(CompositorMusConnectionTest, RendererWillNotSendAck) {
base::Bind(&::TestCallback::ResultCallback, test_callback)));
OnWindowInputEvent(&test_window, event, &ack_callback);
- EXPECT_TRUE(ack_callback.get());
+ EXPECT_FALSE(ack_callback.get());
VerifyAndRunQueues(true, false);
- EXPECT_FALSE(test_callback->called());
+ EXPECT_TRUE(test_callback->called());
+ EXPECT_EQ(EventResult::UNHANDLED, test_callback->result());
}
// Tests that when a touch event id provided, that CompositorMusConnection
« no previous file with comments | « content/renderer/mus/compositor_mus_connection.cc ('k') | content/renderer/mus/render_widget_mus_connection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698