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

Side by Side Diff: ash/drag_drop/drag_drop_controller_unittest.cc

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address build problems, add accessor and unit tests. Created 5 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
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 "ash/drag_drop/drag_drop_controller.h" 5 #include "ash/drag_drop/drag_drop_controller.h"
6 6
7 #include "ash/drag_drop/drag_drop_tracker.h" 7 #include "ash/drag_drop/drag_drop_tracker.h"
8 #include "ash/drag_drop/drag_image_view.h" 8 #include "ash/drag_drop/drag_image_view.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 713 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
714 // drag_data_ to a fake drag data object that we created. 714 // drag_data_ to a fake drag data object that we created.
715 if (i > 0) 715 if (i > 0)
716 UpdateDragData(&data); 716 UpdateDragData(&data);
717 generator.MoveMouseBy(0, 1); 717 generator.MoveMouseBy(0, 1);
718 718
719 // We send a unexpected mouse move event. Note that we cannot use 719 // We send a unexpected mouse move event. Note that we cannot use
720 // EventGenerator since it implicitly turns these into mouse drag events. 720 // EventGenerator since it implicitly turns these into mouse drag events.
721 // The DragDropController should simply ignore these events. 721 // The DragDropController should simply ignore these events.
722 gfx::Point mouse_move_location = drag_view->bounds().CenterPoint(); 722 gfx::Point mouse_move_location = drag_view->bounds().CenterPoint();
723 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, mouse_move_location, 723 ui::MouseEvent mouse_move(
724 mouse_move_location, ui::EventTimeForNow(), 0, 0); 724 ui::ET_MOUSE_MOVED, mouse_move_location, mouse_move_location,
725 ui::EventTimeForNow(), 0, 0,
726 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
725 ui::EventDispatchDetails details = Shell::GetPrimaryRootWindow()-> 727 ui::EventDispatchDetails details = Shell::GetPrimaryRootWindow()->
726 GetHost()->event_processor()->OnEventFromSource(&mouse_move); 728 GetHost()->event_processor()->OnEventFromSource(&mouse_move);
727 ASSERT_FALSE(details.dispatcher_destroyed); 729 ASSERT_FALSE(details.dispatcher_destroyed);
728 } 730 }
729 731
730 generator.ReleaseLeftButton(); 732 generator.ReleaseLeftButton();
731 733
732 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 734 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
733 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(), 735 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(),
734 drag_drop_controller_->num_drag_updates_); 736 drag_drop_controller_->num_drag_updates_);
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 window, 1000 window,
999 gfx::Point(5, 5), 1001 gfx::Point(5, 5),
1000 ui::DragDropTypes::DRAG_MOVE, 1002 ui::DragDropTypes::DRAG_MOVE,
1001 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 1003 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
1002 1004
1003 DragImageWindowObserver observer; 1005 DragImageWindowObserver observer;
1004 ASSERT_TRUE(GetDragImageWindow()); 1006 ASSERT_TRUE(GetDragImageWindow());
1005 GetDragImageWindow()->AddObserver(&observer); 1007 GetDragImageWindow()->AddObserver(&observer);
1006 1008
1007 { 1009 {
1008 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), 1010 ui::MouseEvent e(
1009 gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, 1011 ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), gfx::Point(200, 0),
1010 ui::EF_NONE); 1012 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
1013 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
1011 drag_drop_controller_->DragUpdate(window, e); 1014 drag_drop_controller_->DragUpdate(window, e);
1012 } 1015 }
1013 { 1016 {
1014 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), 1017 ui::MouseEvent e(
1015 gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, 1018 ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), gfx::Point(600, 0),
1016 ui::EF_NONE); 1019 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
1020 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
1017 drag_drop_controller_->DragUpdate(window, e); 1021 drag_drop_controller_->DragUpdate(window, e);
1018 } 1022 }
1019 1023
1020 drag_drop_controller_->DragCancel(); 1024 drag_drop_controller_->DragCancel();
1021 CompleteCancelAnimation(); 1025 CompleteCancelAnimation();
1022 1026
1023 EXPECT_EQ("5,5", observer.window_location_on_destroying().ToString()); 1027 EXPECT_EQ("5,5", observer.window_location_on_destroying().ToString());
1024 } 1028 }
1025 1029
1026 { 1030 {
1027 scoped_ptr<views::Widget> widget(CreateNewWidget()); 1031 scoped_ptr<views::Widget> widget(CreateNewWidget());
1028 aura::Window* window = widget->GetNativeWindow(); 1032 aura::Window* window = widget->GetNativeWindow();
1029 drag_drop_controller_->StartDragAndDrop( 1033 drag_drop_controller_->StartDragAndDrop(
1030 data, 1034 data,
1031 window->GetRootWindow(), 1035 window->GetRootWindow(),
1032 window, 1036 window,
1033 gfx::Point(405, 405), 1037 gfx::Point(405, 405),
1034 ui::DragDropTypes::DRAG_MOVE, 1038 ui::DragDropTypes::DRAG_MOVE,
1035 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 1039 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
1036 DragImageWindowObserver observer; 1040 DragImageWindowObserver observer;
1037 ASSERT_TRUE(GetDragImageWindow()); 1041 ASSERT_TRUE(GetDragImageWindow());
1038 GetDragImageWindow()->AddObserver(&observer); 1042 GetDragImageWindow()->AddObserver(&observer);
1039 1043
1040 { 1044 {
1041 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), 1045 ui::MouseEvent e(
1042 gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, 1046 ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), gfx::Point(600, 0),
1043 ui::EF_NONE); 1047 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
1048 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
1044 drag_drop_controller_->DragUpdate(window, e); 1049 drag_drop_controller_->DragUpdate(window, e);
1045 } 1050 }
1046 { 1051 {
1047 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), 1052 ui::MouseEvent e(
1048 gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, 1053 ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), gfx::Point(200, 0),
1049 ui::EF_NONE); 1054 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
1055 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
1050 drag_drop_controller_->DragUpdate(window, e); 1056 drag_drop_controller_->DragUpdate(window, e);
1051 } 1057 }
1052 1058
1053 drag_drop_controller_->DragCancel(); 1059 drag_drop_controller_->DragCancel();
1054 CompleteCancelAnimation(); 1060 CompleteCancelAnimation();
1055 1061
1056 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString()); 1062 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString());
1057 } 1063 }
1058 for (aura::Window::Windows::iterator iter = root_windows.begin(); 1064 for (aura::Window::Windows::iterator iter = root_windows.begin();
1059 iter != root_windows.end(); ++iter) { 1065 iter != root_windows.end(); ++iter) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1103 drag_drop_controller_->drag_string_); 1109 drag_drop_controller_->drag_string_);
1104 EXPECT_EQ(1, drag_view->num_drag_enters_); 1110 EXPECT_EQ(1, drag_view->num_drag_enters_);
1105 EXPECT_EQ(2, drag_view->num_drag_updates_); 1111 EXPECT_EQ(2, drag_view->num_drag_updates_);
1106 EXPECT_EQ(1, drag_view->num_drops_); 1112 EXPECT_EQ(1, drag_view->num_drops_);
1107 EXPECT_EQ(0, drag_view->num_drag_exits_); 1113 EXPECT_EQ(0, drag_view->num_drag_exits_);
1108 EXPECT_TRUE(drag_view->drag_done_received_); 1114 EXPECT_TRUE(drag_view->drag_done_received_);
1109 } 1115 }
1110 1116
1111 } // namespace test 1117 } // namespace test
1112 } // namespace ash 1118 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698