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