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

Side by Side Diff: ui/app_list/views/app_list_main_view_unittest.cc

Issue 2786693002: Add PointerDetails to ui::MouseEvent's constructors (Closed)
Patch Set: mouse event constructor Created 3 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "ui/app_list/views/app_list_main_view.h" 5 #include "ui/app_list/views/app_list_main_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 126 }
127 } 127 }
128 128
129 return NULL; 129 return NULL;
130 } 130 }
131 131
132 void SimulateClick(views::View* view) { 132 void SimulateClick(views::View* view) {
133 gfx::Point center = view->GetLocalBounds().CenterPoint(); 133 gfx::Point center = view->GetLocalBounds().CenterPoint();
134 view->OnMousePressed(ui::MouseEvent( 134 view->OnMousePressed(ui::MouseEvent(
135 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(), 135 ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(),
136 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 136 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
137 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
137 view->OnMouseReleased(ui::MouseEvent( 138 view->OnMouseReleased(ui::MouseEvent(
138 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(), 139 ui::ET_MOUSE_RELEASED, center, center, ui::EventTimeForNow(),
139 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); 140 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON,
141 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE)));
140 } 142 }
141 143
142 // |point| is in |grid_view|'s coordinates. 144 // |point| is in |grid_view|'s coordinates.
143 AppListItemView* SimulateInitiateDrag(AppsGridView* grid_view, 145 AppListItemView* SimulateInitiateDrag(AppsGridView* grid_view,
144 AppsGridView::Pointer pointer, 146 AppsGridView::Pointer pointer,
145 const gfx::Point& point) { 147 const gfx::Point& point) {
146 AppListItemView* view = GetItemViewAtPointInGrid(grid_view, point); 148 AppListItemView* view = GetItemViewAtPointInGrid(grid_view, point);
147 DCHECK(view); 149 DCHECK(view);
148 150
149 gfx::Point translated = 151 gfx::Point translated =
150 gfx::PointAtOffsetFromOrigin(point - view->origin()); 152 gfx::PointAtOffsetFromOrigin(point - view->origin());
151 ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, translated, point, 153 ui::MouseEvent pressed_event(
152 ui::EventTimeForNow(), 0, 0); 154 ui::ET_MOUSE_PRESSED, translated, point, ui::EventTimeForNow(), 0, 0,
155 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
153 grid_view->InitiateDrag(view, pointer, pressed_event); 156 grid_view->InitiateDrag(view, pointer, pressed_event);
154 return view; 157 return view;
155 } 158 }
156 159
157 // |point| is in |grid_view|'s coordinates. 160 // |point| is in |grid_view|'s coordinates.
158 void SimulateUpdateDrag(AppsGridView* grid_view, 161 void SimulateUpdateDrag(AppsGridView* grid_view,
159 AppsGridView::Pointer pointer, 162 AppsGridView::Pointer pointer,
160 AppListItemView* drag_view, 163 AppListItemView* drag_view,
161 const gfx::Point& point) { 164 const gfx::Point& point) {
162 DCHECK(drag_view); 165 DCHECK(drag_view);
163 gfx::Point translated = 166 gfx::Point translated =
164 gfx::PointAtOffsetFromOrigin(point - drag_view->origin()); 167 gfx::PointAtOffsetFromOrigin(point - drag_view->origin());
165 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated, point, 168 ui::MouseEvent drag_event(
166 ui::EventTimeForNow(), 0, 0); 169 ui::ET_MOUSE_DRAGGED, translated, point, ui::EventTimeForNow(), 0, 0,
170 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
167 grid_view->UpdateDragFromItem(pointer, drag_event); 171 grid_view->UpdateDragFromItem(pointer, drag_event);
168 } 172 }
169 173
170 ContentsView* GetContentsView() { return main_view_->contents_view(); } 174 ContentsView* GetContentsView() { return main_view_->contents_view(); }
171 175
172 AppsGridView* RootGridView() { 176 AppsGridView* RootGridView() {
173 return GetContentsView()->apps_container_view()->apps_grid_view(); 177 return GetContentsView()->apps_container_view()->apps_grid_view();
174 } 178 }
175 179
176 AppListFolderView* FolderView() { 180 AppListFolderView* FolderView() {
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // The app list model should remain unchanged. 453 // The app list model should remain unchanged.
450 EXPECT_EQ(1, FolderViewModel()->view_size()); 454 EXPECT_EQ(1, FolderViewModel()->view_size());
451 EXPECT_EQ(2, RootViewModel()->view_size()); 455 EXPECT_EQ(2, RootViewModel()->view_size());
452 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id()); 456 EXPECT_EQ(folder_id, RootGridView()->GetItemViewAt(0)->item()->id());
453 EXPECT_NE(nullptr, 457 EXPECT_NE(nullptr,
454 delegate_->GetTestModel()->FindFolderItem("single_item_folder")); 458 delegate_->GetTestModel()->FindFolderItem("single_item_folder"));
455 } 459 }
456 460
457 } // namespace test 461 } // namespace test
458 } // namespace app_list 462 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698