| 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 "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 #include "base/mac/scoped_nsautorelease_pool.h" | 8 #include "base/mac/scoped_nsautorelease_pool.h" |
| 9 #include "base/mac/sdk_forward_declarations.h" | 9 #include "base/mac/sdk_forward_declarations.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "content/browser/browser_thread_impl.h" | 11 #include "content/browser/browser_thread_impl.h" |
| 12 #include "content/browser/compositor/image_transport_factory.h" | 12 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
| 13 #include "content/browser/gpu/compositor_util.h" | 13 #include "content/browser/gpu/compositor_util.h" |
| 14 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 14 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 15 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
| 16 #include "content/common/input_messages.h" | 16 #include "content/common/input_messages.h" |
| 17 #include "content/common/view_messages.h" | 17 #include "content/common/view_messages.h" |
| 18 #include "content/public/browser/notification_types.h" | 18 #include "content/public/browser/notification_types.h" |
| 19 #include "content/public/browser/render_widget_host_view_mac_delegate.h" | 19 #include "content/public/browser/render_widget_host_view_mac_delegate.h" |
| 20 #include "content/public/test/mock_render_process_host.h" | 20 #include "content/public/test/mock_render_process_host.h" |
| 21 #include "content/public/test/test_browser_context.h" | 21 #include "content/public/test/test_browser_context.h" |
| 22 #include "content/public/test/test_utils.h" | 22 #include "content/public/test/test_utils.h" |
| 23 #include "content/test/test_render_view_host.h" | 23 #include "content/test/test_render_view_host.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "ui/compositor/test/in_process_context_factory.h" | |
| 27 #include "ui/events/test/cocoa_test_event_utils.h" | 26 #include "ui/events/test/cocoa_test_event_utils.h" |
| 28 #import "ui/gfx/test/ui_cocoa_test_helper.h" | 27 #import "ui/gfx/test/ui_cocoa_test_helper.h" |
| 29 | 28 |
| 30 // Helper class with methods used to mock -[NSEvent phase], used by | 29 // Helper class with methods used to mock -[NSEvent phase], used by |
| 31 // |MockScrollWheelEventWithPhase()|. | 30 // |MockScrollWheelEventWithPhase()|. |
| 32 @interface MockPhaseMethods : NSObject { | 31 @interface MockPhaseMethods : NSObject { |
| 33 } | 32 } |
| 34 | 33 |
| 35 - (NSEventPhase)phaseBegan; | 34 - (NSEventPhase)phaseBegan; |
| 36 - (NSEventPhase)phaseChanged; | 35 - (NSEventPhase)phaseChanged; |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } // namespace | 162 } // namespace |
| 164 | 163 |
| 165 class RenderWidgetHostViewMacTest : public RenderViewHostImplTestHarness { | 164 class RenderWidgetHostViewMacTest : public RenderViewHostImplTestHarness { |
| 166 public: | 165 public: |
| 167 RenderWidgetHostViewMacTest() : old_rwhv_(NULL), rwhv_mac_(NULL) {} | 166 RenderWidgetHostViewMacTest() : old_rwhv_(NULL), rwhv_mac_(NULL) {} |
| 168 | 167 |
| 169 virtual void SetUp() { | 168 virtual void SetUp() { |
| 170 RenderViewHostImplTestHarness::SetUp(); | 169 RenderViewHostImplTestHarness::SetUp(); |
| 171 if (IsDelegatedRendererEnabled()) { | 170 if (IsDelegatedRendererEnabled()) { |
| 172 ImageTransportFactory::InitializeForUnitTests( | 171 ImageTransportFactory::InitializeForUnitTests( |
| 173 scoped_ptr<ui::ContextFactory>(new ui::InProcessContextFactory)); | 172 new NoTransportImageTransportFactory); |
| 174 } | 173 } |
| 175 | 174 |
| 176 // TestRenderViewHost's destruction assumes that its view is a | 175 // TestRenderViewHost's destruction assumes that its view is a |
| 177 // TestRenderWidgetHostView, so store its view and reset it back to the | 176 // TestRenderWidgetHostView, so store its view and reset it back to the |
| 178 // stored view in |TearDown()|. | 177 // stored view in |TearDown()|. |
| 179 old_rwhv_ = rvh()->GetView(); | 178 old_rwhv_ = rvh()->GetView(); |
| 180 | 179 |
| 181 // Owned by its |cocoa_view()|, i.e. |rwhv_cocoa_|. | 180 // Owned by its |cocoa_view()|, i.e. |rwhv_cocoa_|. |
| 182 rwhv_mac_ = new RenderWidgetHostViewMac(rvh()); | 181 rwhv_mac_ = new RenderWidgetHostViewMac(rvh()); |
| 183 rwhv_cocoa_.reset([rwhv_mac_->cocoa_view() retain]); | 182 rwhv_cocoa_.reset([rwhv_mac_->cocoa_view() retain]); |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 777 host->OnMessageReceived(*response2); | 776 host->OnMessageReceived(*response2); |
| 778 | 777 |
| 779 // Check that the view delegate ignored the empty unhandled wheel event. | 778 // Check that the view delegate ignored the empty unhandled wheel event. |
| 780 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); | 779 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); |
| 781 | 780 |
| 782 // Clean up. | 781 // Clean up. |
| 783 host->Shutdown(); | 782 host->Shutdown(); |
| 784 } | 783 } |
| 785 | 784 |
| 786 } // namespace content | 785 } // namespace content |
| OLD | NEW |