| 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> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/mac/scoped_nsautorelease_pool.h" | 13 #include "base/mac/scoped_nsautorelease_pool.h" |
| 14 #include "base/mac/sdk_forward_declarations.h" | 14 #include "base/mac/sdk_forward_declarations.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 18 #include "base/test/histogram_tester.h" | 18 #include "base/test/histogram_tester.h" |
| 19 #include "base/test/simple_test_tick_clock.h" | 19 #include "base/test/simple_test_tick_clock.h" |
| 20 #include "content/browser/browser_thread_impl.h" | 20 #include "content/browser/browser_thread_impl.h" |
| 21 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" | 21 #include "content/browser/compositor/test/no_transport_image_transport_factory.h
" |
| 22 #include "content/browser/frame_host/render_widget_host_view_guest.h" | 22 #include "content/browser/frame_host/render_widget_host_view_guest.h" |
| 23 #include "content/browser/gpu/compositor_util.h" | 23 #include "content/browser/gpu/compositor_util.h" |
| 24 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 24 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
| 25 #include "content/browser/renderer_host/text_input_manager.h" |
| 25 #include "content/common/input/web_input_event_traits.h" | 26 #include "content/common/input/web_input_event_traits.h" |
| 26 #include "content/common/input_messages.h" | 27 #include "content/common/input_messages.h" |
| 27 #include "content/common/view_messages.h" | 28 #include "content/common/view_messages.h" |
| 28 #include "content/public/browser/notification_types.h" | 29 #include "content/public/browser/notification_types.h" |
| 29 #include "content/public/browser/render_widget_host_view_mac_delegate.h" | 30 #include "content/public/browser/render_widget_host_view_mac_delegate.h" |
| 30 #include "content/public/common/content_switches.h" | 31 #include "content/public/common/content_switches.h" |
| 31 #include "content/public/test/mock_render_process_host.h" | 32 #include "content/public/test/mock_render_process_host.h" |
| 32 #include "content/public/test/test_browser_context.h" | 33 #include "content/public/test/test_browser_context.h" |
| 33 #include "content/public/test/test_utils.h" | 34 #include "content/public/test/test_utils.h" |
| 34 #include "content/test/test_render_view_host.h" | 35 #include "content/test/test_render_view_host.h" |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 [(NSEvent*)[[event stub] andReturnValue:OCMOCK_VALUE(timestamp)] timestamp]; | 142 [(NSEvent*)[[event stub] andReturnValue:OCMOCK_VALUE(timestamp)] timestamp]; |
| 142 [(NSEvent*)[[event stub] | 143 [(NSEvent*)[[event stub] |
| 143 andReturnValue:OCMOCK_VALUE(modifierFlags)] modifierFlags]; | 144 andReturnValue:OCMOCK_VALUE(modifierFlags)] modifierFlags]; |
| 144 [(NSEvent*)[[event stub] | 145 [(NSEvent*)[[event stub] |
| 145 andReturnValue:OCMOCK_VALUE(magnification)] magnification]; | 146 andReturnValue:OCMOCK_VALUE(magnification)] magnification]; |
| 146 return event; | 147 return event; |
| 147 } | 148 } |
| 148 | 149 |
| 149 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { | 150 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
| 150 public: | 151 public: |
| 151 MockRenderWidgetHostDelegate() {} | 152 MockRenderWidgetHostDelegate() |
| 153 : text_input_manager_(new TextInputManager()) {} |
| 152 ~MockRenderWidgetHostDelegate() override {} | 154 ~MockRenderWidgetHostDelegate() override {} |
| 153 | 155 |
| 156 TextInputManager* GetTextInputManager() override { |
| 157 return text_input_manager_.get(); |
| 158 } |
| 159 |
| 154 private: | 160 private: |
| 155 void Cut() override {} | 161 void Cut() override {} |
| 156 void Copy() override {} | 162 void Copy() override {} |
| 157 void Paste() override {} | 163 void Paste() override {} |
| 158 void SelectAll() override {} | 164 void SelectAll() override {} |
| 165 |
| 166 std::unique_ptr<TextInputManager> text_input_manager_; |
| 159 }; | 167 }; |
| 160 | 168 |
| 161 class MockRenderWidgetHostImpl : public RenderWidgetHostImpl { | 169 class MockRenderWidgetHostImpl : public RenderWidgetHostImpl { |
| 162 public: | 170 public: |
| 163 MockRenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, | 171 MockRenderWidgetHostImpl(RenderWidgetHostDelegate* delegate, |
| 164 RenderProcessHost* process, | 172 RenderProcessHost* process, |
| 165 int32_t routing_id) | 173 int32_t routing_id) |
| 166 : RenderWidgetHostImpl(delegate, process, routing_id, false) { | 174 : RenderWidgetHostImpl(delegate, process, routing_id, false) { |
| 167 set_renderer_initialized(true); | 175 set_renderer_initialized(true); |
| 168 lastWheelEventLatencyInfo = ui::LatencyInfo(); | 176 lastWheelEventLatencyInfo = ui::LatencyInfo(); |
| (...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1247 // Verify that Event.Latency.OS.MOUSE_WHEEL histogram is computed properly. | 1255 // Verify that Event.Latency.OS.MOUSE_WHEEL histogram is computed properly. |
| 1248 NSEvent* wheelEvent = MockScrollWheelEventWithPhase(@selector(phaseBegan),3); | 1256 NSEvent* wheelEvent = MockScrollWheelEventWithPhase(@selector(phaseBegan),3); |
| 1249 [view->cocoa_view() scrollWheel:wheelEvent]; | 1257 [view->cocoa_view() scrollWheel:wheelEvent]; |
| 1250 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); | 1258 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); |
| 1251 | 1259 |
| 1252 // Clean up. | 1260 // Clean up. |
| 1253 host->ShutdownAndDestroyWidget(true); | 1261 host->ShutdownAndDestroyWidget(true); |
| 1254 } | 1262 } |
| 1255 | 1263 |
| 1256 } // namespace content | 1264 } // namespace content |
| OLD | NEW |