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

Side by Side Diff: ui/aura_shell/drag_drop_controller_unittest.cc

Issue 8631015: Aura: notify DropHelper when target view is removed. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merged with head Created 9 years, 1 month 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 | « no previous file | ui/aura_shell/image_grid.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "ui/aura_shell/drag_drop_controller.h" 5 #include "ui/aura_shell/drag_drop_controller.h"
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "ui/aura/client/aura_constants.h" 9 #include "ui/aura/client/aura_constants.h"
10 #include "ui/aura/desktop.h" 10 #include "ui/aura/desktop.h"
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 EXPECT_EQ(1, drag_view2->num_drag_enters_); 360 EXPECT_EQ(1, drag_view2->num_drag_enters_);
361 num_expected_updates = num_drags - num_expected_updates - 2; 361 num_expected_updates = num_drags - num_expected_updates - 2;
362 EXPECT_EQ(num_expected_updates, drag_view2->num_drag_updates_); 362 EXPECT_EQ(num_expected_updates, drag_view2->num_drag_updates_);
363 EXPECT_EQ(1, drag_view2->num_drops_); 363 EXPECT_EQ(1, drag_view2->num_drops_);
364 EXPECT_EQ(0, drag_view2->num_drag_exits_); 364 EXPECT_EQ(0, drag_view2->num_drag_exits_);
365 EXPECT_FALSE(drag_view2->drag_done_received_); 365 EXPECT_FALSE(drag_view2->drag_done_received_);
366 delete widget1; 366 delete widget1;
367 delete widget2; 367 delete widget2;
368 } 368 }
369 369
370 TEST_F(DragDropControllerTest, ViewRemovedWhileInDragDropTest) {
371 views::Widget* widget = CreateNewWidget();
372 DragTestView* drag_view = new DragTestView;
373 AddViewToWidgetAndResize(widget, drag_view);
374 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint();
375 ui::OSExchangeData data;
376 data.SetString(UTF8ToUTF16("I am being dragged"));
377
378 aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN);
379 aura::Desktop::GetInstance()->DispatchMouseEvent(&event1);
380
381 int num_drags_1 = 17;
382 for (int i = 0; i < num_drags_1; ++i) {
383 // Because we are not doing a blocking drag and drop, the original
384 // OSDragExchangeData object is lost as soon as we return from the drag
385 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
386 // drag_data_ to a fake drag data object that we created.
387 if (i > 0)
388 UpdateDragData(&data);
389 point.Offset(0, 1);
390 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point,
391 ui::EF_LEFT_BUTTON_DOWN);
392 aura::Desktop::GetInstance()->DispatchMouseEvent(&drag_event);
393 }
394
395 drag_view->parent()->RemoveChildView(drag_view);
396 // View has been removed. We will not get any of the following drag updates.
397 int num_drags_2 = 23;
398 for (int i = 0; i < num_drags_2; ++i) {
399 UpdateDragData(&data);
400 point.Offset(0, 1);
401 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point,
402 ui::EF_LEFT_BUTTON_DOWN);
403 aura::Desktop::GetInstance()->DispatchMouseEvent(&drag_event);
404 }
405
406 aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0);
407 aura::Desktop::GetInstance()->DispatchMouseEvent(&event2);
408
409 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
410 EXPECT_EQ(num_drags_1 + num_drags_2 - 1 - drag_view->VerticalDragThreshold(),
411 drag_drop_controller_->num_drag_updates_);
412 EXPECT_TRUE(drag_drop_controller_->drop_received_);
413 EXPECT_EQ(UTF8ToUTF16("I am being dragged"),
414 drag_drop_controller_->drag_string_);
415
416 EXPECT_EQ(1, drag_view->num_drag_enters_);
417 EXPECT_EQ(num_drags_1 - 1 - drag_view->VerticalDragThreshold(),
418 drag_view->num_drag_updates_);
419 EXPECT_EQ(0, drag_view->num_drops_);
420 EXPECT_EQ(0, drag_view->num_drag_exits_);
421 EXPECT_TRUE(drag_view->drag_done_received_);
422 delete widget;
423 }
424
370 } // namespace test 425 } // namespace test
371 } // namespace aura 426 } // namespace aura
OLDNEW
« no previous file with comments | « no previous file | ui/aura_shell/image_grid.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698