| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "services/ui/ws/drag_controller.h" | 5 #include "services/ui/ws/drag_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 connection_by_window_[p->window()] = p.get(); | 149 connection_by_window_[p->window()] = p.get(); |
| 150 return p; | 150 return p; |
| 151 } | 151 } |
| 152 | 152 |
| 153 void StartDragOperation( | 153 void StartDragOperation( |
| 154 DragTestWindow* window, | 154 DragTestWindow* window, |
| 155 uint32_t drag_operations) { | 155 uint32_t drag_operations) { |
| 156 window->PerformOnDragDropStart( | 156 window->PerformOnDragDropStart( |
| 157 std::unordered_map<std::string, std::vector<uint8_t>>()); | 157 std::unordered_map<std::string, std::vector<uint8_t>>()); |
| 158 drag_operation_ = base::MakeUnique<DragController>( | 158 drag_operation_ = base::MakeUnique<DragController>( |
| 159 this, this, window->window(), window, MouseEvent::kMousePointerId, | 159 this, this, window->window(), window, |
| 160 MouseEvent::kDefaultMousePointerId, |
| 160 std::unordered_map<std::string, std::vector<uint8_t>>(), | 161 std::unordered_map<std::string, std::vector<uint8_t>>(), |
| 161 drag_operations); | 162 drag_operations); |
| 162 | 163 |
| 163 // It would be nice if we could just let the observer method fire, but it | 164 // It would be nice if we could just let the observer method fire, but it |
| 164 // fires during the constructor when we haven't assigned the unique_ptr | 165 // fires during the constructor when we haven't assigned the unique_ptr |
| 165 // yet. | 166 // yet. |
| 166 cursor_ = drag_operation_->current_cursor().cursor_type(); | 167 cursor_ = drag_operation_->current_cursor().cursor_type(); |
| 167 } | 168 } |
| 168 | 169 |
| 169 void DispatchDrag(DragTestWindow* window, | 170 void DispatchDrag(DragTestWindow* window, |
| (...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 EXPECT_EQ(QueuedType::ENTER, window->queue_response_type()); | 622 EXPECT_EQ(QueuedType::ENTER, window->queue_response_type()); |
| 622 window->Respond(true); | 623 window->Respond(true); |
| 623 | 624 |
| 624 drag_operation()->Cancel(); | 625 drag_operation()->Cancel(); |
| 625 | 626 |
| 626 EXPECT_FALSE(drag_completed_value().value_or(true)); | 627 EXPECT_FALSE(drag_completed_value().value_or(true)); |
| 627 } | 628 } |
| 628 | 629 |
| 629 TEST_F(DragControllerTest, IgnoreEventsFromOtherPointers) { | 630 TEST_F(DragControllerTest, IgnoreEventsFromOtherPointers) { |
| 630 std::unique_ptr<DragTestWindow> window = BuildWindow(); | 631 std::unique_ptr<DragTestWindow> window = BuildWindow(); |
| 631 // This starts the operation with MouseEvent::kMousePointerId. | 632 // This starts the operation with MouseEvent::kDefaultMousePointerId. |
| 632 StartDragOperation(window.get(), ui::mojom::kDropEffectMove); | 633 StartDragOperation(window.get(), ui::mojom::kDropEffectMove); |
| 633 | 634 |
| 634 // Ignore events from pointer 5. | 635 // Ignore events from pointer 5. |
| 635 DispatchDragWithPointer(window.get(), 5, false, ui::EF_LEFT_MOUSE_BUTTON, | 636 DispatchDragWithPointer(window.get(), 5, false, ui::EF_LEFT_MOUSE_BUTTON, |
| 636 gfx::Point(1, 1)); | 637 gfx::Point(1, 1)); |
| 637 ASSERT_EQ(0u, window->queue_size()); | 638 ASSERT_EQ(0u, window->queue_size()); |
| 638 } | 639 } |
| 639 | 640 |
| 640 TEST_F(DragControllerTest, RejectingWindowHasProperCursor) { | 641 TEST_F(DragControllerTest, RejectingWindowHasProperCursor) { |
| 641 std::unique_ptr<DragTestWindow> window = BuildWindow(); | 642 std::unique_ptr<DragTestWindow> window = BuildWindow(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 | 682 |
| 682 // Window 2 responding negatively to its queued messages shouldn't change the | 683 // Window 2 responding negatively to its queued messages shouldn't change the |
| 683 // cursor. | 684 // cursor. |
| 684 window2->Respond(false); | 685 window2->Respond(false); |
| 685 | 686 |
| 686 EXPECT_EQ(ui::CursorType::kCopy, cursor_type()); | 687 EXPECT_EQ(ui::CursorType::kCopy, cursor_type()); |
| 687 } | 688 } |
| 688 | 689 |
| 689 } // namespace ws | 690 } // namespace ws |
| 690 } // namespace ui | 691 } // namespace ui |
| OLD | NEW |