| 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 | 10 |
| (...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 // |SetActive()| shoud not focus if view is not first responder. | 813 // |SetActive()| shoud not focus if view is not first responder. |
| 814 EXPECT_CALL(*rwh, Focus()).Times(0); | 814 EXPECT_CALL(*rwh, Focus()).Times(0); |
| 815 view->SetActive(true); | 815 view->SetActive(true); |
| 816 testing::Mock::VerifyAndClearExpectations(rwh); | 816 testing::Mock::VerifyAndClearExpectations(rwh); |
| 817 | 817 |
| 818 // Clean up. | 818 // Clean up. |
| 819 rwh->ShutdownAndDestroyWidget(true); | 819 rwh->ShutdownAndDestroyWidget(true); |
| 820 } | 820 } |
| 821 | 821 |
| 822 TEST_F(RenderWidgetHostViewMacTest, ScrollWheelEndEventDelivery) { | 822 TEST_F(RenderWidgetHostViewMacTest, ScrollWheelEndEventDelivery) { |
| 823 // This tests Lion+ functionality, so don't run the test pre-Lion. | |
| 824 if (!base::mac::IsOSLionOrLater()) | |
| 825 return; | |
| 826 | |
| 827 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than | 823 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than |
| 828 // the MockRenderProcessHost that is set up by the test harness which mocks | 824 // the MockRenderProcessHost that is set up by the test harness which mocks |
| 829 // out |OnMessageReceived()|. | 825 // out |OnMessageReceived()|. |
| 830 TestBrowserContext browser_context; | 826 TestBrowserContext browser_context; |
| 831 MockRenderProcessHost* process_host = | 827 MockRenderProcessHost* process_host = |
| 832 new MockRenderProcessHost(&browser_context); | 828 new MockRenderProcessHost(&browser_context); |
| 833 process_host->Init(); | 829 process_host->Init(); |
| 834 MockRenderWidgetHostDelegate delegate; | 830 MockRenderWidgetHostDelegate delegate; |
| 835 int32_t routing_id = process_host->GetNextRoutingID(); | 831 int32_t routing_id = process_host->GetNextRoutingID(); |
| 836 MockRenderWidgetHostImpl* host = | 832 MockRenderWidgetHostImpl* host = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 855 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); | 851 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); |
| 856 [NSApp postEvent:event2 atStart:NO]; | 852 [NSApp postEvent:event2 atStart:NO]; |
| 857 base::MessageLoop::current()->RunUntilIdle(); | 853 base::MessageLoop::current()->RunUntilIdle(); |
| 858 ASSERT_EQ(2U, process_host->sink().message_count()); | 854 ASSERT_EQ(2U, process_host->sink().message_count()); |
| 859 | 855 |
| 860 // Clean up. | 856 // Clean up. |
| 861 host->ShutdownAndDestroyWidget(true); | 857 host->ShutdownAndDestroyWidget(true); |
| 862 } | 858 } |
| 863 | 859 |
| 864 TEST_F(RenderWidgetHostViewMacTest, IgnoreEmptyUnhandledWheelEvent) { | 860 TEST_F(RenderWidgetHostViewMacTest, IgnoreEmptyUnhandledWheelEvent) { |
| 865 // This tests Lion+ functionality, so don't run the test pre-Lion. | |
| 866 if (!base::mac::IsOSLionOrLater()) | |
| 867 return; | |
| 868 | |
| 869 SetupForWheelGestures(false); | 861 SetupForWheelGestures(false); |
| 870 | 862 |
| 871 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than | 863 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than |
| 872 // the MockRenderProcessHost that is set up by the test harness which mocks | 864 // the MockRenderProcessHost that is set up by the test harness which mocks |
| 873 // out |OnMessageReceived()|. | 865 // out |OnMessageReceived()|. |
| 874 TestBrowserContext browser_context; | 866 TestBrowserContext browser_context; |
| 875 MockRenderProcessHost* process_host = | 867 MockRenderProcessHost* process_host = |
| 876 new MockRenderProcessHost(&browser_context); | 868 new MockRenderProcessHost(&browser_context); |
| 877 process_host->Init(); | 869 process_host->Init(); |
| 878 MockRenderWidgetHostDelegate delegate; | 870 MockRenderWidgetHostDelegate delegate; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 | 908 |
| 917 // Check that the view delegate ignored the empty unhandled wheel event. | 909 // Check that the view delegate ignored the empty unhandled wheel event. |
| 918 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); | 910 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); |
| 919 | 911 |
| 920 // Clean up. | 912 // Clean up. |
| 921 host->ShutdownAndDestroyWidget(true); | 913 host->ShutdownAndDestroyWidget(true); |
| 922 } | 914 } |
| 923 | 915 |
| 924 TEST_F(RenderWidgetHostViewMacTest, | 916 TEST_F(RenderWidgetHostViewMacTest, |
| 925 IgnoreEmptyUnhandledWheelEventWithWheelGestures) { | 917 IgnoreEmptyUnhandledWheelEventWithWheelGestures) { |
| 926 // This tests Lion+ functionality, so don't run the test pre-Lion. | |
| 927 if (!base::mac::IsOSLionOrLater()) | |
| 928 return; | |
| 929 | |
| 930 SetupForWheelGestures(true); | 918 SetupForWheelGestures(true); |
| 931 | 919 |
| 932 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than | 920 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than |
| 933 // the MockRenderProcessHost that is set up by the test harness which mocks | 921 // the MockRenderProcessHost that is set up by the test harness which mocks |
| 934 // out |OnMessageReceived()|. | 922 // out |OnMessageReceived()|. |
| 935 TestBrowserContext browser_context; | 923 TestBrowserContext browser_context; |
| 936 MockRenderProcessHost* process_host = | 924 MockRenderProcessHost* process_host = |
| 937 new MockRenderProcessHost(&browser_context); | 925 new MockRenderProcessHost(&browser_context); |
| 938 process_host->Init(); | 926 process_host->Init(); |
| 939 MockRenderWidgetHostDelegate delegate; | 927 MockRenderWidgetHostDelegate delegate; |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1103 IPC::WebInputEventPointer ipc_event = base::get<0>(data); | 1091 IPC::WebInputEventPointer ipc_event = base::get<0>(data); |
| 1104 const blink::WebGestureEvent* gesture_event = | 1092 const blink::WebGestureEvent* gesture_event = |
| 1105 static_cast<const blink::WebGestureEvent*>(ipc_event); | 1093 static_cast<const blink::WebGestureEvent*>(ipc_event); |
| 1106 return gesture_event->data.pinchUpdate.zoomDisabled; | 1094 return gesture_event->data.pinchUpdate.zoomDisabled; |
| 1107 } | 1095 } |
| 1108 | 1096 |
| 1109 MockRenderProcessHost* process_host_; | 1097 MockRenderProcessHost* process_host_; |
| 1110 }; | 1098 }; |
| 1111 | 1099 |
| 1112 TEST_F(RenderWidgetHostViewMacPinchTest, PinchThresholding) { | 1100 TEST_F(RenderWidgetHostViewMacPinchTest, PinchThresholding) { |
| 1113 // This tests Lion+ functionality, so don't run the test pre-Lion. | |
| 1114 if (!base::mac::IsOSLionOrLater()) | |
| 1115 return; | |
| 1116 | |
| 1117 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than | 1101 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than |
| 1118 // the MockRenderProcessHost that is set up by the test harness which mocks | 1102 // the MockRenderProcessHost that is set up by the test harness which mocks |
| 1119 // out |OnMessageReceived()|. | 1103 // out |OnMessageReceived()|. |
| 1120 TestBrowserContext browser_context; | 1104 TestBrowserContext browser_context; |
| 1121 process_host_ = new MockRenderProcessHost(&browser_context); | 1105 process_host_ = new MockRenderProcessHost(&browser_context); |
| 1122 process_host_->Init(); | 1106 process_host_->Init(); |
| 1123 MockRenderWidgetHostDelegate delegate; | 1107 MockRenderWidgetHostDelegate delegate; |
| 1124 int32_t routing_id = process_host_->GetNextRoutingID(); | 1108 int32_t routing_id = process_host_->GetNextRoutingID(); |
| 1125 MockRenderWidgetHostImpl* host = | 1109 MockRenderWidgetHostImpl* host = |
| 1126 new MockRenderWidgetHostImpl(&delegate, process_host_, routing_id); | 1110 new MockRenderWidgetHostImpl(&delegate, process_host_, routing_id); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 EXPECT_EQ(1U, process_host_->sink().message_count()); | 1210 EXPECT_EQ(1U, process_host_->sink().message_count()); |
| 1227 process_host_->sink().ClearMessages(); | 1211 process_host_->sink().ClearMessages(); |
| 1228 } | 1212 } |
| 1229 | 1213 |
| 1230 // Clean up. | 1214 // Clean up. |
| 1231 host->ShutdownAndDestroyWidget(true); | 1215 host->ShutdownAndDestroyWidget(true); |
| 1232 } | 1216 } |
| 1233 | 1217 |
| 1234 | 1218 |
| 1235 } // namespace content | 1219 } // namespace content |
| OLD | NEW |