| OLD | NEW |
| 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/drag_drop/drag_drop_tracker.h" | 8 #include "ash/drag_drop/drag_drop_tracker.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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/location.h" | 12 #include "base/location.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "ui/aura/client/capture_client.h" | 14 #include "ui/aura/client/capture_client.h" |
| 15 #include "ui/aura/window_event_dispatcher.h" | 15 #include "ui/aura/window_event_dispatcher.h" |
| 16 #include "ui/aura/window_tree_host.h" | 16 #include "ui/aura/window_tree_host.h" |
| 17 #include "ui/base/clipboard/clipboard.h" | 17 #include "ui/base/clipboard/clipboard.h" |
| 18 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 18 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
| (...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 CompleteCancelAnimation(); | 1047 CompleteCancelAnimation(); |
| 1048 | 1048 |
| 1049 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString()); | 1049 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString()); |
| 1050 } | 1050 } |
| 1051 for (aura::Window::Windows::iterator iter = root_windows.begin(); | 1051 for (aura::Window::Windows::iterator iter = root_windows.begin(); |
| 1052 iter != root_windows.end(); ++iter) { | 1052 iter != root_windows.end(); ++iter) { |
| 1053 aura::client::SetDragDropClient(*iter, NULL); | 1053 aura::client::SetDragDropClient(*iter, NULL); |
| 1054 } | 1054 } |
| 1055 } | 1055 } |
| 1056 | 1056 |
| 1057 // Verifies that a drag is aborted if a display is disconnected during the drag. |
| 1058 TEST_F(DragDropControllerTest, DragCancelOnDisplayDisconnect) { |
| 1059 if (!SupportsMultipleDisplays()) |
| 1060 return; |
| 1061 |
| 1062 UpdateDisplay("400x400,400x400"); |
| 1063 for (aura::Window* root : Shell::GetInstance()->GetAllRootWindows()) { |
| 1064 aura::client::SetDragDropClient(root, drag_drop_controller_.get()); |
| 1065 } |
| 1066 |
| 1067 ui::OSExchangeData data; |
| 1068 data.SetString(base::UTF8ToUTF16("I am being dragged")); |
| 1069 std::unique_ptr<views::Widget> widget(CreateNewWidget()); |
| 1070 aura::Window* window = widget->GetNativeWindow(); |
| 1071 drag_drop_controller_->StartDragAndDrop( |
| 1072 data, window->GetRootWindow(), window, gfx::Point(5, 5), |
| 1073 ui::DragDropTypes::DRAG_MOVE, ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); |
| 1074 |
| 1075 // Start dragging. |
| 1076 ui::MouseEvent e1(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), |
| 1077 gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, |
| 1078 ui::EF_NONE); |
| 1079 drag_drop_controller_->DragUpdate(window, e1); |
| 1080 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); |
| 1081 EXPECT_TRUE(drag_drop_controller_->IsDragDropInProgress()); |
| 1082 |
| 1083 // Drag onto the secondary display. |
| 1084 ui::MouseEvent e2(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), |
| 1085 gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, |
| 1086 ui::EF_NONE); |
| 1087 drag_drop_controller_->DragUpdate(window, e2); |
| 1088 EXPECT_TRUE(drag_drop_controller_->IsDragDropInProgress()); |
| 1089 |
| 1090 // Disconnect the secondary display. |
| 1091 UpdateDisplay("800x600"); |
| 1092 |
| 1093 // The drag is canceled. |
| 1094 EXPECT_TRUE(drag_drop_controller_->drag_canceled_); |
| 1095 EXPECT_FALSE(drag_drop_controller_->IsDragDropInProgress()); |
| 1096 } |
| 1097 |
| 1057 TEST_F(DragDropControllerTest, TouchDragDropCompletesOnFling) { | 1098 TEST_F(DragDropControllerTest, TouchDragDropCompletesOnFling) { |
| 1058 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1099 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1059 switches::kEnableTouchDragDrop); | 1100 switches::kEnableTouchDragDrop); |
| 1060 ui::GestureConfiguration::GetInstance() | 1101 ui::GestureConfiguration::GetInstance() |
| 1061 ->set_max_touch_move_in_pixels_for_click(1); | 1102 ->set_max_touch_move_in_pixels_for_click(1); |
| 1062 std::unique_ptr<views::Widget> widget(CreateNewWidget()); | 1103 std::unique_ptr<views::Widget> widget(CreateNewWidget()); |
| 1063 DragTestView* drag_view = new DragTestView; | 1104 DragTestView* drag_view = new DragTestView; |
| 1064 AddViewToWidgetAndResize(widget.get(), drag_view); | 1105 AddViewToWidgetAndResize(widget.get(), drag_view); |
| 1065 ui::OSExchangeData data; | 1106 ui::OSExchangeData data; |
| 1066 data.SetString(base::UTF8ToUTF16("I am being dragged")); | 1107 data.SetString(base::UTF8ToUTF16("I am being dragged")); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1096 drag_drop_controller_->drag_string_); | 1137 drag_drop_controller_->drag_string_); |
| 1097 EXPECT_EQ(1, drag_view->num_drag_enters_); | 1138 EXPECT_EQ(1, drag_view->num_drag_enters_); |
| 1098 EXPECT_EQ(2, drag_view->num_drag_updates_); | 1139 EXPECT_EQ(2, drag_view->num_drag_updates_); |
| 1099 EXPECT_EQ(1, drag_view->num_drops_); | 1140 EXPECT_EQ(1, drag_view->num_drops_); |
| 1100 EXPECT_EQ(0, drag_view->num_drag_exits_); | 1141 EXPECT_EQ(0, drag_view->num_drag_exits_); |
| 1101 EXPECT_TRUE(drag_view->drag_done_received_); | 1142 EXPECT_TRUE(drag_view->drag_done_received_); |
| 1102 } | 1143 } |
| 1103 | 1144 |
| 1104 } // namespace test | 1145 } // namespace test |
| 1105 } // namespace ash | 1146 } // namespace ash |
| OLD | NEW |