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

Side by Side Diff: ash/drag_drop/drag_drop_controller_unittest.cc

Issue 406413004: Cleanups for aura/test/event_generator.h (resolve TODOs) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase at r285842 Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « ash/display/root_window_transformers_unittest.cc ('k') | ash/extended_desktop_unittest.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 (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/drag_drop/drag_drop_tracker.h" 7 #include "ash/drag_drop/drag_drop_tracker.h"
8 #include "ash/drag_drop/drag_image_view.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/test/event_generator.h"
16 #include "ui/aura/window_event_dispatcher.h" 15 #include "ui/aura/window_event_dispatcher.h"
17 #include "ui/aura/window_tree_host.h" 16 #include "ui/aura/window_tree_host.h"
18 #include "ui/base/clipboard/clipboard.h" 17 #include "ui/base/clipboard/clipboard.h"
19 #include "ui/base/clipboard/scoped_clipboard_writer.h" 18 #include "ui/base/clipboard/scoped_clipboard_writer.h"
20 #include "ui/base/dragdrop/drag_drop_types.h" 19 #include "ui/base/dragdrop/drag_drop_types.h"
21 #include "ui/base/dragdrop/drag_utils.h" 20 #include "ui/base/dragdrop/drag_utils.h"
22 #include "ui/base/dragdrop/os_exchange_data.h" 21 #include "ui/base/dragdrop/os_exchange_data.h"
23 #include "ui/base/ui_base_switches.h" 22 #include "ui/base/ui_base_switches.h"
24 #include "ui/events/event.h" 23 #include "ui/events/event.h"
25 #include "ui/events/event_utils.h" 24 #include "ui/events/event_utils.h"
26 #include "ui/events/gestures/gesture_types.h" 25 #include "ui/events/gestures/gesture_types.h"
26 #include "ui/events/test/event_generator.h"
27 #include "ui/events/test/events_test_utils.h" 27 #include "ui/events/test/events_test_utils.h"
28 #include "ui/gfx/animation/linear_animation.h" 28 #include "ui/gfx/animation/linear_animation.h"
29 #include "ui/gfx/image/image_skia_rep.h" 29 #include "ui/gfx/image/image_skia_rep.h"
30 #include "ui/views/view.h" 30 #include "ui/views/view.h"
31 #include "ui/views/views_delegate.h" 31 #include "ui/views/views_delegate.h"
32 #include "ui/views/widget/native_widget_aura.h" 32 #include "ui/views/widget/native_widget_aura.h"
33 #include "ui/views/widget/native_widget_delegate.h" 33 #include "ui/views/widget/native_widget_delegate.h"
34 #include "ui/views/widget/widget.h" 34 #include "ui/views/widget/widget.h"
35 35
36 namespace ash { 36 namespace ash {
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 #define MAYBE_DragDropInSingleViewTest DISABLED_DragDropInSingleViewTest 352 #define MAYBE_DragDropInSingleViewTest DISABLED_DragDropInSingleViewTest
353 #else 353 #else
354 #define MAYBE_DragDropInSingleViewTest DragDropInSingleViewTest 354 #define MAYBE_DragDropInSingleViewTest DragDropInSingleViewTest
355 #endif 355 #endif
356 TEST_F(DragDropControllerTest, MAYBE_DragDropInSingleViewTest) { 356 TEST_F(DragDropControllerTest, MAYBE_DragDropInSingleViewTest) {
357 scoped_ptr<views::Widget> widget(CreateNewWidget()); 357 scoped_ptr<views::Widget> widget(CreateNewWidget());
358 DragTestView* drag_view = new DragTestView; 358 DragTestView* drag_view = new DragTestView;
359 AddViewToWidgetAndResize(widget.get(), drag_view); 359 AddViewToWidgetAndResize(widget.get(), drag_view);
360 ui::OSExchangeData data; 360 ui::OSExchangeData data;
361 data.SetString(base::UTF8ToUTF16("I am being dragged")); 361 data.SetString(base::UTF8ToUTF16("I am being dragged"));
362 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 362 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
363 widget->GetNativeView()); 363 widget->GetNativeView());
364 generator.PressLeftButton(); 364 generator.PressLeftButton();
365 365
366 int num_drags = 17; 366 int num_drags = 17;
367 SetCheckIfCaptureLost(widget.get(), true); 367 SetCheckIfCaptureLost(widget.get(), true);
368 for (int i = 0; i < num_drags; ++i) { 368 for (int i = 0; i < num_drags; ++i) {
369 // Because we are not doing a blocking drag and drop, the original 369 // Because we are not doing a blocking drag and drop, the original
370 // OSDragExchangeData object is lost as soon as we return from the drag 370 // OSDragExchangeData object is lost as soon as we return from the drag
371 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 371 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
372 // drag_data_ to a fake drag data object that we created. 372 // drag_data_ to a fake drag data object that we created.
373 if (i > 0) 373 if (i > 0)
(...skipping 24 matching lines...) Expand all
398 EXPECT_EQ(0, drag_view->num_drag_exits_); 398 EXPECT_EQ(0, drag_view->num_drag_exits_);
399 EXPECT_TRUE(drag_view->drag_done_received_); 399 EXPECT_TRUE(drag_view->drag_done_received_);
400 } 400 }
401 401
402 TEST_F(DragDropControllerTest, DragDropWithZeroDragUpdates) { 402 TEST_F(DragDropControllerTest, DragDropWithZeroDragUpdates) {
403 scoped_ptr<views::Widget> widget(CreateNewWidget()); 403 scoped_ptr<views::Widget> widget(CreateNewWidget());
404 DragTestView* drag_view = new DragTestView; 404 DragTestView* drag_view = new DragTestView;
405 AddViewToWidgetAndResize(widget.get(), drag_view); 405 AddViewToWidgetAndResize(widget.get(), drag_view);
406 ui::OSExchangeData data; 406 ui::OSExchangeData data;
407 data.SetString(base::UTF8ToUTF16("I am being dragged")); 407 data.SetString(base::UTF8ToUTF16("I am being dragged"));
408 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 408 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
409 widget->GetNativeView()); 409 widget->GetNativeView());
410 generator.PressLeftButton(); 410 generator.PressLeftButton();
411 411
412 int num_drags = drag_view->VerticalDragThreshold() + 1; 412 int num_drags = drag_view->VerticalDragThreshold() + 1;
413 for (int i = 0; i < num_drags; ++i) { 413 for (int i = 0; i < num_drags; ++i) {
414 // Because we are not doing a blocking drag and drop, the original 414 // Because we are not doing a blocking drag and drop, the original
415 // OSDragExchangeData object is lost as soon as we return from the drag 415 // OSDragExchangeData object is lost as soon as we return from the drag
416 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 416 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
417 // drag_data_ to a fake drag data object that we created. 417 // drag_data_ to a fake drag data object that we created.
418 if (i > 0) 418 if (i > 0)
419 UpdateDragData(&data); 419 UpdateDragData(&data);
(...skipping 26 matching lines...) Expand all
446 TEST_F(DragDropControllerTest, MAYBE_DragDropInMultipleViewsSingleWidgetTest) { 446 TEST_F(DragDropControllerTest, MAYBE_DragDropInMultipleViewsSingleWidgetTest) {
447 scoped_ptr<views::Widget> widget(CreateNewWidget()); 447 scoped_ptr<views::Widget> widget(CreateNewWidget());
448 DragTestView* drag_view1 = new DragTestView; 448 DragTestView* drag_view1 = new DragTestView;
449 AddViewToWidgetAndResize(widget.get(), drag_view1); 449 AddViewToWidgetAndResize(widget.get(), drag_view1);
450 DragTestView* drag_view2 = new DragTestView; 450 DragTestView* drag_view2 = new DragTestView;
451 AddViewToWidgetAndResize(widget.get(), drag_view2); 451 AddViewToWidgetAndResize(widget.get(), drag_view2);
452 452
453 ui::OSExchangeData data; 453 ui::OSExchangeData data;
454 data.SetString(base::UTF8ToUTF16("I am being dragged")); 454 data.SetString(base::UTF8ToUTF16("I am being dragged"));
455 455
456 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 456 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
457 generator.MoveMouseRelativeTo(widget->GetNativeView(), 457 generator.MoveMouseRelativeTo(widget->GetNativeView(),
458 drag_view1->bounds().CenterPoint()); 458 drag_view1->bounds().CenterPoint());
459 generator.PressLeftButton(); 459 generator.PressLeftButton();
460 460
461 int num_drags = drag_view1->width(); 461 int num_drags = drag_view1->width();
462 for (int i = 0; i < num_drags; ++i) { 462 for (int i = 0; i < num_drags; ++i) {
463 // Because we are not doing a blocking drag and drop, the original 463 // Because we are not doing a blocking drag and drop, the original
464 // OSDragExchangeData object is lost as soon as we return from the drag 464 // OSDragExchangeData object is lost as soon as we return from the drag
465 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 465 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
466 // drag_data_ to a fake drag data object that we created. 466 // drag_data_ to a fake drag data object that we created.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 DragTestView* drag_view2 = new DragTestView; 512 DragTestView* drag_view2 = new DragTestView;
513 AddViewToWidgetAndResize(widget2.get(), drag_view2); 513 AddViewToWidgetAndResize(widget2.get(), drag_view2);
514 gfx::Rect widget1_bounds = widget1->GetClientAreaBoundsInScreen(); 514 gfx::Rect widget1_bounds = widget1->GetClientAreaBoundsInScreen();
515 gfx::Rect widget2_bounds = widget2->GetClientAreaBoundsInScreen(); 515 gfx::Rect widget2_bounds = widget2->GetClientAreaBoundsInScreen();
516 widget2->SetBounds(gfx::Rect(widget1_bounds.width(), 0, 516 widget2->SetBounds(gfx::Rect(widget1_bounds.width(), 0,
517 widget2_bounds.width(), widget2_bounds.height())); 517 widget2_bounds.width(), widget2_bounds.height()));
518 518
519 ui::OSExchangeData data; 519 ui::OSExchangeData data;
520 data.SetString(base::UTF8ToUTF16("I am being dragged")); 520 data.SetString(base::UTF8ToUTF16("I am being dragged"));
521 521
522 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 522 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
523 widget1->GetNativeView()); 523 widget1->GetNativeView());
524 generator.PressLeftButton(); 524 generator.PressLeftButton();
525 525
526 int num_drags = drag_view1->width(); 526 int num_drags = drag_view1->width();
527 for (int i = 0; i < num_drags; ++i) { 527 for (int i = 0; i < num_drags; ++i) {
528 // Because we are not doing a blocking drag and drop, the original 528 // Because we are not doing a blocking drag and drop, the original
529 // OSDragExchangeData object is lost as soon as we return from the drag 529 // OSDragExchangeData object is lost as soon as we return from the drag
530 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 530 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
531 // drag_data_ to a fake drag data object that we created. 531 // drag_data_ to a fake drag data object that we created.
532 if (i > 0) 532 if (i > 0)
533 UpdateDragData(&data); 533 UpdateDragData(&data);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 #define MAYBE_ViewRemovedWhileInDragDropTest ViewRemovedWhileInDragDropTest 570 #define MAYBE_ViewRemovedWhileInDragDropTest ViewRemovedWhileInDragDropTest
571 #endif 571 #endif
572 TEST_F(DragDropControllerTest, MAYBE_ViewRemovedWhileInDragDropTest) { 572 TEST_F(DragDropControllerTest, MAYBE_ViewRemovedWhileInDragDropTest) {
573 scoped_ptr<views::Widget> widget(CreateNewWidget()); 573 scoped_ptr<views::Widget> widget(CreateNewWidget());
574 scoped_ptr<DragTestView> drag_view(new DragTestView); 574 scoped_ptr<DragTestView> drag_view(new DragTestView);
575 AddViewToWidgetAndResize(widget.get(), drag_view.get()); 575 AddViewToWidgetAndResize(widget.get(), drag_view.get());
576 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); 576 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint();
577 ui::OSExchangeData data; 577 ui::OSExchangeData data;
578 data.SetString(base::UTF8ToUTF16("I am being dragged")); 578 data.SetString(base::UTF8ToUTF16("I am being dragged"));
579 579
580 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 580 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
581 generator.MoveMouseToCenterOf(widget->GetNativeView()); 581 generator.MoveMouseToCenterOf(widget->GetNativeView());
582 generator.PressLeftButton(); 582 generator.PressLeftButton();
583 583
584 int num_drags_1 = 17; 584 int num_drags_1 = 17;
585 for (int i = 0; i < num_drags_1; ++i) { 585 for (int i = 0; i < num_drags_1; ++i) {
586 // Because we are not doing a blocking drag and drop, the original 586 // Because we are not doing a blocking drag and drop, the original
587 // OSDragExchangeData object is lost as soon as we return from the drag 587 // OSDragExchangeData object is lost as soon as we return from the drag
588 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 588 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
589 // drag_data_ to a fake drag data object that we created. 589 // drag_data_ to a fake drag data object that we created.
590 if (i > 0) 590 if (i > 0)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
631 ui::ScopedClipboardWriter scw(cb, ui::CLIPBOARD_TYPE_COPY_PASTE); 631 ui::ScopedClipboardWriter scw(cb, ui::CLIPBOARD_TYPE_COPY_PASTE);
632 scw.WriteText(base::ASCIIToUTF16(clip_str)); 632 scw.WriteText(base::ASCIIToUTF16(clip_str));
633 } 633 }
634 EXPECT_TRUE(cb->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(), 634 EXPECT_TRUE(cb->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(),
635 ui::CLIPBOARD_TYPE_COPY_PASTE)); 635 ui::CLIPBOARD_TYPE_COPY_PASTE));
636 636
637 scoped_ptr<views::Widget> widget(CreateNewWidget()); 637 scoped_ptr<views::Widget> widget(CreateNewWidget());
638 DragTestView* drag_view = new DragTestView; 638 DragTestView* drag_view = new DragTestView;
639 AddViewToWidgetAndResize(widget.get(), drag_view); 639 AddViewToWidgetAndResize(widget.get(), drag_view);
640 640
641 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 641 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
642 widget->GetNativeView()); 642 widget->GetNativeView());
643 ui::OSExchangeData data; 643 ui::OSExchangeData data;
644 std::string data_str("I am being dragged"); 644 std::string data_str("I am being dragged");
645 data.SetString(base::ASCIIToUTF16(data_str)); 645 data.SetString(base::ASCIIToUTF16(data_str));
646 646
647 generator.PressLeftButton(); 647 generator.PressLeftButton();
648 generator.MoveMouseBy(0, drag_view->VerticalDragThreshold() + 1); 648 generator.MoveMouseBy(0, drag_view->VerticalDragThreshold() + 1);
649 649
650 // Execute any scheduled draws to process deferred mouse events. 650 // Execute any scheduled draws to process deferred mouse events.
651 RunAllPendingInMessageLoop(); 651 RunAllPendingInMessageLoop();
652 652
653 // Verify the clipboard contents haven't changed 653 // Verify the clipboard contents haven't changed
654 std::string result; 654 std::string result;
655 EXPECT_TRUE(cb->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(), 655 EXPECT_TRUE(cb->IsFormatAvailable(ui::Clipboard::GetPlainTextFormatType(),
656 ui::CLIPBOARD_TYPE_COPY_PASTE)); 656 ui::CLIPBOARD_TYPE_COPY_PASTE));
657 cb->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result); 657 cb->ReadAsciiText(ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
658 EXPECT_EQ(clip_str, result); 658 EXPECT_EQ(clip_str, result);
659 // Destory the clipboard here because ash doesn't delete it. 659 // Destory the clipboard here because ash doesn't delete it.
660 // crbug.com/158150. 660 // crbug.com/158150.
661 ui::Clipboard::DestroyClipboardForCurrentThread(); 661 ui::Clipboard::DestroyClipboardForCurrentThread();
662 } 662 }
663 663
664 TEST_F(DragDropControllerTest, WindowDestroyedDuringDragDrop) { 664 TEST_F(DragDropControllerTest, WindowDestroyedDuringDragDrop) {
665 scoped_ptr<views::Widget> widget(CreateNewWidget()); 665 scoped_ptr<views::Widget> widget(CreateNewWidget());
666 DragTestView* drag_view = new DragTestView; 666 DragTestView* drag_view = new DragTestView;
667 AddViewToWidgetAndResize(widget.get(), drag_view); 667 AddViewToWidgetAndResize(widget.get(), drag_view);
668 aura::Window* window = widget->GetNativeView(); 668 aura::Window* window = widget->GetNativeView();
669 669
670 ui::OSExchangeData data; 670 ui::OSExchangeData data;
671 data.SetString(base::UTF8ToUTF16("I am being dragged")); 671 data.SetString(base::UTF8ToUTF16("I am being dragged"));
672 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 672 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
673 widget->GetNativeView()); 673 widget->GetNativeView());
674 generator.PressLeftButton(); 674 generator.PressLeftButton();
675 675
676 int num_drags = 17; 676 int num_drags = 17;
677 for (int i = 0; i < num_drags; ++i) { 677 for (int i = 0; i < num_drags; ++i) {
678 // Because we are not doing a blocking drag and drop, the original 678 // Because we are not doing a blocking drag and drop, the original
679 // OSDragExchangeData object is lost as soon as we return from the drag 679 // OSDragExchangeData object is lost as soon as we return from the drag
680 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 680 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
681 // drag_data_ to a fake drag data object that we created. 681 // drag_data_ to a fake drag data object that we created.
682 if (i > 0) 682 if (i > 0)
683 UpdateDragData(&data); 683 UpdateDragData(&data);
(...skipping 22 matching lines...) Expand all
706 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 706 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
707 EXPECT_TRUE(drag_drop_controller_->drop_received_); 707 EXPECT_TRUE(drag_drop_controller_->drop_received_);
708 } 708 }
709 709
710 TEST_F(DragDropControllerTest, SyntheticEventsDuringDragDrop) { 710 TEST_F(DragDropControllerTest, SyntheticEventsDuringDragDrop) {
711 scoped_ptr<views::Widget> widget(CreateNewWidget()); 711 scoped_ptr<views::Widget> widget(CreateNewWidget());
712 DragTestView* drag_view = new DragTestView; 712 DragTestView* drag_view = new DragTestView;
713 AddViewToWidgetAndResize(widget.get(), drag_view); 713 AddViewToWidgetAndResize(widget.get(), drag_view);
714 ui::OSExchangeData data; 714 ui::OSExchangeData data;
715 data.SetString(base::UTF8ToUTF16("I am being dragged")); 715 data.SetString(base::UTF8ToUTF16("I am being dragged"));
716 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 716 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
717 widget->GetNativeView()); 717 widget->GetNativeView());
718 generator.PressLeftButton(); 718 generator.PressLeftButton();
719 719
720 int num_drags = 17; 720 int num_drags = 17;
721 for (int i = 0; i < num_drags; ++i) { 721 for (int i = 0; i < num_drags; ++i) {
722 // Because we are not doing a blocking drag and drop, the original 722 // Because we are not doing a blocking drag and drop, the original
723 // OSDragExchangeData object is lost as soon as we return from the drag 723 // OSDragExchangeData object is lost as soon as we return from the drag
724 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 724 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
725 // drag_data_ to a fake drag data object that we created. 725 // drag_data_ to a fake drag data object that we created.
726 if (i > 0) 726 if (i > 0)
727 UpdateDragData(&data); 727 UpdateDragData(&data);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 #else 762 #else
763 #define MAYBE_PressingEscapeCancelsDragDrop PressingEscapeCancelsDragDrop 763 #define MAYBE_PressingEscapeCancelsDragDrop PressingEscapeCancelsDragDrop
764 #define MAYBE_CaptureLostCancelsDragDrop CaptureLostCancelsDragDrop 764 #define MAYBE_CaptureLostCancelsDragDrop CaptureLostCancelsDragDrop
765 #endif 765 #endif
766 TEST_F(DragDropControllerTest, MAYBE_PressingEscapeCancelsDragDrop) { 766 TEST_F(DragDropControllerTest, MAYBE_PressingEscapeCancelsDragDrop) {
767 scoped_ptr<views::Widget> widget(CreateNewWidget()); 767 scoped_ptr<views::Widget> widget(CreateNewWidget());
768 DragTestView* drag_view = new DragTestView; 768 DragTestView* drag_view = new DragTestView;
769 AddViewToWidgetAndResize(widget.get(), drag_view); 769 AddViewToWidgetAndResize(widget.get(), drag_view);
770 ui::OSExchangeData data; 770 ui::OSExchangeData data;
771 data.SetString(base::UTF8ToUTF16("I am being dragged")); 771 data.SetString(base::UTF8ToUTF16("I am being dragged"));
772 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 772 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
773 widget->GetNativeView()); 773 widget->GetNativeView());
774 generator.PressLeftButton(); 774 generator.PressLeftButton();
775 775
776 int num_drags = 17; 776 int num_drags = 17;
777 for (int i = 0; i < num_drags; ++i) { 777 for (int i = 0; i < num_drags; ++i) {
778 // Because we are not doing a blocking drag and drop, the original 778 // Because we are not doing a blocking drag and drop, the original
779 // OSDragExchangeData object is lost as soon as we return from the drag 779 // OSDragExchangeData object is lost as soon as we return from the drag
780 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 780 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
781 // drag_data_ to a fake drag data object that we created. 781 // drag_data_ to a fake drag data object that we created.
782 if (i > 0) 782 if (i > 0)
783 UpdateDragData(&data); 783 UpdateDragData(&data);
(...skipping 20 matching lines...) Expand all
804 EXPECT_EQ(1, drag_view->num_drag_exits_); 804 EXPECT_EQ(1, drag_view->num_drag_exits_);
805 EXPECT_TRUE(drag_view->drag_done_received_); 805 EXPECT_TRUE(drag_view->drag_done_received_);
806 } 806 }
807 807
808 TEST_F(DragDropControllerTest, MAYBE_CaptureLostCancelsDragDrop) { 808 TEST_F(DragDropControllerTest, MAYBE_CaptureLostCancelsDragDrop) {
809 scoped_ptr<views::Widget> widget(CreateNewWidget()); 809 scoped_ptr<views::Widget> widget(CreateNewWidget());
810 DragTestView* drag_view = new DragTestView; 810 DragTestView* drag_view = new DragTestView;
811 AddViewToWidgetAndResize(widget.get(), drag_view); 811 AddViewToWidgetAndResize(widget.get(), drag_view);
812 ui::OSExchangeData data; 812 ui::OSExchangeData data;
813 data.SetString(base::UTF8ToUTF16("I am being dragged")); 813 data.SetString(base::UTF8ToUTF16("I am being dragged"));
814 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 814 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
815 widget->GetNativeView()); 815 widget->GetNativeView());
816 generator.PressLeftButton(); 816 generator.PressLeftButton();
817 817
818 int num_drags = 17; 818 int num_drags = 17;
819 for (int i = 0; i < num_drags; ++i) { 819 for (int i = 0; i < num_drags; ++i) {
820 // Because we are not doing a blocking drag and drop, the original 820 // Because we are not doing a blocking drag and drop, the original
821 // OSDragExchangeData object is lost as soon as we return from the drag 821 // OSDragExchangeData object is lost as soon as we return from the drag
822 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 822 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
823 // drag_data_ to a fake drag data object that we created. 823 // drag_data_ to a fake drag data object that we created.
824 if (i > 0) 824 if (i > 0)
825 UpdateDragData(&data); 825 UpdateDragData(&data);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 DragTestView* drag_view2 = new DragTestView; 866 DragTestView* drag_view2 = new DragTestView;
867 AddViewToWidgetAndResize(widget2.get(), drag_view2); 867 AddViewToWidgetAndResize(widget2.get(), drag_view2);
868 gfx::Rect widget1_bounds = widget1->GetClientAreaBoundsInScreen(); 868 gfx::Rect widget1_bounds = widget1->GetClientAreaBoundsInScreen();
869 gfx::Rect widget2_bounds = widget2->GetClientAreaBoundsInScreen(); 869 gfx::Rect widget2_bounds = widget2->GetClientAreaBoundsInScreen();
870 widget2->SetBounds(gfx::Rect(widget1_bounds.width(), 0, 870 widget2->SetBounds(gfx::Rect(widget1_bounds.width(), 0,
871 widget2_bounds.width(), widget2_bounds.height())); 871 widget2_bounds.width(), widget2_bounds.height()));
872 872
873 ui::OSExchangeData data; 873 ui::OSExchangeData data;
874 data.SetString(base::UTF8ToUTF16("I am being dragged")); 874 data.SetString(base::UTF8ToUTF16("I am being dragged"));
875 875
876 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 876 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
877 widget1->GetNativeView()); 877 widget1->GetNativeView());
878 generator.PressTouch(); 878 generator.PressTouch();
879 gfx::Point point = gfx::Rect(drag_view1->bounds()).CenterPoint(); 879 gfx::Point point = gfx::Rect(drag_view1->bounds()).CenterPoint();
880 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point); 880 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point);
881 // Because we are not doing a blocking drag and drop, the original 881 // Because we are not doing a blocking drag and drop, the original
882 // OSDragExchangeData object is lost as soon as we return from the drag 882 // OSDragExchangeData object is lost as soon as we return from the drag
883 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 883 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
884 // drag_data_ to a fake drag data object that we created. 884 // drag_data_ to a fake drag data object that we created.
885 UpdateDragData(&data); 885 UpdateDragData(&data);
886 gfx::Point gesture_location = point; 886 gfx::Point gesture_location = point;
887 int num_drags = drag_view1->width(); 887 int num_drags = drag_view1->width();
(...skipping 28 matching lines...) Expand all
916 EXPECT_EQ(0, drag_view2->num_drag_exits_); 916 EXPECT_EQ(0, drag_view2->num_drag_exits_);
917 EXPECT_FALSE(drag_view2->drag_done_received_); 917 EXPECT_FALSE(drag_view2->drag_done_received_);
918 } 918 }
919 919
920 TEST_F(DragDropControllerTest, TouchDragDropCancelsOnLongTap) { 920 TEST_F(DragDropControllerTest, TouchDragDropCancelsOnLongTap) {
921 CommandLine::ForCurrentProcess()->AppendSwitch( 921 CommandLine::ForCurrentProcess()->AppendSwitch(
922 switches::kEnableTouchDragDrop); 922 switches::kEnableTouchDragDrop);
923 scoped_ptr<views::Widget> widget(CreateNewWidget()); 923 scoped_ptr<views::Widget> widget(CreateNewWidget());
924 DragTestView* drag_view = new DragTestView; 924 DragTestView* drag_view = new DragTestView;
925 AddViewToWidgetAndResize(widget.get(), drag_view); 925 AddViewToWidgetAndResize(widget.get(), drag_view);
926 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 926 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
927 widget->GetNativeView()); 927 widget->GetNativeView());
928 928
929 generator.PressTouch(); 929 generator.PressTouch();
930 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); 930 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint();
931 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point); 931 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point);
932 DispatchGesture(ui::ET_GESTURE_LONG_TAP, point); 932 DispatchGesture(ui::ET_GESTURE_LONG_TAP, point);
933 933
934 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 934 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
935 EXPECT_TRUE(drag_drop_controller_->drag_canceled_); 935 EXPECT_TRUE(drag_drop_controller_->drag_canceled_);
936 EXPECT_EQ(0, drag_drop_controller_->num_drag_updates_); 936 EXPECT_EQ(0, drag_drop_controller_->num_drag_updates_);
937 EXPECT_FALSE(drag_drop_controller_->drop_received_); 937 EXPECT_FALSE(drag_drop_controller_->drop_received_);
938 EXPECT_EQ(base::UTF8ToUTF16("I am being dragged"), 938 EXPECT_EQ(base::UTF8ToUTF16("I am being dragged"),
939 drag_drop_controller_->drag_string_); 939 drag_drop_controller_->drag_string_);
940 EXPECT_EQ(0, drag_view->num_drag_enters_); 940 EXPECT_EQ(0, drag_view->num_drag_enters_);
941 EXPECT_EQ(0, drag_view->num_drops_); 941 EXPECT_EQ(0, drag_view->num_drops_);
942 EXPECT_EQ(0, drag_view->num_drag_exits_); 942 EXPECT_EQ(0, drag_view->num_drag_exits_);
943 EXPECT_TRUE(drag_view->drag_done_received_); 943 EXPECT_TRUE(drag_view->drag_done_received_);
944 } 944 }
945 945
946 TEST_F(DragDropControllerTest, TouchDragDropLongTapGestureIsForwarded) { 946 TEST_F(DragDropControllerTest, TouchDragDropLongTapGestureIsForwarded) {
947 CommandLine::ForCurrentProcess()->AppendSwitch( 947 CommandLine::ForCurrentProcess()->AppendSwitch(
948 switches::kEnableTouchDragDrop); 948 switches::kEnableTouchDragDrop);
949 scoped_ptr<views::Widget> widget(CreateNewWidget()); 949 scoped_ptr<views::Widget> widget(CreateNewWidget());
950 DragTestView* drag_view = new DragTestView; 950 DragTestView* drag_view = new DragTestView;
951 AddViewToWidgetAndResize(widget.get(), drag_view); 951 AddViewToWidgetAndResize(widget.get(), drag_view);
952 aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 952 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
953 widget->GetNativeView()); 953 widget->GetNativeView());
954 954
955 generator.PressTouch(); 955 generator.PressTouch();
956 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); 956 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint();
957 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point); 957 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point);
958 958
959 // Since we are not running inside a nested loop, the |drag_source_window_| 959 // Since we are not running inside a nested loop, the |drag_source_window_|
960 // will get destroyed immediately. Hence we reassign it. 960 // will get destroyed immediately. Hence we reassign it.
961 EXPECT_EQ(NULL, GetDragSourceWindow()); 961 EXPECT_EQ(NULL, GetDragSourceWindow());
962 SetDragSourceWindow(widget->GetNativeView()); 962 SetDragSourceWindow(widget->GetNativeView());
963 EXPECT_FALSE(drag_view->long_tap_received_); 963 EXPECT_FALSE(drag_view->long_tap_received_);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString()); 1075 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString());
1076 } 1076 }
1077 for (aura::Window::Windows::iterator iter = root_windows.begin(); 1077 for (aura::Window::Windows::iterator iter = root_windows.begin();
1078 iter != root_windows.end(); ++iter) { 1078 iter != root_windows.end(); ++iter) {
1079 aura::client::SetDragDropClient(*iter, NULL); 1079 aura::client::SetDragDropClient(*iter, NULL);
1080 } 1080 }
1081 } 1081 }
1082 1082
1083 } // namespace test 1083 } // namespace test
1084 } // namespace aura 1084 } // namespace aura
OLDNEW
« no previous file with comments | « ash/display/root_window_transformers_unittest.cc ('k') | ash/extended_desktop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698