| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #include <Cocoa/Cocoa.h> | 7 #include <Cocoa/Cocoa.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 1369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 ASSERT_EQ(2U, process_host->sink().message_count()); | 1380 ASSERT_EQ(2U, process_host->sink().message_count()); |
| 1381 process_host->sink().ClearMessages(); | 1381 process_host->sink().ClearMessages(); |
| 1382 | 1382 |
| 1383 // Send a wheel event with phaseEnded. When wheel scroll latching is enabled | 1383 // Send a wheel event with phaseEnded. When wheel scroll latching is enabled |
| 1384 // the event will be dropped and the mouse_wheel_end_dispatch_timer_ will | 1384 // the event will be dropped and the mouse_wheel_end_dispatch_timer_ will |
| 1385 // start. | 1385 // start. |
| 1386 NSEvent* wheelEvent2 = | 1386 NSEvent* wheelEvent2 = |
| 1387 MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); | 1387 MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); |
| 1388 [view->cocoa_view() scrollWheel:wheelEvent2]; | 1388 [view->cocoa_view() scrollWheel:wheelEvent2]; |
| 1389 ASSERT_EQ(0U, process_host->sink().message_count()); | 1389 ASSERT_EQ(0U, process_host->sink().message_count()); |
| 1390 DCHECK(view->HasPendingWheelEndEvent()); | 1390 DCHECK(view->HasPendingWheelEndEventForTesting()); |
| 1391 process_host->sink().ClearMessages(); | 1391 process_host->sink().ClearMessages(); |
| 1392 | 1392 |
| 1393 host->ShutdownAndDestroyWidget(true); | 1393 host->ShutdownAndDestroyWidget(true); |
| 1394 } | 1394 } |
| 1395 | 1395 |
| 1396 TEST_F(RenderWidgetHostViewMacWithWheelScrollLatchingEnabledTest, | 1396 TEST_F(RenderWidgetHostViewMacWithWheelScrollLatchingEnabledTest, |
| 1397 WheelWithMomentumPhaseBeganStopsTheWheelEndDispatchTimer) { | 1397 WheelWithMomentumPhaseBeganStopsTheWheelEndDispatchTimer) { |
| 1398 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than | 1398 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than |
| 1399 // the MockRenderProcessHost that is set up by the test harness which mocks | 1399 // the MockRenderProcessHost that is set up by the test harness which mocks |
| 1400 // out |OnMessageReceived()|. | 1400 // out |OnMessageReceived()|. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1426 ASSERT_EQ(2U, process_host->sink().message_count()); | 1426 ASSERT_EQ(2U, process_host->sink().message_count()); |
| 1427 process_host->sink().ClearMessages(); | 1427 process_host->sink().ClearMessages(); |
| 1428 | 1428 |
| 1429 // Send a wheel event with phaseEnded. When wheel scroll latching is enabled | 1429 // Send a wheel event with phaseEnded. When wheel scroll latching is enabled |
| 1430 // the event will be dropped and the mouse_wheel_end_dispatch_timer_ will | 1430 // the event will be dropped and the mouse_wheel_end_dispatch_timer_ will |
| 1431 // start. | 1431 // start. |
| 1432 NSEvent* wheelEvent2 = | 1432 NSEvent* wheelEvent2 = |
| 1433 MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); | 1433 MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); |
| 1434 [view->cocoa_view() scrollWheel:wheelEvent2]; | 1434 [view->cocoa_view() scrollWheel:wheelEvent2]; |
| 1435 ASSERT_EQ(0U, process_host->sink().message_count()); | 1435 ASSERT_EQ(0U, process_host->sink().message_count()); |
| 1436 DCHECK(view->HasPendingWheelEndEvent()); | 1436 DCHECK(view->HasPendingWheelEndEventForTesting()); |
| 1437 process_host->sink().ClearMessages(); | 1437 process_host->sink().ClearMessages(); |
| 1438 | 1438 |
| 1439 // Send a wheel event with momentum phase started, this should stop the wheel | 1439 // Send a wheel event with momentum phase started, this should stop the wheel |
| 1440 // end dispatch timer. | 1440 // end dispatch timer. |
| 1441 NSEvent* wheelEvent3 = | 1441 NSEvent* wheelEvent3 = |
| 1442 MockScrollWheelEventWithMomentumPhase(@selector(phaseBegan), 3); | 1442 MockScrollWheelEventWithMomentumPhase(@selector(phaseBegan), 3); |
| 1443 ASSERT_TRUE(wheelEvent3); | 1443 ASSERT_TRUE(wheelEvent3); |
| 1444 [view->cocoa_view() scrollWheel:wheelEvent3]; | 1444 [view->cocoa_view() scrollWheel:wheelEvent3]; |
| 1445 ASSERT_EQ(1U, process_host->sink().message_count()); | 1445 ASSERT_EQ(1U, process_host->sink().message_count()); |
| 1446 DCHECK(!view->HasPendingWheelEndEvent()); | 1446 DCHECK(!view->HasPendingWheelEndEventForTesting()); |
| 1447 process_host->sink().ClearMessages(); | 1447 process_host->sink().ClearMessages(); |
| 1448 | 1448 |
| 1449 host->ShutdownAndDestroyWidget(true); | 1449 host->ShutdownAndDestroyWidget(true); |
| 1450 } | 1450 } |
| 1451 | 1451 |
| 1452 TEST_F(RenderWidgetHostViewMacWithWheelScrollLatchingEnabledTest, | 1452 TEST_F(RenderWidgetHostViewMacWithWheelScrollLatchingEnabledTest, |
| 1453 WheelWithPhaseBeganDispatchesThePendingWheelEnd) { | 1453 WheelWithPhaseBeganDispatchesThePendingWheelEnd) { |
| 1454 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than | 1454 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than |
| 1455 // the MockRenderProcessHost that is set up by the test harness which mocks | 1455 // the MockRenderProcessHost that is set up by the test harness which mocks |
| 1456 // out |OnMessageReceived()|. | 1456 // out |OnMessageReceived()|. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1482 ASSERT_EQ(2U, process_host->sink().message_count()); | 1482 ASSERT_EQ(2U, process_host->sink().message_count()); |
| 1483 process_host->sink().ClearMessages(); | 1483 process_host->sink().ClearMessages(); |
| 1484 | 1484 |
| 1485 // Send a wheel event with phaseEnded. When wheel scroll latching is enabled | 1485 // Send a wheel event with phaseEnded. When wheel scroll latching is enabled |
| 1486 // the event will be dropped and the mouse_wheel_end_dispatch_timer_ will | 1486 // the event will be dropped and the mouse_wheel_end_dispatch_timer_ will |
| 1487 // start. | 1487 // start. |
| 1488 NSEvent* wheelEvent2 = | 1488 NSEvent* wheelEvent2 = |
| 1489 MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); | 1489 MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); |
| 1490 [view->cocoa_view() scrollWheel:wheelEvent2]; | 1490 [view->cocoa_view() scrollWheel:wheelEvent2]; |
| 1491 ASSERT_EQ(0U, process_host->sink().message_count()); | 1491 ASSERT_EQ(0U, process_host->sink().message_count()); |
| 1492 DCHECK(view->HasPendingWheelEndEvent()); | 1492 DCHECK(view->HasPendingWheelEndEventForTesting()); |
| 1493 process_host->sink().ClearMessages(); | 1493 process_host->sink().ClearMessages(); |
| 1494 | 1494 |
| 1495 // Send a wheel event with phase started, this should stop the wheel end | 1495 // Send a wheel event with phase started, this should stop the wheel end |
| 1496 // dispatch timer and dispatch the pending wheel end event for the previous | 1496 // dispatch timer and dispatch the pending wheel end event for the previous |
| 1497 // scroll sequence. | 1497 // scroll sequence. |
| 1498 NSEvent* wheelEvent3 = | 1498 NSEvent* wheelEvent3 = |
| 1499 MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); | 1499 MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); |
| 1500 ASSERT_TRUE(wheelEvent3); | 1500 ASSERT_TRUE(wheelEvent3); |
| 1501 [view->cocoa_view() scrollWheel:wheelEvent3]; | 1501 [view->cocoa_view() scrollWheel:wheelEvent3]; |
| 1502 ASSERT_EQ(2U, process_host->sink().message_count()); | 1502 ASSERT_EQ(2U, process_host->sink().message_count()); |
| 1503 DCHECK(!view->HasPendingWheelEndEvent()); | 1503 DCHECK(!view->HasPendingWheelEndEventForTesting()); |
| 1504 process_host->sink().ClearMessages(); | 1504 process_host->sink().ClearMessages(); |
| 1505 | 1505 |
| 1506 host->ShutdownAndDestroyWidget(true); | 1506 host->ShutdownAndDestroyWidget(true); |
| 1507 } | 1507 } |
| 1508 | 1508 |
| 1509 class RenderWidgetHostViewMacPinchTest : public RenderWidgetHostViewMacTest { | 1509 class RenderWidgetHostViewMacPinchTest : public RenderWidgetHostViewMacTest { |
| 1510 public: | 1510 public: |
| 1511 RenderWidgetHostViewMacPinchTest() : process_host_(nullptr) {} | 1511 RenderWidgetHostViewMacPinchTest() : process_host_(nullptr) {} |
| 1512 | 1512 |
| 1513 bool ZoomDisabledForPinchUpdateMessage() { | 1513 bool ZoomDisabledForPinchUpdateMessage() { |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2034 // -performKeyEquivalent: now returns YES to prevent further propagation, and | 2034 // -performKeyEquivalent: now returns YES to prevent further propagation, and |
| 2035 // the event is sent to the renderer. | 2035 // the event is sent to the renderer. |
| 2036 EXPECT_TRUE([window performKeyEquivalent:key_down]); | 2036 EXPECT_TRUE([window performKeyEquivalent:key_down]); |
| 2037 EXPECT_EQ(2U, process_host->sink().message_count()); | 2037 EXPECT_EQ(2U, process_host->sink().message_count()); |
| 2038 EXPECT_EQ("RawKeyDown Char", GetInputMessageTypes(process_host)); | 2038 EXPECT_EQ("RawKeyDown Char", GetInputMessageTypes(process_host)); |
| 2039 | 2039 |
| 2040 rwhv_mac_->release_pepper_fullscreen_window_for_testing(); | 2040 rwhv_mac_->release_pepper_fullscreen_window_for_testing(); |
| 2041 } | 2041 } |
| 2042 | 2042 |
| 2043 } // namespace content | 2043 } // namespace content |
| OLD | NEW |