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