Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1040)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac_unittest.mm

Issue 8400060: Switch content tests to use BrowserThreadImpl directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to lkgr Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 using content::BrowserThreadImpl;
16
15 class RenderWidgetHostViewMacTest : public RenderViewHostTestHarness { 17 class RenderWidgetHostViewMacTest : public RenderViewHostTestHarness {
16 public: 18 public:
17 RenderWidgetHostViewMacTest() : old_rwhv_(NULL), rwhv_mac_(NULL) {} 19 RenderWidgetHostViewMacTest() : old_rwhv_(NULL), rwhv_mac_(NULL) {}
18 20
19 virtual void SetUp() { 21 virtual void SetUp() {
20 RenderViewHostTestHarness::SetUp(); 22 RenderViewHostTestHarness::SetUp();
21 23
22 // TestRenderViewHost's destruction assumes that its view is a 24 // TestRenderViewHost's destruction assumes that its view is a
23 // TestRenderWidgetHostView, so store its view and reset it back to the 25 // TestRenderWidgetHostView, so store its view and reset it back to the
24 // stored view in |TearDown()|. 26 // stored view in |TearDown()|.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 private: 83 private:
82 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMacTest); 84 DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostViewMacTest);
83 }; 85 };
84 86
85 TEST_F(RenderWidgetHostViewMacTest, Basic) { 87 TEST_F(RenderWidgetHostViewMacTest, Basic) {
86 } 88 }
87 89
88 // Regression test for http://crbug.com/60318 90 // Regression test for http://crbug.com/60318
89 TEST_F(RenderWidgetHostViewMacTest, FocusAcceleratedView) { 91 TEST_F(RenderWidgetHostViewMacTest, FocusAcceleratedView) {
90 // The accelerated view methods want to be called on the UI thread. 92 // The accelerated view methods want to be called on the UI thread.
91 scoped_ptr<content::TestBrowserThread> ui_thread_( 93 scoped_ptr<BrowserThreadImpl> ui_thread_(
92 new content::TestBrowserThread(BrowserThread::UI, 94 new BrowserThreadImpl(BrowserThread::UI,
93 MessageLoop::current())); 95 MessageLoop::current()));
94 96
95 int w = 400, h = 300; 97 int w = 400, h = 300;
96 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h); 98 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h);
97 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]); 99 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]);
98 NSView* accelerated_view = static_cast<NSView*>( 100 NSView* accelerated_view = static_cast<NSView*>(
99 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle)); 101 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle));
100 EXPECT_FALSE([accelerated_view isHidden]); 102 EXPECT_FALSE([accelerated_view isHidden]);
101 103
102 // Take away first responder from the rwhvmac, then simulate the effect of a 104 // Take away first responder from the rwhvmac, then simulate the effect of a
103 // click on the accelerated view. The rwhvmac should be first responder 105 // click on the accelerated view. The rwhvmac should be first responder
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 156
155 std::pair<NSEvent*, NSEvent*> clicks = 157 std::pair<NSEvent*, NSEvent*> clicks =
156 cocoa_test_event_utils::MouseClickInView(rwhv_cocoa_.get(), 1); 158 cocoa_test_event_utils::MouseClickInView(rwhv_cocoa_.get(), 1);
157 [rwhv_cocoa_.get() mouseDown:clicks.first]; 159 [rwhv_cocoa_.get() mouseDown:clicks.first];
158 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); 160 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]);
159 } 161 }
160 162
161 // Regression test for http://crbug.com/64256 163 // Regression test for http://crbug.com/64256
162 TEST_F(RenderWidgetHostViewMacTest, TakesFocusOnMouseDownWithAcceleratedView) { 164 TEST_F(RenderWidgetHostViewMacTest, TakesFocusOnMouseDownWithAcceleratedView) {
163 // The accelerated view methods want to be called on the UI thread. 165 // The accelerated view methods want to be called on the UI thread.
164 scoped_ptr<content::TestBrowserThread> ui_thread_( 166 scoped_ptr<BrowserThreadImpl> ui_thread_(
165 new content::TestBrowserThread(BrowserThread::UI, 167 new BrowserThreadImpl(BrowserThread::UI,
166 MessageLoop::current())); 168 MessageLoop::current()));
167 169
168 int w = 400, h = 300; 170 int w = 400, h = 300;
169 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h); 171 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h);
170 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]); 172 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]);
171 NSView* accelerated_view = static_cast<NSView*>( 173 NSView* accelerated_view = static_cast<NSView*>(
172 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle)); 174 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle));
173 EXPECT_FALSE([accelerated_view isHidden]); 175 EXPECT_FALSE([accelerated_view isHidden]);
174 176
175 // Add the RWHVCocoa to the window and remove first responder status. 177 // Add the RWHVCocoa to the window and remove first responder status.
176 scoped_nsobject<CocoaTestHelperWindow> 178 scoped_nsobject<CocoaTestHelperWindow>
(...skipping 10 matching lines...) Expand all
187 189
188 // A click on the accelerated view should focus the RWHVCocoa. 190 // A click on the accelerated view should focus the RWHVCocoa.
189 std::pair<NSEvent*, NSEvent*> clicks = 191 std::pair<NSEvent*, NSEvent*> clicks =
190 cocoa_test_event_utils::MouseClickInView(accelerated_view, 1); 192 cocoa_test_event_utils::MouseClickInView(accelerated_view, 1);
191 [rwhv_cocoa_.get() mouseDown:clicks.first]; 193 [rwhv_cocoa_.get() mouseDown:clicks.first];
192 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); 194 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]);
193 195
194 // Clean up. 196 // Clean up.
195 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle); 197 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle);
196 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698