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

Side by Side Diff: ui/app_list/views/apps_grid_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 (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 "ui/app_list/views/apps_grid_view.h" 5 #include "ui/app_list/views/apps_grid_view.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 const gfx::Point& from, 145 const gfx::Point& from,
146 const gfx::Point& to) { 146 const gfx::Point& to) {
147 AppListItemView* view = GetItemViewForPoint(from); 147 AppListItemView* view = GetItemViewForPoint(from);
148 DCHECK(view); 148 DCHECK(view);
149 149
150 gfx::Point translated_from = 150 gfx::Point translated_from =
151 gfx::PointAtOffsetFromOrigin(from - view->origin()); 151 gfx::PointAtOffsetFromOrigin(from - view->origin());
152 gfx::Point translated_to = 152 gfx::Point translated_to =
153 gfx::PointAtOffsetFromOrigin(to - view->origin()); 153 gfx::PointAtOffsetFromOrigin(to - view->origin());
154 154
155 ui::MouseEvent pressed_event(ui::ET_MOUSE_PRESSED, translated_from, from, 155 ui::MouseEvent pressed_event(
156 ui::EventTimeForNow(), 0, 0); 156 ui::ET_MOUSE_PRESSED, translated_from, from, ui::EventTimeForNow(), 0,
157 0, ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
157 apps_grid_view_->InitiateDrag(view, pointer, pressed_event); 158 apps_grid_view_->InitiateDrag(view, pointer, pressed_event);
158 159
159 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated_to, to, 160 ui::MouseEvent drag_event(
160 ui::EventTimeForNow(), 0, 0); 161 ui::ET_MOUSE_DRAGGED, translated_to, to, ui::EventTimeForNow(), 0, 0,
162 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
161 apps_grid_view_->UpdateDragFromItem(pointer, drag_event); 163 apps_grid_view_->UpdateDragFromItem(pointer, drag_event);
162 return view; 164 return view;
163 } 165 }
164 166
165 void SimulateKeyPress(ui::KeyboardCode key_code) { 167 void SimulateKeyPress(ui::KeyboardCode key_code) {
166 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE); 168 ui::KeyEvent key_event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE);
167 apps_grid_view_->OnKeyPressed(key_event); 169 apps_grid_view_->OnKeyPressed(key_event);
168 } 170 }
169 171
170 std::unique_ptr<AppListTestModel> model_; 172 std::unique_ptr<AppListTestModel> model_;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 test_api_->LayoutToIdealBounds(); 298 test_api_->LayoutToIdealBounds();
297 299
298 // Adding a launcher item cancels the drag and respects the order. 300 // Adding a launcher item cancels the drag and respects the order.
299 SimulateDrag(AppsGridView::MOUSE, from, to); 301 SimulateDrag(AppsGridView::MOUSE, from, to);
300 EXPECT_TRUE(apps_grid_view_->has_dragged_view()); 302 EXPECT_TRUE(apps_grid_view_->has_dragged_view());
301 model_->CreateAndAddItem("Extra"); 303 model_->CreateAndAddItem("Extra");
302 // No need to EndDrag explicitly - adding an item should do this. 304 // No need to EndDrag explicitly - adding an item should do this.
303 EXPECT_FALSE(apps_grid_view_->has_dragged_view()); 305 EXPECT_FALSE(apps_grid_view_->has_dragged_view());
304 // Even though cancelled, mouse move events can still arrive via the item 306 // Even though cancelled, mouse move events can still arrive via the item
305 // view. Ensure that behaves sanely, and doesn't start a new drag. 307 // view. Ensure that behaves sanely, and doesn't start a new drag.
306 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1), 308 ui::MouseEvent drag_event(
307 gfx::Point(2, 2), ui::EventTimeForNow(), 0, 0); 309 ui::ET_MOUSE_DRAGGED, gfx::Point(1, 1), gfx::Point(2, 2),
310 ui::EventTimeForNow(), 0, 0,
311 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
308 apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, drag_event); 312 apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, drag_event);
309 EXPECT_FALSE(apps_grid_view_->has_dragged_view()); 313 EXPECT_FALSE(apps_grid_view_->has_dragged_view());
310 314
311 EXPECT_EQ(std::string("Item 1,Item 2,Item 3,Extra"), 315 EXPECT_EQ(std::string("Item 1,Item 2,Item 3,Extra"),
312 model_->GetModelContent()); 316 model_->GetModelContent());
313 test_api_->LayoutToIdealBounds(); 317 test_api_->LayoutToIdealBounds();
314 } 318 }
315 319
316 TEST_F(AppsGridViewTest, MouseDragItemIntoFolder) { 320 TEST_F(AppsGridViewTest, MouseDragItemIntoFolder) {
317 size_t kTotalItems = 3; 321 size_t kTotalItems = 3;
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 439
436 // The grid now looks like | blank | folder |. 440 // The grid now looks like | blank | folder |.
437 EXPECT_EQ(NULL, GetItemViewForPoint(GetItemTileRectAt(0, 0).CenterPoint())); 441 EXPECT_EQ(NULL, GetItemViewForPoint(GetItemTileRectAt(0, 0).CenterPoint()));
438 EXPECT_EQ(folder_view, 442 EXPECT_EQ(folder_view,
439 GetItemViewForPoint(GetItemTileRectAt(0, 1).CenterPoint())); 443 GetItemViewForPoint(GetItemTileRectAt(0, 1).CenterPoint()));
440 444
441 // Move onto the folder and end the drag. 445 // Move onto the folder and end the drag.
442 to = GetItemTileRectAt(0, 1).CenterPoint(); 446 to = GetItemTileRectAt(0, 1).CenterPoint();
443 gfx::Point translated_to = 447 gfx::Point translated_to =
444 gfx::PointAtOffsetFromOrigin(to - dragged_view->origin()); 448 gfx::PointAtOffsetFromOrigin(to - dragged_view->origin());
445 ui::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, translated_to, to, 449 ui::MouseEvent drag_event(
446 ui::EventTimeForNow(), 0, 0); 450 ui::ET_MOUSE_DRAGGED, translated_to, to, ui::EventTimeForNow(), 0, 0,
451 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
447 apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, drag_event); 452 apps_grid_view_->UpdateDragFromItem(AppsGridView::MOUSE, drag_event);
448 apps_grid_view_->EndDrag(false); 453 apps_grid_view_->EndDrag(false);
449 454
450 // The item should not have moved into the folder. 455 // The item should not have moved into the folder.
451 EXPECT_EQ(2u, model_->top_level_item_list()->item_count()); 456 EXPECT_EQ(2u, model_->top_level_item_list()->item_count());
452 EXPECT_EQ(kMaxFolderItems, folder_item->ChildItemCount()); 457 EXPECT_EQ(kMaxFolderItems, folder_item->ChildItemCount());
453 test_api_->LayoutToIdealBounds(); 458 test_api_->LayoutToIdealBounds();
454 } 459 }
455 460
456 TEST_F(AppsGridViewTest, MouseDragItemReorder) { 461 TEST_F(AppsGridViewTest, MouseDragItemReorder) {
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 AppListItemView* item_view = GetItemViewAt(0); 773 AppListItemView* item_view = GetItemViewAt(0);
769 ASSERT_TRUE(item_view); 774 ASSERT_TRUE(item_view);
770 const views::Label* title_label = item_view->title(); 775 const views::Label* title_label = item_view->title();
771 EXPECT_FALSE(title_label->GetTooltipText( 776 EXPECT_FALSE(title_label->GetTooltipText(
772 title_label->bounds().CenterPoint(), &actual_tooltip)); 777 title_label->bounds().CenterPoint(), &actual_tooltip));
773 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text())); 778 EXPECT_EQ(title, base::UTF16ToUTF8(title_label->text()));
774 } 779 }
775 780
776 } // namespace test 781 } // namespace test
777 } // namespace app_list 782 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698