diff options
Diffstat (limited to 'ash/drag_drop/drag_drop_controller_unittest.cc')
-rw-r--r-- | ash/drag_drop/drag_drop_controller_unittest.cc | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/ash/drag_drop/drag_drop_controller_unittest.cc b/ash/drag_drop/drag_drop_controller_unittest.cc index 8599535..2b0091f 100644 --- a/ash/drag_drop/drag_drop_controller_unittest.cc +++ b/ash/drag_drop/drag_drop_controller_unittest.cc @@ -4,12 +4,14 @@ #include "ash/drag_drop/drag_drop_controller.h" +#include "ash/drag_drop/drag_drop_tracker.h" #include "ash/drag_drop/drag_image_view.h" #include "ash/shell.h" #include "ash/test/ash_test_base.h" #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" @@ -329,6 +331,10 @@ class DragDropControllerTest : public AshTestBase { NULL; } + internal::DragDropTracker* drag_drop_tracker() { + return drag_drop_controller_->drag_drop_tracker_.get(); + } + void CompleteCancelAnimation() { CompletableLinearAnimation* animation = static_cast<CompletableLinearAnimation*>( @@ -754,8 +760,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 +807,57 @@ TEST_F(DragDropControllerTest, MAYBE_PressingEscapeCancelsDragDrop) { EXPECT_TRUE(drag_view->drag_done_received_); } +TEST_F(DragDropControllerTest, MAYBE_CaptureLostCancelsDragDrop) { + 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(); + } + // Make sure the capture window won't handle mouse events. + aura::Window* capture_window = drag_drop_tracker()->capture_window(); + ASSERT_TRUE(!!capture_window); + EXPECT_EQ("0x0", capture_window->bounds().size().ToString()); + EXPECT_EQ(NULL, + capture_window->GetEventHandlerForPoint(gfx::Point())); + EXPECT_EQ(NULL, + capture_window->GetTopWindowContainingPoint(gfx::Point())); + + 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); |