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

Side by Side Diff: services/ui/ws/drag_controller_unittest.cc

Issue 2833163002: Change ui cursor identifiers to an enum class. (Closed)
Patch Set: OK, it can't be explicit for mac. 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
« no previous file with comments | « services/ui/ws/drag_controller.cc ('k') | services/ui/ws/event_dispatcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 }; 275 };
276 276
277 DragTestWindow::~DragTestWindow() { 277 DragTestWindow::~DragTestWindow() {
278 parent_->OnTestWindowDestroyed(this); 278 parent_->OnTestWindowDestroyed(this);
279 } 279 }
280 280
281 TEST_F(DragControllerTest, SimpleDragDrop) { 281 TEST_F(DragControllerTest, SimpleDragDrop) {
282 std::unique_ptr<DragTestWindow> window = BuildWindow(); 282 std::unique_ptr<DragTestWindow> window = BuildWindow();
283 StartDragOperation(window.get(), ui::mojom::kDropEffectMove); 283 StartDragOperation(window.get(), ui::mojom::kDropEffectMove);
284 284
285 EXPECT_EQ(ui::mojom::CursorType::NO_DROP, cursor()); 285 EXPECT_EQ(ui::mojom::CursorType::kNoDrop, cursor());
286 286
287 DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(1, 1)); 287 DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(1, 1));
288 EXPECT_EQ(QueuedType::ENTER, window->queue_response_type()); 288 EXPECT_EQ(QueuedType::ENTER, window->queue_response_type());
289 window->Respond(true); 289 window->Respond(true);
290 290
291 // (Even though we're doing a move, the cursor name is COPY.) 291 // (Even though we're doing a move, the cursor name is COPY.)
292 EXPECT_EQ(ui::mojom::CursorType::COPY, cursor()); 292 EXPECT_EQ(ui::mojom::CursorType::kCopy, cursor());
293 293
294 DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(2, 2)); 294 DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(2, 2));
295 EXPECT_EQ(QueuedType::OVER, window->queue_response_type()); 295 EXPECT_EQ(QueuedType::OVER, window->queue_response_type());
296 window->Respond(true); 296 window->Respond(true);
297 297
298 DispatchDrag(window.get(), true, 0, gfx::Point(2, 2)); 298 DispatchDrag(window.get(), true, 0, gfx::Point(2, 2));
299 EXPECT_EQ(QueuedType::DROP, window->queue_response_type()); 299 EXPECT_EQ(QueuedType::DROP, window->queue_response_type());
300 window->Respond(true); 300 window->Respond(true);
301 301
302 EXPECT_EQ(ui::mojom::kDropEffectMove, 302 EXPECT_EQ(ui::mojom::kDropEffectMove,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 EXPECT_EQ(nullptr, api.GetCurrentTarget()); 531 EXPECT_EQ(nullptr, api.GetCurrentTarget());
532 532
533 // But a target window closing out from under us doesn't fail the drag. 533 // But a target window closing out from under us doesn't fail the drag.
534 EXPECT_FALSE(drag_completed_value().has_value()); 534 EXPECT_FALSE(drag_completed_value().has_value());
535 } 535 }
536 536
537 TEST_F(DragControllerTest, TargetWindowClosedResetsCursor) { 537 TEST_F(DragControllerTest, TargetWindowClosedResetsCursor) {
538 std::unique_ptr<DragTestWindow> window1 = BuildWindow(); 538 std::unique_ptr<DragTestWindow> window1 = BuildWindow();
539 std::unique_ptr<DragTestWindow> window2 = BuildWindow(); 539 std::unique_ptr<DragTestWindow> window2 = BuildWindow();
540 StartDragOperation(window1.get(), ui::mojom::kDropEffectMove); 540 StartDragOperation(window1.get(), ui::mojom::kDropEffectMove);
541 EXPECT_EQ(ui::mojom::CursorType::NO_DROP, cursor()); 541 EXPECT_EQ(ui::mojom::CursorType::kNoDrop, cursor());
542 542
543 // Send some events to |window|. 543 // Send some events to |window|.
544 DispatchDrag(window2.get(), false, ui::EF_LEFT_MOUSE_BUTTON, 544 DispatchDrag(window2.get(), false, ui::EF_LEFT_MOUSE_BUTTON,
545 gfx::Point(1, 1)); 545 gfx::Point(1, 1));
546 EXPECT_EQ(QueuedType::ENTER, window2->queue_response_type()); 546 EXPECT_EQ(QueuedType::ENTER, window2->queue_response_type());
547 window2->Respond(true); 547 window2->Respond(true);
548 DispatchDrag(window2.get(), false, ui::EF_LEFT_MOUSE_BUTTON, 548 DispatchDrag(window2.get(), false, ui::EF_LEFT_MOUSE_BUTTON,
549 gfx::Point(1, 1)); 549 gfx::Point(1, 1));
550 window2->Respond(true); 550 window2->Respond(true);
551 EXPECT_EQ(ui::mojom::CursorType::COPY, cursor()); 551 EXPECT_EQ(ui::mojom::CursorType::kCopy, cursor());
552 552
553 // Force the destruction of |window.window|. 553 // Force the destruction of |window.window|.
554 window2.reset(); 554 window2.reset();
555 555
556 // The cursor no loner indicates that it can drop on |window2|. 556 // The cursor no loner indicates that it can drop on |window2|.
557 EXPECT_EQ(ui::mojom::CursorType::NO_DROP, cursor()); 557 EXPECT_EQ(ui::mojom::CursorType::kNoDrop, cursor());
558 } 558 }
559 559
560 TEST_F(DragControllerTest, SourceWindowClosedWhileDrag) { 560 TEST_F(DragControllerTest, SourceWindowClosedWhileDrag) {
561 std::unique_ptr<DragTestWindow> window1 = BuildWindow(); 561 std::unique_ptr<DragTestWindow> window1 = BuildWindow();
562 std::unique_ptr<DragTestWindow> window2 = BuildWindow(); 562 std::unique_ptr<DragTestWindow> window2 = BuildWindow();
563 StartDragOperation(window1.get(), ui::mojom::kDropEffectMove); 563 StartDragOperation(window1.get(), ui::mojom::kDropEffectMove);
564 564
565 test::DragControllerTestApi api(drag_operation()); 565 test::DragControllerTestApi api(drag_operation());
566 566
567 // Send some events to |windoww|. 567 // Send some events to |windoww|.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
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();
641 StartDragOperation(window.get(), ui::mojom::kDropEffectMove); 641 StartDragOperation(window.get(), ui::mojom::kDropEffectMove);
642 642
643 EXPECT_EQ(ui::mojom::CursorType::NO_DROP, cursor()); 643 EXPECT_EQ(ui::mojom::CursorType::kNoDrop, cursor());
644 644
645 DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(1, 1)); 645 DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(1, 1));
646 EXPECT_EQ(QueuedType::ENTER, window->queue_response_type()); 646 EXPECT_EQ(QueuedType::ENTER, window->queue_response_type());
647 window->Respond(true); 647 window->Respond(true);
648 648
649 EXPECT_EQ(ui::mojom::CursorType::COPY, cursor()); 649 EXPECT_EQ(ui::mojom::CursorType::kCopy, cursor());
650 650
651 DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(2, 2)); 651 DispatchDrag(window.get(), false, ui::EF_LEFT_MOUSE_BUTTON, gfx::Point(2, 2));
652 EXPECT_EQ(QueuedType::OVER, window->queue_response_type()); 652 EXPECT_EQ(QueuedType::OVER, window->queue_response_type());
653 653
654 // At this point, we respond with no available drag actions at this pixel. 654 // At this point, we respond with no available drag actions at this pixel.
655 window->Respond(false); 655 window->Respond(false);
656 EXPECT_EQ(ui::mojom::CursorType::NO_DROP, cursor()); 656 EXPECT_EQ(ui::mojom::CursorType::kNoDrop, cursor());
657 } 657 }
658 658
659 TEST_F(DragControllerTest, ResopnseFromOtherWindowDoesntChangeCursor) { 659 TEST_F(DragControllerTest, ResopnseFromOtherWindowDoesntChangeCursor) {
660 std::unique_ptr<DragTestWindow> window1 = BuildWindow(); 660 std::unique_ptr<DragTestWindow> window1 = BuildWindow();
661 std::unique_ptr<DragTestWindow> window2 = BuildWindow(); 661 std::unique_ptr<DragTestWindow> window2 = BuildWindow();
662 StartDragOperation(window1.get(), ui::mojom::kDropEffectMove); 662 StartDragOperation(window1.get(), ui::mojom::kDropEffectMove);
663 663
664 // Send some events to |window2|. 664 // Send some events to |window2|.
665 DispatchDrag(window2.get(), false, ui::EF_LEFT_MOUSE_BUTTON, 665 DispatchDrag(window2.get(), false, ui::EF_LEFT_MOUSE_BUTTON,
666 gfx::Point(1, 1)); 666 gfx::Point(1, 1));
667 EXPECT_EQ(QueuedType::ENTER, window2->queue_response_type()); 667 EXPECT_EQ(QueuedType::ENTER, window2->queue_response_type());
668 DispatchDrag(window2.get(), false, ui::EF_LEFT_MOUSE_BUTTON, 668 DispatchDrag(window2.get(), false, ui::EF_LEFT_MOUSE_BUTTON,
669 gfx::Point(1, 1)); 669 gfx::Point(1, 1));
670 670
671 EXPECT_EQ(ui::mojom::CursorType::NO_DROP, cursor()); 671 EXPECT_EQ(ui::mojom::CursorType::kNoDrop, cursor());
672 672
673 // Now enter |window1|, and respond. 673 // Now enter |window1|, and respond.
674 DispatchDrag(window1.get(), false, ui::EF_LEFT_MOUSE_BUTTON, 674 DispatchDrag(window1.get(), false, ui::EF_LEFT_MOUSE_BUTTON,
675 gfx::Point(5, 5)); 675 gfx::Point(5, 5));
676 EXPECT_EQ(QueuedType::ENTER, window1->queue_response_type()); 676 EXPECT_EQ(QueuedType::ENTER, window1->queue_response_type());
677 window1->Respond(true); 677 window1->Respond(true);
678 678
679 EXPECT_EQ(ui::mojom::CursorType::COPY, cursor()); 679 EXPECT_EQ(ui::mojom::CursorType::kCopy, cursor());
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::kCopy, cursor());
686 } 686 }
687 687
688 } // namespace ws 688 } // namespace ws
689 } // namespace ui 689 } // namespace ui
OLDNEW
« no previous file with comments | « services/ui/ws/drag_controller.cc ('k') | services/ui/ws/event_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698