| 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 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/mac/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 // This tests Lion+ functionality, so don't run the test pre-Lion. | 693 // This tests Lion+ functionality, so don't run the test pre-Lion. |
| 694 if (!base::mac::IsOSLionOrLater()) | 694 if (!base::mac::IsOSLionOrLater()) |
| 695 return; | 695 return; |
| 696 | 696 |
| 697 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than | 697 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than |
| 698 // the MockRenderProcessHost that is set up by the test harness which mocks | 698 // the MockRenderProcessHost that is set up by the test harness which mocks |
| 699 // out |OnMessageReceived()|. | 699 // out |OnMessageReceived()|. |
| 700 TestBrowserContext browser_context; | 700 TestBrowserContext browser_context; |
| 701 MockRenderProcessHost* process_host = | 701 MockRenderProcessHost* process_host = |
| 702 new MockRenderProcessHost(&browser_context); | 702 new MockRenderProcessHost(&browser_context); |
| 703 process_host->Init(); |
| 703 MockRenderWidgetHostDelegate delegate; | 704 MockRenderWidgetHostDelegate delegate; |
| 704 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( | 705 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( |
| 705 &delegate, process_host, MSG_ROUTING_NONE); | 706 &delegate, process_host, MSG_ROUTING_NONE); |
| 706 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); | 707 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); |
| 707 | 708 |
| 708 // Send an initial wheel event with NSEventPhaseBegan to the view. | 709 // Send an initial wheel event with NSEventPhaseBegan to the view. |
| 709 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); | 710 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); |
| 710 [view->cocoa_view() scrollWheel:event1]; | 711 [view->cocoa_view() scrollWheel:event1]; |
| 711 ASSERT_EQ(1U, process_host->sink().message_count()); | 712 ASSERT_EQ(1U, process_host->sink().message_count()); |
| 712 | 713 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 732 // This tests Lion+ functionality, so don't run the test pre-Lion. | 733 // This tests Lion+ functionality, so don't run the test pre-Lion. |
| 733 if (!base::mac::IsOSLionOrLater()) | 734 if (!base::mac::IsOSLionOrLater()) |
| 734 return; | 735 return; |
| 735 | 736 |
| 736 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than | 737 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than |
| 737 // the MockRenderProcessHost that is set up by the test harness which mocks | 738 // the MockRenderProcessHost that is set up by the test harness which mocks |
| 738 // out |OnMessageReceived()|. | 739 // out |OnMessageReceived()|. |
| 739 TestBrowserContext browser_context; | 740 TestBrowserContext browser_context; |
| 740 MockRenderProcessHost* process_host = | 741 MockRenderProcessHost* process_host = |
| 741 new MockRenderProcessHost(&browser_context); | 742 new MockRenderProcessHost(&browser_context); |
| 743 process_host->Init(); |
| 742 MockRenderWidgetHostDelegate delegate; | 744 MockRenderWidgetHostDelegate delegate; |
| 743 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( | 745 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( |
| 744 &delegate, process_host, MSG_ROUTING_NONE); | 746 &delegate, process_host, MSG_ROUTING_NONE); |
| 745 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); | 747 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); |
| 746 | 748 |
| 747 // Add a delegate to the view. | 749 // Add a delegate to the view. |
| 748 base::scoped_nsobject<MockRenderWidgetHostViewMacDelegate> view_delegate( | 750 base::scoped_nsobject<MockRenderWidgetHostViewMacDelegate> view_delegate( |
| 749 [[MockRenderWidgetHostViewMacDelegate alloc] init]); | 751 [[MockRenderWidgetHostViewMacDelegate alloc] init]); |
| 750 view->SetDelegate(view_delegate.get()); | 752 view->SetDelegate(view_delegate.get()); |
| 751 | 753 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 TEST_F(RenderWidgetHostViewMacPinchTest, PinchThresholding) { | 901 TEST_F(RenderWidgetHostViewMacPinchTest, PinchThresholding) { |
| 900 // This tests Lion+ functionality, so don't run the test pre-Lion. | 902 // This tests Lion+ functionality, so don't run the test pre-Lion. |
| 901 if (!base::mac::IsOSLionOrLater()) | 903 if (!base::mac::IsOSLionOrLater()) |
| 902 return; | 904 return; |
| 903 | 905 |
| 904 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than | 906 // Initialize the view associated with a MockRenderWidgetHostImpl, rather than |
| 905 // the MockRenderProcessHost that is set up by the test harness which mocks | 907 // the MockRenderProcessHost that is set up by the test harness which mocks |
| 906 // out |OnMessageReceived()|. | 908 // out |OnMessageReceived()|. |
| 907 TestBrowserContext browser_context; | 909 TestBrowserContext browser_context; |
| 908 process_host_ = new MockRenderProcessHost(&browser_context); | 910 process_host_ = new MockRenderProcessHost(&browser_context); |
| 911 process_host_->Init(); |
| 909 MockRenderWidgetHostDelegate delegate; | 912 MockRenderWidgetHostDelegate delegate; |
| 910 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( | 913 MockRenderWidgetHostImpl* host = new MockRenderWidgetHostImpl( |
| 911 &delegate, process_host_, MSG_ROUTING_NONE); | 914 &delegate, process_host_, MSG_ROUTING_NONE); |
| 912 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); | 915 RenderWidgetHostViewMac* view = new RenderWidgetHostViewMac(host, false); |
| 913 | 916 |
| 914 // We'll use this IPC message to ack events. | 917 // We'll use this IPC message to ack events. |
| 915 InputEventAck ack(blink::WebInputEvent::GesturePinchUpdate, | 918 InputEventAck ack(blink::WebInputEvent::GesturePinchUpdate, |
| 916 INPUT_EVENT_ACK_STATE_CONSUMED); | 919 INPUT_EVENT_ACK_STATE_CONSUMED); |
| 917 scoped_ptr<IPC::Message> response( | 920 scoped_ptr<IPC::Message> response( |
| 918 new InputHostMsg_HandleInputEvent_ACK(0, ack)); | 921 new InputHostMsg_HandleInputEvent_ACK(0, ack)); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1010 EXPECT_EQ(1U, process_host_->sink().message_count()); | 1013 EXPECT_EQ(1U, process_host_->sink().message_count()); |
| 1011 process_host_->sink().ClearMessages(); | 1014 process_host_->sink().ClearMessages(); |
| 1012 } | 1015 } |
| 1013 | 1016 |
| 1014 // Clean up. | 1017 // Clean up. |
| 1015 host->Shutdown(); | 1018 host->Shutdown(); |
| 1016 } | 1019 } |
| 1017 | 1020 |
| 1018 | 1021 |
| 1019 } // namespace content | 1022 } // namespace content |
| OLD | NEW |