OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/scoped_nsautorelease_pool.h" | 7 #include "base/mac/scoped_nsautorelease_pool.h" |
8 #include "content/browser/browser_thread_impl.h" | 8 #include "content/browser/browser_thread_impl.h" |
9 #include "content/browser/renderer_host/test_render_view_host.h" | 9 #include "content/browser/renderer_host/test_render_view_host.h" |
10 #include "content/common/gpu/gpu_messages.h" | |
11 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
12 #include "ui/base/test/cocoa_test_event_utils.h" | 11 #include "ui/base/test/cocoa_test_event_utils.h" |
13 #import "ui/base/test/ui_cocoa_test_helper.h" | 12 #import "ui/base/test/ui_cocoa_test_helper.h" |
14 #include "webkit/plugins/npapi/webplugin.h" | 13 #include "webkit/plugins/npapi/webplugin.h" |
15 | 14 |
16 using content::BrowserThread; | 15 using content::BrowserThread; |
17 using content::BrowserThreadImpl; | 16 using content::BrowserThreadImpl; |
18 | 17 |
19 class RenderWidgetHostViewMacTest : public RenderViewHostTestHarness { | 18 class RenderWidgetHostViewMacTest : public RenderViewHostTestHarness { |
20 public: | 19 public: |
(...skipping 30 matching lines...) Expand all Loading... |
51 gfx::PluginWindowHandle AddAcceleratedPluginView(int w, int h) { | 50 gfx::PluginWindowHandle AddAcceleratedPluginView(int w, int h) { |
52 // Create an accelerated view the size of the rhwvmac. | 51 // Create an accelerated view the size of the rhwvmac. |
53 [rwhv_cocoa_.get() setFrame:NSMakeRect(0, 0, w, h)]; | 52 [rwhv_cocoa_.get() setFrame:NSMakeRect(0, 0, w, h)]; |
54 gfx::PluginWindowHandle accelerated_handle = | 53 gfx::PluginWindowHandle accelerated_handle = |
55 rwhv_mac_->AllocateFakePluginWindowHandle(/*opaque=*/false, | 54 rwhv_mac_->AllocateFakePluginWindowHandle(/*opaque=*/false, |
56 /*root=*/false); | 55 /*root=*/false); |
57 rwhv_mac_->AcceleratedSurfaceSetIOSurface(accelerated_handle, w, h, 0); | 56 rwhv_mac_->AcceleratedSurfaceSetIOSurface(accelerated_handle, w, h, 0); |
58 | 57 |
59 // The accelerated view isn't shown until it has a valid rect and has been | 58 // The accelerated view isn't shown until it has a valid rect and has been |
60 // painted to. | 59 // painted to. |
61 GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params params; | 60 rwhv_mac_->AcceleratedSurfaceBuffersSwapped(accelerated_handle, |
62 params.window = accelerated_handle; | 61 0, 0, 0, 0); |
63 rwhv_mac_->AcceleratedSurfaceBuffersSwapped(params, 0); | |
64 webkit::npapi::WebPluginGeometry geom; | 62 webkit::npapi::WebPluginGeometry geom; |
65 gfx::Rect rect(0, 0, w, h); | 63 gfx::Rect rect(0, 0, w, h); |
66 geom.window = accelerated_handle; | 64 geom.window = accelerated_handle; |
67 geom.window_rect = rect; | 65 geom.window_rect = rect; |
68 geom.clip_rect = rect; | 66 geom.clip_rect = rect; |
69 geom.visible = true; | 67 geom.visible = true; |
70 geom.rects_valid = true; | 68 geom.rects_valid = true; |
71 rwhv_mac_->MovePluginWindows( | 69 rwhv_mac_->MovePluginWindows( |
72 std::vector<webkit::npapi::WebPluginGeometry>(1, geom)); | 70 std::vector<webkit::npapi::WebPluginGeometry>(1, geom)); |
73 | 71 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 | 190 |
193 // A click on the accelerated view should focus the RWHVCocoa. | 191 // A click on the accelerated view should focus the RWHVCocoa. |
194 std::pair<NSEvent*, NSEvent*> clicks = | 192 std::pair<NSEvent*, NSEvent*> clicks = |
195 cocoa_test_event_utils::MouseClickInView(accelerated_view, 1); | 193 cocoa_test_event_utils::MouseClickInView(accelerated_view, 1); |
196 [rwhv_cocoa_.get() mouseDown:clicks.first]; | 194 [rwhv_cocoa_.get() mouseDown:clicks.first]; |
197 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); | 195 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); |
198 | 196 |
199 // Clean up. | 197 // Clean up. |
200 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle); | 198 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle); |
201 } | 199 } |
OLD | NEW |