Chromium Code Reviews| Index: ash/drag_drop/drag_drop_controller_unittest.cc |
| diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc |
| index 8599535d182477cea222483976c0b59c3bcc01ae..698ad2a9b9a385dda993b1acf54375ff6817f0dd 100644 |
| --- a/ash/drag_drop/drag_drop_controller_unittest.cc |
| +++ b/ash/drag_drop/drag_drop_controller_unittest.cc |
| @@ -10,6 +10,7 @@ |
| #include "base/command_line.h" |
| #include "base/location.h" |
| #include "base/utf_string_conversions.h" |
| +#include "ui/aura/client/capture_client.h" |
| #include "ui/aura/root_window.h" |
| #include "ui/aura/test/event_generator.h" |
| #include "ui/base/animation/linear_animation.h" |
| @@ -754,8 +755,10 @@ TEST_F(DragDropControllerTest, SyntheticEventsDuringDragDrop) { |
| // TODO(win_aura) http://crbug.com/154081 |
| #if defined(OS_WIN) |
| #define MAYBE_PressingEscapeCancelsDragDrop DISABLED_PressingEscapeCancelsDragDrop |
| +#define MAYBE_CaptureLostCancelsDragDrop DISABLED_CaptureLostCancelsDragDrop |
| #else |
| #define MAYBE_PressingEscapeCancelsDragDrop PressingEscapeCancelsDragDrop |
| +#define MAYBE_CaptureLostCancelsDragDrop CaptureLostCancelsDragDrop |
| #endif |
| TEST_F(DragDropControllerTest, MAYBE_PressingEscapeCancelsDragDrop) { |
| scoped_ptr<views::Widget> widget(CreateNewWidget()); |
| @@ -799,6 +802,49 @@ TEST_F(DragDropControllerTest, MAYBE_PressingEscapeCancelsDragDrop) { |
| EXPECT_TRUE(drag_view->drag_done_received_); |
| } |
| +TEST_F(DragDropControllerTest, MAYBE_CaptureLostCancelsDragDrop) { |
|
varunjain
2013/03/25 18:04:23
I am a bit concerned that now that we have a non-N
oshima
2013/03/25 20:41:10
I added a few more checks here as the rest of it i
|
| + scoped_ptr<views::Widget> widget(CreateNewWidget()); |
| + DragTestView* drag_view = new DragTestView; |
| + AddViewToWidgetAndResize(widget.get(), drag_view); |
| + ui::OSExchangeData data; |
| + data.SetString(UTF8ToUTF16("I am being dragged")); |
| + aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| + widget->GetNativeView()); |
| + generator.PressLeftButton(); |
| + |
| + int num_drags = 17; |
| + for (int i = 0; i < num_drags; ++i) { |
| + // Because we are not doing a blocking drag and drop, the original |
| + // OSDragExchangeData object is lost as soon as we return from the drag |
| + // initiation in DragDropController::StartDragAndDrop(). Hence we set the |
| + // drag_data_ to a fake drag data object that we created. |
| + if (i > 0) |
| + UpdateDragData(&data); |
| + generator.MoveMouseBy(0, 1); |
| + |
| + // Execute any scheduled draws to process deferred mouse events. |
| + RunAllPendingInMessageLoop(); |
| + } |
| + |
| + aura::client::GetCaptureClient(widget->GetNativeView()->GetRootWindow())-> |
| + SetCapture(NULL); |
| + |
| + EXPECT_TRUE(drag_drop_controller_->drag_start_received_); |
| + EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(), |
| + drag_drop_controller_->num_drag_updates_); |
| + EXPECT_FALSE(drag_drop_controller_->drop_received_); |
| + EXPECT_TRUE(drag_drop_controller_->drag_canceled_); |
| + EXPECT_EQ(UTF8ToUTF16("I am being dragged"), |
| + drag_drop_controller_->drag_string_); |
| + |
| + EXPECT_EQ(1, drag_view->num_drag_enters_); |
| + EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(), |
| + drag_view->num_drag_updates_); |
| + EXPECT_EQ(0, drag_view->num_drops_); |
| + EXPECT_EQ(1, drag_view->num_drag_exits_); |
| + EXPECT_TRUE(drag_view->drag_done_received_); |
| +} |
| + |
| TEST_F(DragDropControllerTest, TouchDragDropInMultipleWindows) { |
| CommandLine::ForCurrentProcess()->AppendSwitch( |
| switches::kEnableTouchDragDrop); |