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

Side by Side Diff: ash/drag_drop/drag_drop_controller_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 "ash/drag_drop/drag_drop_controller.h" 5 #include "ash/drag_drop/drag_drop_controller.h"
6 6
7 #include "ash/common/drag_drop/drag_image_view.h" 7 #include "ash/common/drag_drop/drag_image_view.h"
8 #include "ash/drag_drop/drag_drop_tracker.h" 8 #include "ash/drag_drop/drag_drop_tracker.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 669 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 680 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
681 // drag_data_ to a fake drag data object that we created. 681 // drag_data_ to a fake drag data object that we created.
682 if (i > 0) 682 if (i > 0)
683 UpdateDragData(&data); 683 UpdateDragData(&data);
684 generator.MoveMouseBy(0, 1); 684 generator.MoveMouseBy(0, 1);
685 685
686 // We send a unexpected mouse move event. Note that we cannot use 686 // We send a unexpected mouse move event. Note that we cannot use
687 // EventGenerator since it implicitly turns these into mouse drag events. 687 // EventGenerator since it implicitly turns these into mouse drag events.
688 // The DragDropController should simply ignore these events. 688 // The DragDropController should simply ignore these events.
689 gfx::Point mouse_move_location = drag_view->bounds().CenterPoint(); 689 gfx::Point mouse_move_location = drag_view->bounds().CenterPoint();
690 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, mouse_move_location, 690 ui::MouseEvent mouse_move(
691 mouse_move_location, ui::EventTimeForNow(), 0, 0); 691 ui::ET_MOUSE_MOVED, mouse_move_location, mouse_move_location,
692 ui::EventTimeForNow(), 0, 0,
693 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
692 ui::EventDispatchDetails details = Shell::GetPrimaryRootWindow() 694 ui::EventDispatchDetails details = Shell::GetPrimaryRootWindow()
693 ->GetHost() 695 ->GetHost()
694 ->event_sink() 696 ->event_sink()
695 ->OnEventFromSource(&mouse_move); 697 ->OnEventFromSource(&mouse_move);
696 ASSERT_FALSE(details.dispatcher_destroyed); 698 ASSERT_FALSE(details.dispatcher_destroyed);
697 } 699 }
698 700
699 generator.ReleaseLeftButton(); 701 generator.ReleaseLeftButton();
700 702
701 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 703 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 drag_drop_controller_->StartDragAndDrop( 954 drag_drop_controller_->StartDragAndDrop(
953 data, window->GetRootWindow(), window, gfx::Point(5, 5), 955 data, window->GetRootWindow(), window, gfx::Point(5, 5),
954 ui::DragDropTypes::DRAG_MOVE, 956 ui::DragDropTypes::DRAG_MOVE,
955 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 957 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
956 958
957 DragImageWindowObserver observer; 959 DragImageWindowObserver observer;
958 ASSERT_TRUE(GetDragImageWindow()); 960 ASSERT_TRUE(GetDragImageWindow());
959 GetDragImageWindow()->AddObserver(&observer); 961 GetDragImageWindow()->AddObserver(&observer);
960 962
961 { 963 {
962 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), 964 ui::MouseEvent e(
963 gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, 965 ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), gfx::Point(200, 0),
964 ui::EF_NONE); 966 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
967 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
965 drag_drop_controller_->DragUpdate(window, e); 968 drag_drop_controller_->DragUpdate(window, e);
966 } 969 }
967 { 970 {
968 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), 971 ui::MouseEvent e(
969 gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, 972 ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), gfx::Point(600, 0),
970 ui::EF_NONE); 973 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
974 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
971 drag_drop_controller_->DragUpdate(window, e); 975 drag_drop_controller_->DragUpdate(window, e);
972 } 976 }
973 977
974 drag_drop_controller_->DragCancel(); 978 drag_drop_controller_->DragCancel();
975 CompleteCancelAnimation(); 979 CompleteCancelAnimation();
976 980
977 EXPECT_EQ("5,5", observer.window_location_on_destroying().ToString()); 981 EXPECT_EQ("5,5", observer.window_location_on_destroying().ToString());
978 } 982 }
979 983
980 { 984 {
981 std::unique_ptr<views::Widget> widget(CreateNewWidget()); 985 std::unique_ptr<views::Widget> widget(CreateNewWidget());
982 aura::Window* window = widget->GetNativeWindow(); 986 aura::Window* window = widget->GetNativeWindow();
983 drag_drop_controller_->StartDragAndDrop( 987 drag_drop_controller_->StartDragAndDrop(
984 data, window->GetRootWindow(), window, gfx::Point(405, 405), 988 data, window->GetRootWindow(), window, gfx::Point(405, 405),
985 ui::DragDropTypes::DRAG_MOVE, 989 ui::DragDropTypes::DRAG_MOVE,
986 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 990 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
987 DragImageWindowObserver observer; 991 DragImageWindowObserver observer;
988 ASSERT_TRUE(GetDragImageWindow()); 992 ASSERT_TRUE(GetDragImageWindow());
989 GetDragImageWindow()->AddObserver(&observer); 993 GetDragImageWindow()->AddObserver(&observer);
990 994
991 { 995 {
992 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), 996 ui::MouseEvent e(
993 gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, 997 ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), gfx::Point(600, 0),
994 ui::EF_NONE); 998 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
999 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
995 drag_drop_controller_->DragUpdate(window, e); 1000 drag_drop_controller_->DragUpdate(window, e);
996 } 1001 }
997 { 1002 {
998 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), 1003 ui::MouseEvent e(
999 gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, 1004 ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), gfx::Point(200, 0),
1000 ui::EF_NONE); 1005 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
1006 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
1001 drag_drop_controller_->DragUpdate(window, e); 1007 drag_drop_controller_->DragUpdate(window, e);
1002 } 1008 }
1003 1009
1004 drag_drop_controller_->DragCancel(); 1010 drag_drop_controller_->DragCancel();
1005 CompleteCancelAnimation(); 1011 CompleteCancelAnimation();
1006 1012
1007 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString()); 1013 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString());
1008 } 1014 }
1009 for (aura::Window::Windows::iterator iter = root_windows.begin(); 1015 for (aura::Window::Windows::iterator iter = root_windows.begin();
1010 iter != root_windows.end(); ++iter) { 1016 iter != root_windows.end(); ++iter) {
(...skipping 10 matching lines...) Expand all
1021 1027
1022 ui::OSExchangeData data; 1028 ui::OSExchangeData data;
1023 data.SetString(base::UTF8ToUTF16("I am being dragged")); 1029 data.SetString(base::UTF8ToUTF16("I am being dragged"));
1024 std::unique_ptr<views::Widget> widget(CreateNewWidget()); 1030 std::unique_ptr<views::Widget> widget(CreateNewWidget());
1025 aura::Window* window = widget->GetNativeWindow(); 1031 aura::Window* window = widget->GetNativeWindow();
1026 drag_drop_controller_->StartDragAndDrop( 1032 drag_drop_controller_->StartDragAndDrop(
1027 data, window->GetRootWindow(), window, gfx::Point(5, 5), 1033 data, window->GetRootWindow(), window, gfx::Point(5, 5),
1028 ui::DragDropTypes::DRAG_MOVE, ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 1034 ui::DragDropTypes::DRAG_MOVE, ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
1029 1035
1030 // Start dragging. 1036 // Start dragging.
1031 ui::MouseEvent e1(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), 1037 ui::MouseEvent e1(
1032 gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, 1038 ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), gfx::Point(200, 0),
1033 ui::EF_NONE); 1039 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
1040 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
1034 drag_drop_controller_->DragUpdate(window, e1); 1041 drag_drop_controller_->DragUpdate(window, e1);
1035 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 1042 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
1036 EXPECT_TRUE(drag_drop_controller_->IsDragDropInProgress()); 1043 EXPECT_TRUE(drag_drop_controller_->IsDragDropInProgress());
1037 1044
1038 // Drag onto the secondary display. 1045 // Drag onto the secondary display.
1039 ui::MouseEvent e2(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), 1046 ui::MouseEvent e2(
1040 gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, 1047 ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), gfx::Point(600, 0),
1041 ui::EF_NONE); 1048 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE,
1049 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
1042 drag_drop_controller_->DragUpdate(window, e2); 1050 drag_drop_controller_->DragUpdate(window, e2);
1043 EXPECT_TRUE(drag_drop_controller_->IsDragDropInProgress()); 1051 EXPECT_TRUE(drag_drop_controller_->IsDragDropInProgress());
1044 1052
1045 // Disconnect the secondary display. 1053 // Disconnect the secondary display.
1046 UpdateDisplay("800x600"); 1054 UpdateDisplay("800x600");
1047 1055
1048 // The drag is canceled. 1056 // The drag is canceled.
1049 EXPECT_TRUE(drag_drop_controller_->drag_canceled_); 1057 EXPECT_TRUE(drag_drop_controller_->drag_canceled_);
1050 EXPECT_FALSE(drag_drop_controller_->IsDragDropInProgress()); 1058 EXPECT_FALSE(drag_drop_controller_->IsDragDropInProgress());
1051 } 1059 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 drag_drop_controller_->drag_string_); 1108 drag_drop_controller_->drag_string_);
1101 EXPECT_EQ(1, drag_view->num_drag_enters_); 1109 EXPECT_EQ(1, drag_view->num_drag_enters_);
1102 EXPECT_EQ(2, drag_view->num_drag_updates_); 1110 EXPECT_EQ(2, drag_view->num_drag_updates_);
1103 EXPECT_EQ(1, drag_view->num_drops_); 1111 EXPECT_EQ(1, drag_view->num_drops_);
1104 EXPECT_EQ(0, drag_view->num_drag_exits_); 1112 EXPECT_EQ(0, drag_view->num_drag_exits_);
1105 EXPECT_TRUE(drag_view->drag_done_received_); 1113 EXPECT_TRUE(drag_view->drag_done_received_);
1106 } 1114 }
1107 1115
1108 } // namespace test 1116 } // namespace test
1109 } // namespace ash 1117 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698