Chromium Code Reviews| 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 aura::Window::Windows root_windows = | |
| 1064 Shell::GetInstance()->GetAllRootWindows(); | |
| 1065 for (aura::Window::Windows::iterator iter = root_windows.begin(); | |
|
msw
2016/08/05 19:32:58
nit: for (aura::Window* window : Shell::GetInstanc
James Cook
2016/08/05 20:10:11
Done.
| |
| 1066 iter != root_windows.end(); ++iter) { | |
| 1067 aura::client::SetDragDropClient(*iter, drag_drop_controller_.get()); | |
| 1068 } | |
| 1069 | |
| 1070 ui::OSExchangeData data; | |
| 1071 data.SetString(base::UTF8ToUTF16("I am being dragged")); | |
| 1072 std::unique_ptr<views::Widget> widget(CreateNewWidget()); | |
| 1073 aura::Window* window = widget->GetNativeWindow(); | |
| 1074 drag_drop_controller_->StartDragAndDrop( | |
| 1075 data, window->GetRootWindow(), window, gfx::Point(5, 5), | |
| 1076 ui::DragDropTypes::DRAG_MOVE, ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); | |
| 1077 | |
| 1078 // Start dragging. | |
| 1079 ui::MouseEvent e1(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), | |
| 1080 gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, | |
| 1081 ui::EF_NONE); | |
| 1082 drag_drop_controller_->DragUpdate(window, e1); | |
| 1083 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); | |
| 1084 EXPECT_TRUE(drag_drop_controller_->IsDragDropInProgress()); | |
| 1085 | |
| 1086 // Drag onto the secondary display. | |
| 1087 ui::MouseEvent e2(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), | |
| 1088 gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, | |
| 1089 ui::EF_NONE); | |
| 1090 drag_drop_controller_->DragUpdate(window, e2); | |
| 1091 EXPECT_TRUE(drag_drop_controller_->IsDragDropInProgress()); | |
| 1092 | |
| 1093 // Disconnect the secondary display. | |
| 1094 UpdateDisplay("800x600"); | |
| 1095 | |
| 1096 // The drag is canceled. | |
| 1097 EXPECT_TRUE(drag_drop_controller_->drag_canceled_); | |
| 1098 EXPECT_FALSE(drag_drop_controller_->IsDragDropInProgress()); | |
| 1099 } | |
| 1100 | |
| 1057 TEST_F(DragDropControllerTest, TouchDragDropCompletesOnFling) { | 1101 TEST_F(DragDropControllerTest, TouchDragDropCompletesOnFling) { |
| 1058 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 1102 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 1059 switches::kEnableTouchDragDrop); | 1103 switches::kEnableTouchDragDrop); |
| 1060 ui::GestureConfiguration::GetInstance() | 1104 ui::GestureConfiguration::GetInstance() |
| 1061 ->set_max_touch_move_in_pixels_for_click(1); | 1105 ->set_max_touch_move_in_pixels_for_click(1); |
| 1062 std::unique_ptr<views::Widget> widget(CreateNewWidget()); | 1106 std::unique_ptr<views::Widget> widget(CreateNewWidget()); |
| 1063 DragTestView* drag_view = new DragTestView; | 1107 DragTestView* drag_view = new DragTestView; |
| 1064 AddViewToWidgetAndResize(widget.get(), drag_view); | 1108 AddViewToWidgetAndResize(widget.get(), drag_view); |
| 1065 ui::OSExchangeData data; | 1109 ui::OSExchangeData data; |
| 1066 data.SetString(base::UTF8ToUTF16("I am being dragged")); | 1110 data.SetString(base::UTF8ToUTF16("I am being dragged")); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1096 drag_drop_controller_->drag_string_); | 1140 drag_drop_controller_->drag_string_); |
| 1097 EXPECT_EQ(1, drag_view->num_drag_enters_); | 1141 EXPECT_EQ(1, drag_view->num_drag_enters_); |
| 1098 EXPECT_EQ(2, drag_view->num_drag_updates_); | 1142 EXPECT_EQ(2, drag_view->num_drag_updates_); |
| 1099 EXPECT_EQ(1, drag_view->num_drops_); | 1143 EXPECT_EQ(1, drag_view->num_drops_); |
| 1100 EXPECT_EQ(0, drag_view->num_drag_exits_); | 1144 EXPECT_EQ(0, drag_view->num_drag_exits_); |
| 1101 EXPECT_TRUE(drag_view->drag_done_received_); | 1145 EXPECT_TRUE(drag_view->drag_done_received_); |
| 1102 } | 1146 } |
| 1103 | 1147 |
| 1104 } // namespace test | 1148 } // namespace test |
| 1105 } // namespace ash | 1149 } // namespace ash |
| OLD | NEW |