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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 EXPECT_TRUE(ack_callback.get()); | 436 EXPECT_TRUE(ack_callback.get()); |
437 VerifyAndRunQueues(false, false); | 437 VerifyAndRunQueues(false, false); |
438 EXPECT_FALSE(test_callback->called()); | 438 EXPECT_FALSE(test_callback->called()); |
439 } | 439 } |
440 | 440 |
441 // Tests that when the renderer will not ack an event, that | 441 // Tests that when the renderer will not ack an event, that |
442 // CompositorMusConnection does not consume the ack, nor calls it. | 442 // CompositorMusConnection does not consume the ack, nor calls it. |
443 TEST_F(CompositorMusConnectionTest, RendererWillNotSendAck) { | 443 TEST_F(CompositorMusConnectionTest, RendererWillNotSendAck) { |
444 ui::TestWindow test_window; | 444 ui::TestWindow test_window; |
445 ui::PointerEvent event( | 445 ui::PointerEvent event( |
446 ui::ET_POINTER_DOWN, gfx::Point(), gfx::Point(), ui::EF_NONE, 0, | 446 ui::ET_POINTER_DOWN, gfx::Point(), gfx::Point(), ui::EF_NONE, 0, 0, |
447 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE), | 447 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE), |
448 ui::EventTimeForNow()); | 448 ui::EventTimeForNow()); |
449 | 449 |
450 scoped_refptr<TestCallback> test_callback(new TestCallback); | 450 scoped_refptr<TestCallback> test_callback(new TestCallback); |
451 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( | 451 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( |
452 new base::Callback<void(EventResult)>( | 452 new base::Callback<void(EventResult)>( |
453 base::Bind(&::TestCallback::ResultCallback, test_callback))); | 453 base::Bind(&::TestCallback::ResultCallback, test_callback))); |
454 | 454 |
455 OnWindowInputEvent(&test_window, event, &ack_callback); | 455 OnWindowInputEvent(&test_window, event, &ack_callback); |
456 EXPECT_TRUE(ack_callback.get()); | 456 EXPECT_TRUE(ack_callback.get()); |
457 | 457 |
458 VerifyAndRunQueues(true, false); | 458 VerifyAndRunQueues(true, false); |
459 EXPECT_FALSE(test_callback->called()); | 459 EXPECT_FALSE(test_callback->called()); |
460 } | 460 } |
461 | 461 |
462 // Tests that when a touch event id provided, that CompositorMusConnection | 462 // Tests that when a touch event id provided, that CompositorMusConnection |
463 // consumes the ack. | 463 // consumes the ack. |
464 TEST_F(CompositorMusConnectionTest, TouchEventConsumed) { | 464 TEST_F(CompositorMusConnectionTest, TouchEventConsumed) { |
465 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); | 465 TestRenderWidgetInputHandler* input_handler = render_widget_input_handler(); |
466 input_handler->set_delegate(connection()); | 466 input_handler->set_delegate(connection()); |
467 input_handler->set_state(InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); | 467 input_handler->set_state(InputEventAckState::INPUT_EVENT_ACK_STATE_CONSUMED); |
468 | 468 |
469 ui::TestWindow test_window; | 469 ui::TestWindow test_window; |
470 ui::PointerEvent event( | 470 ui::PointerEvent event( |
471 ui::ET_POINTER_DOWN, gfx::Point(), gfx::Point(), ui::EF_NONE, 0, | 471 ui::ET_POINTER_DOWN, gfx::Point(), gfx::Point(), ui::EF_NONE, 0, 0, |
472 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH), | 472 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH), |
473 ui::EventTimeForNow()); | 473 ui::EventTimeForNow()); |
474 | 474 |
475 scoped_refptr<TestCallback> test_callback(new TestCallback); | 475 scoped_refptr<TestCallback> test_callback(new TestCallback); |
476 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( | 476 std::unique_ptr<base::Callback<void(EventResult)>> ack_callback( |
477 new base::Callback<void(EventResult)>( | 477 new base::Callback<void(EventResult)>( |
478 base::Bind(&::TestCallback::ResultCallback, test_callback))); | 478 base::Bind(&::TestCallback::ResultCallback, test_callback))); |
479 | 479 |
480 OnWindowInputEvent(&test_window, event, &ack_callback); | 480 OnWindowInputEvent(&test_window, event, &ack_callback); |
481 // OnWindowInputEvent is expected to clear the callback if it plans on | 481 // OnWindowInputEvent is expected to clear the callback if it plans on |
482 // handling the ack. | 482 // handling the ack. |
483 EXPECT_FALSE(ack_callback.get()); | 483 EXPECT_FALSE(ack_callback.get()); |
484 | 484 |
485 VerifyAndRunQueues(true, true); | 485 VerifyAndRunQueues(true, true); |
486 | 486 |
487 // The ack callback should have been called | 487 // The ack callback should have been called |
488 EXPECT_TRUE(test_callback->called()); | 488 EXPECT_TRUE(test_callback->called()); |
489 EXPECT_EQ(EventResult::HANDLED, test_callback->result()); | 489 EXPECT_EQ(EventResult::HANDLED, test_callback->result()); |
490 } | 490 } |
491 | 491 |
492 } // namespace content | 492 } // namespace content |
OLD | NEW |