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

Side by Side Diff: ui/views/widget/widget_unittest.cc

Issue 10832282: Replace views::MouseEvent with ui::MouseEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months 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
« no previous file with comments | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/native_widget_types.h" 9 #include "ui/gfx/native_widget_types.h"
10 #include "ui/gfx/point.h" 10 #include "ui/gfx/point.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 typedef NativeWidgetWin NativeWidgetPlatformForTest; 68 typedef NativeWidgetWin NativeWidgetPlatformForTest;
69 #endif 69 #endif
70 70
71 // A view that always processes all mouse events. 71 // A view that always processes all mouse events.
72 class MouseView : public View { 72 class MouseView : public View {
73 public: 73 public:
74 MouseView() : View() { 74 MouseView() : View() {
75 } 75 }
76 virtual ~MouseView() {} 76 virtual ~MouseView() {}
77 77
78 virtual bool OnMousePressed(const MouseEvent& event) OVERRIDE { 78 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE {
79 return true; 79 return true;
80 } 80 }
81 }; 81 };
82 82
83 typedef ViewsTestBase WidgetTest; 83 typedef ViewsTestBase WidgetTest;
84 84
85 NativeWidget* CreatePlatformNativeWidget( 85 NativeWidget* CreatePlatformNativeWidget(
86 internal::NativeWidgetDelegate* delegate) { 86 internal::NativeWidgetDelegate* delegate) {
87 return new NativeWidgetPlatformForTest(delegate); 87 return new NativeWidgetPlatformForTest(delegate);
88 } 88 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 206
207 child2->SetBounds(gfx::Rect(200, 10, 200, 200)); 207 child2->SetBounds(gfx::Rect(200, 10, 200, 200));
208 view = new MouseView(); 208 view = new MouseView();
209 view->SetBounds(0, 0, 200, 200); 209 view->SetBounds(0, 0, 200, 200);
210 child2->GetRootView()->AddChildView(view); 210 child2->GetRootView()->AddChildView(view);
211 211
212 toplevel->Show(); 212 toplevel->Show();
213 RunPendingMessages(); 213 RunPendingMessages();
214 214
215 // Click on child1 215 // Click on child1
216 MouseEvent pressed(ui::ET_MOUSE_PRESSED, 45, 45, ui::EF_LEFT_MOUSE_BUTTON); 216 gfx::Point p1(45, 45);
217 ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1,
218 ui::EF_LEFT_MOUSE_BUTTON);
217 toplevel->OnMouseEvent(pressed); 219 toplevel->OnMouseEvent(pressed);
218 220
219 EXPECT_TRUE(WidgetHasMouseCapture(toplevel)); 221 EXPECT_TRUE(WidgetHasMouseCapture(toplevel));
220 EXPECT_TRUE(WidgetHasMouseCapture(child1)); 222 EXPECT_TRUE(WidgetHasMouseCapture(child1));
221 EXPECT_FALSE(WidgetHasMouseCapture(child2)); 223 EXPECT_FALSE(WidgetHasMouseCapture(child2));
222 224
223 MouseEvent released(ui::ET_MOUSE_RELEASED, 45, 45, ui::EF_LEFT_MOUSE_BUTTON); 225 ui::MouseEvent released(ui::ET_MOUSE_RELEASED, p1, p1,
226 ui::EF_LEFT_MOUSE_BUTTON);
224 toplevel->OnMouseEvent(released); 227 toplevel->OnMouseEvent(released);
225 228
226 EXPECT_FALSE(WidgetHasMouseCapture(toplevel)); 229 EXPECT_FALSE(WidgetHasMouseCapture(toplevel));
227 EXPECT_FALSE(WidgetHasMouseCapture(child1)); 230 EXPECT_FALSE(WidgetHasMouseCapture(child1));
228 EXPECT_FALSE(WidgetHasMouseCapture(child2)); 231 EXPECT_FALSE(WidgetHasMouseCapture(child2));
229 232
230 RunPendingMessages(); 233 RunPendingMessages();
231 234
232 // Click on child2 235 // Click on child2
233 MouseEvent pressed2(ui::ET_MOUSE_PRESSED, 315, 45, ui::EF_LEFT_MOUSE_BUTTON); 236 gfx::Point p2(315, 45);
237 ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, p2, p2,
238 ui::EF_LEFT_MOUSE_BUTTON);
234 EXPECT_TRUE(toplevel->OnMouseEvent(pressed2)); 239 EXPECT_TRUE(toplevel->OnMouseEvent(pressed2));
235 EXPECT_TRUE(WidgetHasMouseCapture(toplevel)); 240 EXPECT_TRUE(WidgetHasMouseCapture(toplevel));
236 EXPECT_TRUE(WidgetHasMouseCapture(child2)); 241 EXPECT_TRUE(WidgetHasMouseCapture(child2));
237 EXPECT_FALSE(WidgetHasMouseCapture(child1)); 242 EXPECT_FALSE(WidgetHasMouseCapture(child1));
238 243
239 MouseEvent released2(ui::ET_MOUSE_RELEASED, 315, 45, 244 ui::MouseEvent released2(ui::ET_MOUSE_RELEASED, p2, p2,
240 ui::EF_LEFT_MOUSE_BUTTON); 245 ui::EF_LEFT_MOUSE_BUTTON);
241 toplevel->OnMouseEvent(released2); 246 toplevel->OnMouseEvent(released2);
242 EXPECT_FALSE(WidgetHasMouseCapture(toplevel)); 247 EXPECT_FALSE(WidgetHasMouseCapture(toplevel));
243 EXPECT_FALSE(WidgetHasMouseCapture(child1)); 248 EXPECT_FALSE(WidgetHasMouseCapture(child1));
244 EXPECT_FALSE(WidgetHasMouseCapture(child2)); 249 EXPECT_FALSE(WidgetHasMouseCapture(child2));
245 250
246 toplevel->CloseNow(); 251 toplevel->CloseNow();
247 } 252 }
248 253
249 // Test if a focus manager and an inputmethod work without CHECK failure 254 // Test if a focus manager and an inputmethod work without CHECK failure
250 // when window activation changes. 255 // when window activation changes.
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 // And it stays maximized after getting out of full screen. 821 // And it stays maximized after getting out of full screen.
817 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel)); 822 EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel));
818 823
819 // Clean up. 824 // Clean up.
820 toplevel->Close(); 825 toplevel->Close();
821 RunPendingMessages(); 826 RunPendingMessages();
822 } 827 }
823 828
824 } // namespace 829 } // namespace
825 } // namespace views 830 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698