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/renderer_host/test_render_view_host.h" | 9 #include "content/browser/renderer_host/test_render_view_host.h" |
9 #include "content/test/test_browser_thread.h" | |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/base/test/cocoa_test_event_utils.h" | 11 #include "ui/base/test/cocoa_test_event_utils.h" |
12 #import "ui/base/test/ui_cocoa_test_helper.h" | 12 #import "ui/base/test/ui_cocoa_test_helper.h" |
13 #include "webkit/plugins/npapi/webplugin.h" | 13 #include "webkit/plugins/npapi/webplugin.h" |
14 | 14 |
15 class RenderWidgetHostViewMacTest : public RenderViewHostTestHarness { | 15 class RenderWidgetHostViewMacTest : public RenderViewHostTestHarness { |
16 public: | 16 public: |
17 RenderWidgetHostViewMacTest() : old_rwhv_(NULL), rwhv_mac_(NULL) {} | 17 RenderWidgetHostViewMacTest() : old_rwhv_(NULL), rwhv_mac_(NULL) {} |
18 | 18 |
19 virtual void SetUp() { | 19 virtual void SetUp() { |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 private: | 81 private: |
82 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMacTest); | 82 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMacTest); |
83 }; | 83 }; |
84 | 84 |
85 TEST_F(RenderWidgetHostViewMacTest, Basic) { | 85 TEST_F(RenderWidgetHostViewMacTest, Basic) { |
86 } | 86 } |
87 | 87 |
88 // Regression test for http://crbug.com/60318 | 88 // Regression test for http://crbug.com/60318 |
89 TEST_F(RenderWidgetHostViewMacTest, FocusAcceleratedView) { | 89 TEST_F(RenderWidgetHostViewMacTest, FocusAcceleratedView) { |
90 // The accelerated view methods want to be called on the UI thread. | 90 // The accelerated view methods want to be called on the UI thread. |
91 scoped_ptr<content::TestBrowserThread> ui_thread_( | 91 scoped_ptr<content::BrowserThreadImpl> ui_thread_( |
jam
2011/10/28 17:00:21
add using in this file?
Jói
2011/10/31 15:13:15
Done.
| |
92 new content::TestBrowserThread(BrowserThread::UI, | 92 new content::BrowserThreadImpl(BrowserThread::UI, |
93 MessageLoop::current())); | 93 MessageLoop::current())); |
94 | 94 |
95 int w = 400, h = 300; | 95 int w = 400, h = 300; |
96 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h); | 96 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h); |
97 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]); | 97 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]); |
98 NSView* accelerated_view = static_cast<NSView*>( | 98 NSView* accelerated_view = static_cast<NSView*>( |
99 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle)); | 99 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle)); |
100 EXPECT_FALSE([accelerated_view isHidden]); | 100 EXPECT_FALSE([accelerated_view isHidden]); |
101 | 101 |
102 // Take away first responder from the rwhvmac, then simulate the effect of a | 102 // Take away first responder from the rwhvmac, then simulate the effect of a |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 | 154 |
155 std::pair<NSEvent*, NSEvent*> clicks = | 155 std::pair<NSEvent*, NSEvent*> clicks = |
156 cocoa_test_event_utils::MouseClickInView(rwhv_cocoa_.get(), 1); | 156 cocoa_test_event_utils::MouseClickInView(rwhv_cocoa_.get(), 1); |
157 [rwhv_cocoa_.get() mouseDown:clicks.first]; | 157 [rwhv_cocoa_.get() mouseDown:clicks.first]; |
158 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); | 158 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); |
159 } | 159 } |
160 | 160 |
161 // Regression test for http://crbug.com/64256 | 161 // Regression test for http://crbug.com/64256 |
162 TEST_F(RenderWidgetHostViewMacTest, TakesFocusOnMouseDownWithAcceleratedView) { | 162 TEST_F(RenderWidgetHostViewMacTest, TakesFocusOnMouseDownWithAcceleratedView) { |
163 // The accelerated view methods want to be called on the UI thread. | 163 // The accelerated view methods want to be called on the UI thread. |
164 scoped_ptr<content::TestBrowserThread> ui_thread_( | 164 scoped_ptr<content::BrowserThreadImpl> ui_thread_( |
165 new content::TestBrowserThread(BrowserThread::UI, | 165 new content::BrowserThreadImpl(BrowserThread::UI, |
166 MessageLoop::current())); | 166 MessageLoop::current())); |
167 | 167 |
168 int w = 400, h = 300; | 168 int w = 400, h = 300; |
169 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h); | 169 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h); |
170 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]); | 170 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]); |
171 NSView* accelerated_view = static_cast<NSView*>( | 171 NSView* accelerated_view = static_cast<NSView*>( |
172 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle)); | 172 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle)); |
173 EXPECT_FALSE([accelerated_view isHidden]); | 173 EXPECT_FALSE([accelerated_view isHidden]); |
174 | 174 |
175 // Add the RWHVCocoa to the window and remove first responder status. | 175 // Add the RWHVCocoa to the window and remove first responder status. |
(...skipping 11 matching lines...) Expand all Loading... | |
187 | 187 |
188 // A click on the accelerated view should focus the RWHVCocoa. | 188 // A click on the accelerated view should focus the RWHVCocoa. |
189 std::pair<NSEvent*, NSEvent*> clicks = | 189 std::pair<NSEvent*, NSEvent*> clicks = |
190 cocoa_test_event_utils::MouseClickInView(accelerated_view, 1); | 190 cocoa_test_event_utils::MouseClickInView(accelerated_view, 1); |
191 [rwhv_cocoa_.get() mouseDown:clicks.first]; | 191 [rwhv_cocoa_.get() mouseDown:clicks.first]; |
192 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); | 192 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); |
193 | 193 |
194 // Clean up. | 194 // Clean up. |
195 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle); | 195 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle); |
196 } | 196 } |
OLD | NEW |