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