| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/mus/compositor_mus_connection.h" | 5 #include "content/renderer/mus/compositor_mus_connection.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "content/renderer/input/input_handler_manager_client.h" | 22 #include "content/renderer/input/input_handler_manager_client.h" |
| 23 #include "content/renderer/input/render_widget_input_handler.h" | 23 #include "content/renderer/input/render_widget_input_handler.h" |
| 24 #include "content/renderer/mus/render_widget_mus_connection.h" | 24 #include "content/renderer/mus/render_widget_mus_connection.h" |
| 25 #include "content/renderer/render_widget.h" | 25 #include "content/renderer/render_widget.h" |
| 26 #include "content/test/fake_compositor_dependencies.h" | 26 #include "content/test/fake_compositor_dependencies.h" |
| 27 #include "content/test/fake_renderer_scheduler.h" | 27 #include "content/test/fake_renderer_scheduler.h" |
| 28 #include "mojo/public/cpp/bindings/interface_request.h" | 28 #include "mojo/public/cpp/bindings/interface_request.h" |
| 29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 30 #include "ui/events/event_utils.h" | 30 #include "ui/events/event_utils.h" |
| 31 | 31 |
| 32 using mus::mojom::EventResult; |
| 33 |
| 32 namespace { | 34 namespace { |
| 33 | 35 |
| 34 // Wrapper for the callback provided to | 36 // Wrapper for the callback provided to |
| 35 // CompositorMusConnection:OnWindowInputEvent. This tracks whether the it was | 37 // CompositorMusConnection:OnWindowInputEvent. This tracks whether the it was |
| 36 // called, along with the result. | 38 // called, along with the result. |
| 37 class TestCallback : public base::RefCounted<TestCallback> { | 39 class TestCallback : public base::RefCounted<TestCallback> { |
| 38 public: | 40 public: |
| 39 TestCallback() : called_(false), result_(false) {} | 41 TestCallback() : called_(false), result_(EventResult::UNHANDLED) {} |
| 40 | 42 |
| 41 bool called() { return called_; } | 43 bool called() { return called_; } |
| 42 bool result() { return result_; } | 44 EventResult result() { return result_; } |
| 43 | 45 |
| 44 void BoolCallback(bool result) { | 46 void ResultCallback(EventResult result) { |
| 45 called_ = true; | 47 called_ = true; |
| 46 result_ = result; | 48 result_ = result; |
| 47 } | 49 } |
| 48 | 50 |
| 49 private: | 51 private: |
| 50 friend class base::RefCounted<TestCallback>; | 52 friend class base::RefCounted<TestCallback>; |
| 51 | 53 |
| 52 ~TestCallback() {} | 54 ~TestCallback() {} |
| 53 | 55 |
| 54 bool called_; | 56 bool called_; |
| 55 bool result_; | 57 EventResult result_; |
| 56 | 58 |
| 57 DISALLOW_COPY_AND_ASSIGN(TestCallback); | 59 DISALLOW_COPY_AND_ASSIGN(TestCallback); |
| 58 }; | 60 }; |
| 59 | 61 |
| 60 // Allows for overriding the behaviour of HandleInputEvent, to simulate input | 62 // Allows for overriding the behaviour of HandleInputEvent, to simulate input |
| 61 // handlers which consume events before they are sent to the renderer. | 63 // handlers which consume events before they are sent to the renderer. |
| 62 class TestInputHandlerManager : public content::InputHandlerManager { | 64 class TestInputHandlerManager : public content::InputHandlerManager { |
| 63 public: | 65 public: |
| 64 TestInputHandlerManager( | 66 TestInputHandlerManager( |
| 65 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 67 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 ~CompositorMusConnectionTest() override {} | 212 ~CompositorMusConnectionTest() override {} |
| 211 | 213 |
| 212 // Returns a valid key event, so that it can be converted to a web event by | 214 // Returns a valid key event, so that it can be converted to a web event by |
| 213 // CompositorMusConnection. | 215 // CompositorMusConnection. |
| 214 std::unique_ptr<ui::Event> GenerateKeyEvent(); | 216 std::unique_ptr<ui::Event> GenerateKeyEvent(); |
| 215 | 217 |
| 216 // Calls CompositorMusConnection::OnWindowInputEvent. | 218 // Calls CompositorMusConnection::OnWindowInputEvent. |
| 217 void OnWindowInputEvent( | 219 void OnWindowInputEvent( |
| 218 mus::Window* window, | 220 mus::Window* window, |
| 219 const ui::Event& event, | 221 const ui::Event& event, |
| 220 std::unique_ptr<base::Callback<void(bool)>>* ack_callback); | 222 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback); |
| 221 | 223 |
| 222 // Confirms the state of pending tasks enqueued on each task runner, and runs | 224 // Confirms the state of pending tasks enqueued on each task runner, and runs |
| 223 // until idle. | 225 // until idle. |
| 224 void VerifyAndRunQueues(bool main_task_runner_enqueued, | 226 void VerifyAndRunQueues(bool main_task_runner_enqueued, |
| 225 bool compositor_task_runner_enqueued); | 227 bool compositor_task_runner_enqueued); |
| 226 | 228 |
| 227 CompositorMusConnection* compositor_connection() { | 229 CompositorMusConnection* compositor_connection() { |
| 228 return compositor_connection_.get(); | 230 return compositor_connection_.get(); |
| 229 } | 231 } |
| 230 RenderWidgetMusConnection* connection() { return connection_; } | 232 RenderWidgetMusConnection* connection() { return connection_; } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 }; | 269 }; |
| 268 | 270 |
| 269 std::unique_ptr<ui::Event> CompositorMusConnectionTest::GenerateKeyEvent() { | 271 std::unique_ptr<ui::Event> CompositorMusConnectionTest::GenerateKeyEvent() { |
| 270 return std::unique_ptr<ui::Event>(new ui::KeyEvent( | 272 return std::unique_ptr<ui::Event>(new ui::KeyEvent( |
| 271 ui::ET_KEY_PRESSED, ui::KeyboardCode::VKEY_A, ui::EF_NONE)); | 273 ui::ET_KEY_PRESSED, ui::KeyboardCode::VKEY_A, ui::EF_NONE)); |
| 272 } | 274 } |
| 273 | 275 |
| 274 void CompositorMusConnectionTest::OnWindowInputEvent( | 276 void CompositorMusConnectionTest::OnWindowInputEvent( |
| 275 mus::Window* window, | 277 mus::Window* window, |
| 276 const ui::Event& event, | 278 const ui::Event& event, |
| 277 std::unique_ptr<base::Callback<void(bool)>>* ack_callback) { | 279 std::unique_ptr<base::Callback<void(EventResult)>>* ack_callback) { |
| 278 compositor_connection_->OnWindowInputEvent(window, event, ack_callback); | 280 compositor_connection_->OnWindowInputEvent(window, event, ack_callback); |
| 279 } | 281 } |
| 280 | 282 |
| 281 void CompositorMusConnectionTest::VerifyAndRunQueues( | 283 void CompositorMusConnectionTest::VerifyAndRunQueues( |
| 282 bool main_task_runner_enqueued, | 284 bool main_task_runner_enqueued, |
| 283 bool compositor_task_runner_enqueued) { | 285 bool compositor_task_runner_enqueued) { |
| 284 // Run through the enqueued actions. | 286 // Run through the enqueued actions. |
| 285 EXPECT_EQ(main_task_runner_enqueued, main_task_runner_->HasPendingTask()); | 287 EXPECT_EQ(main_task_runner_enqueued, main_task_runner_->HasPendingTask()); |
| 286 main_task_runner_->RunUntilIdle(); | 288 main_task_runner_->RunUntilIdle(); |
| 287 | 289 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 // it with the correct state once processed. | 329 // it with the correct state once processed. |
| 328 TEST_F(CompositorMusConnectionTest, NotConsumed) { | 330 TEST_F(CompositorMusConnectionTest, NotConsumed) { |
| 329 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); | 331 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); |
| 330 input_handler->set_delegate(connection()); | 332 input_handler->set_delegate(connection()); |
| 331 input_handler->set_state( | 333 input_handler->set_state( |
| 332 InputEventAckState::INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 334 InputEventAckState::INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
| 333 | 335 |
| 334 mus::TestWindow test_window; | 336 mus::TestWindow test_window; |
| 335 std::unique_ptr<ui::Event> event(GenerateKeyEvent()); | 337 std::unique_ptr<ui::Event> event(GenerateKeyEvent()); |
| 336 scoped_refptr<TestCallback> test_callback(new TestCallback); | 338 scoped_refptr<TestCallback> test_callback(new TestCallback); |
| 337 std::unique_ptr<base::Callback<void(bool)>> ack_callback( | 339 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( |
| 338 new base::Callback<void(bool)>( | 340 new base::Callback<void(EventResult)>( |
| 339 base::Bind(&::TestCallback::BoolCallback, test_callback))); | 341 base::Bind(&::TestCallback::ResultCallback, test_callback))); |
| 340 | 342 |
| 341 OnWindowInputEvent(&test_window, *event.get(), &ack_callback); | 343 OnWindowInputEvent(&test_window, *event.get(), &ack_callback); |
| 342 // OnWindowInputEvent is expected to clear the callback if it plans on | 344 // OnWindowInputEvent is expected to clear the callback if it plans on |
| 343 // handling the ack. | 345 // handling the ack. |
| 344 EXPECT_FALSE(ack_callback.get()); | 346 EXPECT_FALSE(ack_callback.get()); |
| 345 | 347 |
| 346 VerifyAndRunQueues(true, true); | 348 VerifyAndRunQueues(true, true); |
| 347 | 349 |
| 348 // The ack callback should have been called | 350 // The ack callback should have been called |
| 349 EXPECT_TRUE(test_callback->called()); | 351 EXPECT_TRUE(test_callback->called()); |
| 350 EXPECT_FALSE(test_callback->result()); | 352 EXPECT_EQ(EventResult::UNHANDLED, test_callback->result()); |
| 351 } | 353 } |
| 352 | 354 |
| 353 // Tests that for events which the renderer will ack, and consume, that | 355 // Tests that for events which the renderer will ack, and consume, that |
| 354 // CompositorMusConnection consumes the ack during OnWindowInputEvent, and calls | 356 // CompositorMusConnection consumes the ack during OnWindowInputEvent, and calls |
| 355 // it with the correct state once processed. | 357 // it with the correct state once processed. |
| 356 TEST_F(CompositorMusConnectionTest, Consumed) { | 358 TEST_F(CompositorMusConnectionTest, Consumed) { |
| 357 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); | 359 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); |
| 358 input_handler->set_delegate(connection()); | 360 input_handler->set_delegate(connection()); |
| 359 input_handler->set_state(InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); | 361 input_handler->set_state(InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); |
| 360 | 362 |
| 361 mus::TestWindow test_window; | 363 mus::TestWindow test_window; |
| 362 std::unique_ptr<ui::Event> event(GenerateKeyEvent()); | 364 std::unique_ptr<ui::Event> event(GenerateKeyEvent()); |
| 363 scoped_refptr<TestCallback> test_callback(new TestCallback); | 365 scoped_refptr<TestCallback> test_callback(new TestCallback); |
| 364 std::unique_ptr<base::Callback<void(bool)>> ack_callback( | 366 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( |
| 365 new base::Callback<void(bool)>( | 367 new base::Callback<void(EventResult)>( |
| 366 base::Bind(&::TestCallback::BoolCallback, test_callback))); | 368 base::Bind(&::TestCallback::ResultCallback, test_callback))); |
| 367 | 369 |
| 368 OnWindowInputEvent(&test_window, *event.get(), &ack_callback); | 370 OnWindowInputEvent(&test_window, *event.get(), &ack_callback); |
| 369 // OnWindowInputEvent is expected to clear the callback if it plans on | 371 // OnWindowInputEvent is expected to clear the callback if it plans on |
| 370 // handling the ack. | 372 // handling the ack. |
| 371 EXPECT_FALSE(ack_callback.get()); | 373 EXPECT_FALSE(ack_callback.get()); |
| 372 | 374 |
| 373 VerifyAndRunQueues(true, true); | 375 VerifyAndRunQueues(true, true); |
| 374 | 376 |
| 375 // The ack callback should have been called | 377 // The ack callback should have been called |
| 376 EXPECT_TRUE(test_callback->called()); | 378 EXPECT_TRUE(test_callback->called()); |
| 377 EXPECT_TRUE(test_callback->result()); | 379 EXPECT_EQ(EventResult::HANDLED, test_callback->result()); |
| 378 } | 380 } |
| 379 | 381 |
| 380 // Tests that when the RenderWidgetInputHandler does not ack before a new event | 382 // Tests that when the RenderWidgetInputHandler does not ack before a new event |
| 381 // arrives, that only the most recent ack is fired. | 383 // arrives, that only the most recent ack is fired. |
| 382 TEST_F(CompositorMusConnectionTest, LostAck) { | 384 TEST_F(CompositorMusConnectionTest, LostAck) { |
| 383 mus::TestWindow test_window; | 385 mus::TestWindow test_window; |
| 384 std::unique_ptr<ui::Event> event1(GenerateKeyEvent()); | 386 std::unique_ptr<ui::Event> event1(GenerateKeyEvent()); |
| 385 scoped_refptr<TestCallback> test_callback1(new TestCallback); | 387 scoped_refptr<TestCallback> test_callback1(new TestCallback); |
| 386 std::unique_ptr<base::Callback<void(bool)>> ack_callback1( | 388 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback1( |
| 387 new base::Callback<void(bool)>( | 389 new base::Callback<void(EventResult)>( |
| 388 base::Bind(&::TestCallback::BoolCallback, test_callback1))); | 390 base::Bind(&::TestCallback::ResultCallback, test_callback1))); |
| 389 | 391 |
| 390 OnWindowInputEvent(&test_window, *event1.get(), &ack_callback1); | 392 OnWindowInputEvent(&test_window, *event1.get(), &ack_callback1); |
| 391 EXPECT_FALSE(ack_callback1.get()); | 393 EXPECT_FALSE(ack_callback1.get()); |
| 392 // When simulating the timeout the ack is never enqueued | 394 // When simulating the timeout the ack is never enqueued |
| 393 VerifyAndRunQueues(true, false); | 395 VerifyAndRunQueues(true, false); |
| 394 | 396 |
| 395 // Setting a delegate will lead to the next event being acked. Having a | 397 // Setting a delegate will lead to the next event being acked. Having a |
| 396 // cleared queue simulates the input handler timing out on an event. | 398 // cleared queue simulates the input handler timing out on an event. |
| 397 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); | 399 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); |
| 398 input_handler->set_delegate(connection()); | 400 input_handler->set_delegate(connection()); |
| 399 input_handler->set_state(InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); | 401 input_handler->set_state(InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); |
| 400 | 402 |
| 401 std::unique_ptr<ui::Event> event2(GenerateKeyEvent()); | 403 std::unique_ptr<ui::Event> event2(GenerateKeyEvent()); |
| 402 scoped_refptr<TestCallback> test_callback2(new TestCallback); | 404 scoped_refptr<TestCallback> test_callback2(new TestCallback); |
| 403 std::unique_ptr<base::Callback<void(bool)>> ack_callback2( | 405 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback2( |
| 404 new base::Callback<void(bool)>( | 406 new base::Callback<void(EventResult)>( |
| 405 base::Bind(&::TestCallback::BoolCallback, test_callback2))); | 407 base::Bind(&::TestCallback::ResultCallback, test_callback2))); |
| 406 OnWindowInputEvent(&test_window, *event2.get(), &ack_callback2); | 408 OnWindowInputEvent(&test_window, *event2.get(), &ack_callback2); |
| 407 EXPECT_FALSE(ack_callback2.get()); | 409 EXPECT_FALSE(ack_callback2.get()); |
| 408 | 410 |
| 409 VerifyAndRunQueues(true, true); | 411 VerifyAndRunQueues(true, true); |
| 410 | 412 |
| 411 // Only the most recent ack was called. | 413 // Only the most recent ack was called. |
| 412 EXPECT_FALSE(test_callback1->called()); | 414 EXPECT_FALSE(test_callback1->called()); |
| 413 EXPECT_TRUE(test_callback2->called()); | 415 EXPECT_TRUE(test_callback2->called()); |
| 414 EXPECT_TRUE(test_callback2->result()); | 416 EXPECT_EQ(EventResult::HANDLED, test_callback2->result()); |
| 415 } | 417 } |
| 416 | 418 |
| 417 // Tests that when an input handler consumes the event, that | 419 // Tests that when an input handler consumes the event, that |
| 418 // CompositorMusConnection does not consume the ack, nor calls it. | 420 // CompositorMusConnection does not consume the ack, nor calls it. |
| 419 TEST_F(CompositorMusConnectionTest, InputHandlerConsumes) { | 421 TEST_F(CompositorMusConnectionTest, InputHandlerConsumes) { |
| 420 input_handler_manager()->SetHandleInputEventResult( | 422 input_handler_manager()->SetHandleInputEventResult( |
| 421 InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); | 423 InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); |
| 422 mus::TestWindow test_window; | 424 mus::TestWindow test_window; |
| 423 std::unique_ptr<ui::Event> event(GenerateKeyEvent()); | 425 std::unique_ptr<ui::Event> event(GenerateKeyEvent()); |
| 424 scoped_refptr<TestCallback> test_callback(new TestCallback); | 426 scoped_refptr<TestCallback> test_callback(new TestCallback); |
| 425 std::unique_ptr<base::Callback<void(bool)>> ack_callback( | 427 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( |
| 426 new base::Callback<void(bool)>( | 428 new base::Callback<void(EventResult)>( |
| 427 base::Bind(&::TestCallback::BoolCallback, test_callback))); | 429 base::Bind(&::TestCallback::ResultCallback, test_callback))); |
| 428 | 430 |
| 429 OnWindowInputEvent(&test_window, *event.get(), &ack_callback); | 431 OnWindowInputEvent(&test_window, *event.get(), &ack_callback); |
| 430 | 432 |
| 431 EXPECT_TRUE(ack_callback.get()); | 433 EXPECT_TRUE(ack_callback.get()); |
| 432 VerifyAndRunQueues(false, false); | 434 VerifyAndRunQueues(false, false); |
| 433 EXPECT_FALSE(test_callback->called()); | 435 EXPECT_FALSE(test_callback->called()); |
| 434 } | 436 } |
| 435 | 437 |
| 436 // Tests that when the renderer will not ack an event, that | 438 // Tests that when the renderer will not ack an event, that |
| 437 // CompositorMusConnection does not consume the ack, nor calls it. | 439 // CompositorMusConnection does not consume the ack, nor calls it. |
| 438 TEST_F(CompositorMusConnectionTest, RendererWillNotSendAck) { | 440 TEST_F(CompositorMusConnectionTest, RendererWillNotSendAck) { |
| 439 mus::TestWindow test_window; | 441 mus::TestWindow test_window; |
| 440 ui::PointerEvent event(ui::ET_POINTER_DOWN, | 442 ui::PointerEvent event(ui::ET_POINTER_DOWN, |
| 441 ui::EventPointerType::POINTER_TYPE_MOUSE, gfx::Point(), | 443 ui::EventPointerType::POINTER_TYPE_MOUSE, gfx::Point(), |
| 442 gfx::Point(), ui::EF_NONE, 0, ui::EventTimeForNow()); | 444 gfx::Point(), ui::EF_NONE, 0, ui::EventTimeForNow()); |
| 443 | 445 |
| 444 scoped_refptr<TestCallback> test_callback(new TestCallback); | 446 scoped_refptr<TestCallback> test_callback(new TestCallback); |
| 445 std::unique_ptr<base::Callback<void(bool)>> ack_callback( | 447 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( |
| 446 new base::Callback<void(bool)>( | 448 new base::Callback<void(EventResult)>( |
| 447 base::Bind(&::TestCallback::BoolCallback, test_callback))); | 449 base::Bind(&::TestCallback::ResultCallback, test_callback))); |
| 448 | 450 |
| 449 OnWindowInputEvent(&test_window, event, &ack_callback); | 451 OnWindowInputEvent(&test_window, event, &ack_callback); |
| 450 EXPECT_TRUE(ack_callback.get()); | 452 EXPECT_TRUE(ack_callback.get()); |
| 451 | 453 |
| 452 VerifyAndRunQueues(true, false); | 454 VerifyAndRunQueues(true, false); |
| 453 EXPECT_FALSE(test_callback->called()); | 455 EXPECT_FALSE(test_callback->called()); |
| 454 } | 456 } |
| 455 | 457 |
| 456 // Tests that when a touch event id provided, that CompositorMusConnection | 458 // Tests that when a touch event id provided, that CompositorMusConnection |
| 457 // consumes the ack. | 459 // consumes the ack. |
| 458 TEST_F(CompositorMusConnectionTest, TouchEventConsumed) { | 460 TEST_F(CompositorMusConnectionTest, TouchEventConsumed) { |
| 459 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); | 461 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); |
| 460 input_handler->set_delegate(connection()); | 462 input_handler->set_delegate(connection()); |
| 461 input_handler->set_state(InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); | 463 input_handler->set_state(InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); |
| 462 | 464 |
| 463 mus::TestWindow test_window; | 465 mus::TestWindow test_window; |
| 464 ui::PointerEvent event(ui::ET_POINTER_DOWN, | 466 ui::PointerEvent event(ui::ET_POINTER_DOWN, |
| 465 ui::EventPointerType::POINTER_TYPE_TOUCH, gfx::Point(), | 467 ui::EventPointerType::POINTER_TYPE_TOUCH, gfx::Point(), |
| 466 gfx::Point(), ui::EF_NONE, 0, ui::EventTimeForNow()); | 468 gfx::Point(), ui::EF_NONE, 0, ui::EventTimeForNow()); |
| 467 | 469 |
| 468 scoped_refptr<TestCallback> test_callback(new TestCallback); | 470 scoped_refptr<TestCallback> test_callback(new TestCallback); |
| 469 scoped_ptr<base::Callback<void(bool)>> ack_callback( | 471 scoped_ptr<base::Callback<void(EventResult)>> ack_callback( |
| 470 new base::Callback<void(bool)>( | 472 new base::Callback<void(EventResult)>( |
| 471 base::Bind(&::TestCallback::BoolCallback, test_callback))); | 473 base::Bind(&::TestCallback::ResultCallback, test_callback))); |
| 472 | 474 |
| 473 OnWindowInputEvent(&test_window, event, &ack_callback); | 475 OnWindowInputEvent(&test_window, event, &ack_callback); |
| 474 // OnWindowInputEvent is expected to clear the callback if it plans on | 476 // OnWindowInputEvent is expected to clear the callback if it plans on |
| 475 // handling the ack. | 477 // handling the ack. |
| 476 EXPECT_FALSE(ack_callback.get()); | 478 EXPECT_FALSE(ack_callback.get()); |
| 477 | 479 |
| 478 VerifyAndRunQueues(true, true); | 480 VerifyAndRunQueues(true, true); |
| 479 | 481 |
| 480 // The ack callback should have been called | 482 // The ack callback should have been called |
| 481 EXPECT_TRUE(test_callback->called()); | 483 EXPECT_TRUE(test_callback->called()); |
| 482 EXPECT_TRUE(test_callback->result()); | 484 EXPECT_EQ(EventResult::HANDLED, test_callback->result()); |
| 483 } | 485 } |
| 484 | 486 |
| 485 } // namespace content | 487 } // namespace content |
| OLD | NEW |