| 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> |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 } | 234 } |
| 235 | 235 |
| 236 } // namespace | 236 } // namespace |
| 237 | 237 |
| 238 class RenderWidgetHostViewMacTest : public RenderViewHostImplTestHarness { | 238 class RenderWidgetHostViewMacTest : public RenderViewHostImplTestHarness { |
| 239 public: | 239 public: |
| 240 RenderWidgetHostViewMacTest() : old_rwhv_(NULL), rwhv_mac_(NULL) {} | 240 RenderWidgetHostViewMacTest() : old_rwhv_(NULL), rwhv_mac_(NULL) {} |
| 241 | 241 |
| 242 void SetUp() override { | 242 void SetUp() override { |
| 243 RenderViewHostImplTestHarness::SetUp(); | 243 RenderViewHostImplTestHarness::SetUp(); |
| 244 ImageTransportFactory::InitializeForUnitTests( | |
| 245 std::unique_ptr<ImageTransportFactory>( | |
| 246 new NoTransportImageTransportFactory)); | |
| 247 | |
| 248 // TestRenderViewHost's destruction assumes that its view is a | 244 // TestRenderViewHost's destruction assumes that its view is a |
| 249 // TestRenderWidgetHostView, so store its view and reset it back to the | 245 // TestRenderWidgetHostView, so store its view and reset it back to the |
| 250 // stored view in |TearDown()|. | 246 // stored view in |TearDown()|. |
| 251 old_rwhv_ = rvh()->GetWidget()->GetView(); | 247 old_rwhv_ = rvh()->GetWidget()->GetView(); |
| 252 | 248 |
| 253 // Owned by its |cocoa_view()|, i.e. |rwhv_cocoa_|. | 249 // Owned by its |cocoa_view()|, i.e. |rwhv_cocoa_|. |
| 254 rwhv_mac_ = new RenderWidgetHostViewMac(rvh()->GetWidget(), false); | 250 rwhv_mac_ = new RenderWidgetHostViewMac(rvh()->GetWidget(), false); |
| 255 rwhv_cocoa_.reset([rwhv_mac_->cocoa_view() retain]); | 251 rwhv_cocoa_.reset([rwhv_mac_->cocoa_view() retain]); |
| 256 } | 252 } |
| 257 void TearDown() override { | 253 void TearDown() override { |
| 258 // Make sure the rwhv_mac_ is gone once the superclass's |TearDown()| runs. | 254 // Make sure the rwhv_mac_ is gone once the superclass's |TearDown()| runs. |
| 259 rwhv_cocoa_.reset(); | 255 rwhv_cocoa_.reset(); |
| 260 RecycleAndWait(); | 256 RecycleAndWait(); |
| 261 | 257 |
| 262 // See comment in SetUp(). | 258 // See comment in SetUp(). |
| 263 test_rvh()->GetWidget()->SetView( | 259 test_rvh()->GetWidget()->SetView( |
| 264 static_cast<RenderWidgetHostViewBase*>(old_rwhv_)); | 260 static_cast<RenderWidgetHostViewBase*>(old_rwhv_)); |
| 265 | 261 |
| 266 ImageTransportFactory::Terminate(); | |
| 267 RenderViewHostImplTestHarness::TearDown(); | 262 RenderViewHostImplTestHarness::TearDown(); |
| 268 } | 263 } |
| 269 | 264 |
| 270 void RecycleAndWait() { | 265 void RecycleAndWait() { |
| 271 pool_.Recycle(); | 266 pool_.Recycle(); |
| 272 base::RunLoop().RunUntilIdle(); | 267 base::RunLoop().RunUntilIdle(); |
| 273 pool_.Recycle(); | 268 pool_.Recycle(); |
| 274 } | 269 } |
| 275 | 270 |
| 276 void DestroyHostViewRetainCocoaView() { | 271 void DestroyHostViewRetainCocoaView() { |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 // Verify that Event.Latency.OS.MOUSE_WHEEL histogram is computed properly. | 1237 // Verify that Event.Latency.OS.MOUSE_WHEEL histogram is computed properly. |
| 1243 NSEvent* wheelEvent = MockScrollWheelEventWithPhase(@selector(phaseBegan),3); | 1238 NSEvent* wheelEvent = MockScrollWheelEventWithPhase(@selector(phaseBegan),3); |
| 1244 [view->cocoa_view() scrollWheel:wheelEvent]; | 1239 [view->cocoa_view() scrollWheel:wheelEvent]; |
| 1245 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); | 1240 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); |
| 1246 | 1241 |
| 1247 // Clean up. | 1242 // Clean up. |
| 1248 host->ShutdownAndDestroyWidget(true); | 1243 host->ShutdownAndDestroyWidget(true); |
| 1249 } | 1244 } |
| 1250 | 1245 |
| 1251 } // namespace content | 1246 } // namespace content |
| OLD | NEW |