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

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

Issue 8340028: Salient parts of http://codereview.chromium.org/8392042/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: 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
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.h"
9 #include "content/browser/renderer_host/test_render_view_host.h" 8 #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
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<BrowserThread> ui_thread_( 91 scoped_ptr<content::TestBrowserThread> ui_thread_(
92 new BrowserThread(BrowserThread::UI, MessageLoop::current())); 92 new content::TestBrowserThread(BrowserThread::UI,
93 MessageLoop::current()));
93 94
94 int w = 400, h = 300; 95 int w = 400, h = 300;
95 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h); 96 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h);
96 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]); 97 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]);
97 NSView* accelerated_view = static_cast<NSView*>( 98 NSView* accelerated_view = static_cast<NSView*>(
98 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle)); 99 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle));
99 EXPECT_FALSE([accelerated_view isHidden]); 100 EXPECT_FALSE([accelerated_view isHidden]);
100 101
101 // 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
102 // click on the accelerated view. The rwhvmac should be first responder 103 // click on the accelerated view. The rwhvmac should be first responder
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 154
154 std::pair<NSEvent*, NSEvent*> clicks = 155 std::pair<NSEvent*, NSEvent*> clicks =
155 cocoa_test_event_utils::MouseClickInView(rwhv_cocoa_.get(), 1); 156 cocoa_test_event_utils::MouseClickInView(rwhv_cocoa_.get(), 1);
156 [rwhv_cocoa_.get() mouseDown:clicks.first]; 157 [rwhv_cocoa_.get() mouseDown:clicks.first];
157 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); 158 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]);
158 } 159 }
159 160
160 // Regression test for http://crbug.com/64256 161 // Regression test for http://crbug.com/64256
161 TEST_F(RenderWidgetHostViewMacTest, TakesFocusOnMouseDownWithAcceleratedView) { 162 TEST_F(RenderWidgetHostViewMacTest, TakesFocusOnMouseDownWithAcceleratedView) {
162 // 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.
163 scoped_ptr<BrowserThread> ui_thread_( 164 scoped_ptr<content::TestBrowserThread> ui_thread_(
164 new BrowserThread(BrowserThread::UI, MessageLoop::current())); 165 new content::TestBrowserThread(BrowserThread::UI,
166 MessageLoop::current()));
165 167
166 int w = 400, h = 300; 168 int w = 400, h = 300;
167 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h); 169 gfx::PluginWindowHandle accelerated_handle = AddAcceleratedPluginView(w, h);
168 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]); 170 EXPECT_FALSE([rwhv_cocoa_.get() isHidden]);
169 NSView* accelerated_view = static_cast<NSView*>( 171 NSView* accelerated_view = static_cast<NSView*>(
170 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle)); 172 rwhv_mac_->ViewForPluginWindowHandle(accelerated_handle));
171 EXPECT_FALSE([accelerated_view isHidden]); 173 EXPECT_FALSE([accelerated_view isHidden]);
172 174
173 // Add the RWHVCocoa to the window and remove first responder status. 175 // Add the RWHVCocoa to the window and remove first responder status.
174 scoped_nsobject<CocoaTestHelperWindow> 176 scoped_nsobject<CocoaTestHelperWindow>
(...skipping 10 matching lines...) Expand all
185 187
186 // A click on the accelerated view should focus the RWHVCocoa. 188 // A click on the accelerated view should focus the RWHVCocoa.
187 std::pair<NSEvent*, NSEvent*> clicks = 189 std::pair<NSEvent*, NSEvent*> clicks =
188 cocoa_test_event_utils::MouseClickInView(accelerated_view, 1); 190 cocoa_test_event_utils::MouseClickInView(accelerated_view, 1);
189 [rwhv_cocoa_.get() mouseDown:clicks.first]; 191 [rwhv_cocoa_.get() mouseDown:clicks.first];
190 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]); 192 EXPECT_EQ(rwhv_cocoa_.get(), [window firstResponder]);
191 193
192 // Clean up. 194 // Clean up.
193 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle); 195 rwhv_mac_->DestroyFakePluginWindowHandle(accelerated_handle);
194 } 196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698