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

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

Issue 560053002: Do not interchange MOUSE_MOVED and MOUSE_DRAGGED events in Widget (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for review Created 6 years, 2 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
« ui/views/widget/widget.cc ('K') | « 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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 3175 matching lines...) Expand 10 before | Expand all | Expand 10 after
3186 // Drargging. Cover HasCapture() and NativeWidgetPrivate::IsMouseButtonDown(). 3186 // Drargging. Cover HasCapture() and NativeWidgetPrivate::IsMouseButtonDown().
3187 generator.DragMouseTo(gfx::Point(40, 40)); 3187 generator.DragMouseTo(gfx::Point(40, 40));
3188 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_PRESSED)); 3188 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_PRESSED));
3189 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_RELEASED)); 3189 EXPECT_EQ(3, view->GetEventCount(ui::ET_MOUSE_RELEASED));
3190 EXPECT_EQ(1, view->GetEventCount(ui::ET_MOUSE_DRAGGED)); 3190 EXPECT_EQ(1, view->GetEventCount(ui::ET_MOUSE_DRAGGED));
3191 EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON, view->last_flags()); 3191 EXPECT_EQ(ui::EF_LEFT_MOUSE_BUTTON, view->last_flags());
3192 3192
3193 widget->CloseNow(); 3193 widget->CloseNow();
3194 } 3194 }
3195 3195
3196 // Tests that a view does not receive entered, dragged, or moved events if
3197 // a mouse cursor is moved into it while the left mouse button is pressed.
3198 TEST_F(WidgetTest, DragIntoView) {
3199 EventCountView* container = new EventCountView;
3200 container->SetBounds(0, 0, 100, 80);
3201
3202 EventCountView* consume_view = new EventCountView;
3203 consume_view->set_handle_mode(EventCountView::CONSUME_EVENTS);
3204 consume_view->SetBounds(10, 10, 50, 40);
3205
3206 Widget* widget = CreateTopLevelFramelessPlatformWidget();
3207 widget->SetBounds(gfx::Rect(0, 0, 100, 80));
3208 widget->SetContentsView(container);
3209 container->AddChildView(consume_view);
3210
3211 widget->Show();
3212
3213 ui::test::EventGenerator generator(GetContext(), widget->GetNativeWindow());
3214 generator.set_current_location(gfx::Point(75, 15));
3215
3216 generator.PressLeftButton();
3217 generator.MoveMouseTo(gfx::Point(20, 20));
3218 EXPECT_EQ(0, consume_view->GetEventCount(ui::ET_MOUSE_ENTERED));
3219 EXPECT_EQ(0, consume_view->GetEventCount(ui::ET_MOUSE_DRAGGED));
3220 EXPECT_EQ(0, consume_view->GetEventCount(ui::ET_MOUSE_MOVED));
3221
3222 widget->CloseNow();
3223 }
3224
3196 // Tests that the root view is correctly set up for Widget types that do not 3225 // Tests that the root view is correctly set up for Widget types that do not
3197 // require a non-client view, before any other views are added to the widget. 3226 // require a non-client view, before any other views are added to the widget.
3198 // That is, before Widget::ReorderNativeViews() is called which, if called with 3227 // That is, before Widget::ReorderNativeViews() is called which, if called with
3199 // a root view not set, could cause the root view to get resized to the widget. 3228 // a root view not set, could cause the root view to get resized to the widget.
3200 TEST_F(WidgetTest, NonClientWindowValidAfterInit) { 3229 TEST_F(WidgetTest, NonClientWindowValidAfterInit) {
3201 Widget* widget = CreateTopLevelFramelessPlatformWidget(); 3230 Widget* widget = CreateTopLevelFramelessPlatformWidget();
3202 View* root_view = widget->GetRootView(); 3231 View* root_view = widget->GetRootView();
3203 3232
3204 // Size the root view to exceed the widget bounds. 3233 // Size the root view to exceed the widget bounds.
3205 const gfx::Rect test_rect(0, 0, 500, 500); 3234 const gfx::Rect test_rect(0, 0, 500, 500);
3206 root_view->SetBoundsRect(test_rect); 3235 root_view->SetBoundsRect(test_rect);
3207 3236
3208 EXPECT_NE(test_rect.size(), widget->GetWindowBoundsInScreen().size()); 3237 EXPECT_NE(test_rect.size(), widget->GetWindowBoundsInScreen().size());
3209 3238
3210 EXPECT_EQ(test_rect, root_view->bounds()); 3239 EXPECT_EQ(test_rect, root_view->bounds());
3211 widget->ReorderNativeViews(); 3240 widget->ReorderNativeViews();
3212 EXPECT_EQ(test_rect, root_view->bounds()); 3241 EXPECT_EQ(test_rect, root_view->bounds());
3213 3242
3214 widget->CloseNow(); 3243 widget->CloseNow();
3215 } 3244 }
3216 3245
3217 } // namespace test 3246 } // namespace test
3218 } // namespace views 3247 } // namespace views
OLDNEW
« ui/views/widget/widget.cc ('K') | « ui/views/widget/widget.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698