summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorvarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 23:26:36 +0000
committervarunjain@chromium.org <varunjain@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-22 23:26:36 +0000
commit2505827b3cb1a71414e2d70c8149ecb0fed8d925 (patch)
tree4646e4614a9dd8a9249ab032b32abc53ad2dcfe4 /ui
parent290fc49d46142b94f9c7754c8c3cf36408b9a269 (diff)
downloadchromium_src-2505827b3cb1a71414e2d70c8149ecb0fed8d925.zip
chromium_src-2505827b3cb1a71414e2d70c8149ecb0fed8d925.tar.gz
chromium_src-2505827b3cb1a71414e2d70c8149ecb0fed8d925.tar.bz2
Aura: notify DropHelper when target view is removed.
BUG=97845 TEST=DragDropControllerTest.ViewRemovedWhileInDragDropTest Review URL: http://codereview.chromium.org/8631015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111247 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/aura_shell/drag_drop_controller_unittest.cc55
-rw-r--r--ui/aura_shell/image_grid.h3
-rw-r--r--ui/aura_shell/shadow.h3
-rw-r--r--ui/aura_shell/shadow_controller.h5
-rw-r--r--ui/views/widget/native_widget_aura.cc4
5 files changed, 64 insertions, 6 deletions
diff --git a/ui/aura_shell/drag_drop_controller_unittest.cc b/ui/aura_shell/drag_drop_controller_unittest.cc
index c5a2142..a153cee 100644
--- a/ui/aura_shell/drag_drop_controller_unittest.cc
+++ b/ui/aura_shell/drag_drop_controller_unittest.cc
@@ -367,5 +367,60 @@ TEST_F(DragDropControllerTest, DragDropInMultipleViewsMultipleWidgetsTest) {
delete widget2;
}
+TEST_F(DragDropControllerTest, ViewRemovedWhileInDragDropTest) {
+ views::Widget* widget = CreateNewWidget();
+ DragTestView* drag_view = new DragTestView;
+ AddViewToWidgetAndResize(widget, drag_view);
+ gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint();
+ ui::OSExchangeData data;
+ data.SetString(UTF8ToUTF16("I am being dragged"));
+
+ aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN);
+ aura::Desktop::GetInstance()->DispatchMouseEvent(&event1);
+
+ int num_drags_1 = 17;
+ for (int i = 0; i < num_drags_1; ++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);
+ point.Offset(0, 1);
+ aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point,
+ ui::EF_LEFT_BUTTON_DOWN);
+ aura::Desktop::GetInstance()->DispatchMouseEvent(&drag_event);
+ }
+
+ drag_view->parent()->RemoveChildView(drag_view);
+ // View has been removed. We will not get any of the following drag updates.
+ int num_drags_2 = 23;
+ for (int i = 0; i < num_drags_2; ++i) {
+ UpdateDragData(&data);
+ point.Offset(0, 1);
+ aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point,
+ ui::EF_LEFT_BUTTON_DOWN);
+ aura::Desktop::GetInstance()->DispatchMouseEvent(&drag_event);
+ }
+
+ aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0);
+ aura::Desktop::GetInstance()->DispatchMouseEvent(&event2);
+
+ EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
+ EXPECT_EQ(num_drags_1 + num_drags_2 - 1 - drag_view->VerticalDragThreshold(),
+ drag_drop_controller_->num_drag_updates_);
+ EXPECT_TRUE(drag_drop_controller_->drop_received_);
+ 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 - 1 - drag_view->VerticalDragThreshold(),
+ drag_view->num_drag_updates_);
+ EXPECT_EQ(0, drag_view->num_drops_);
+ EXPECT_EQ(0, drag_view->num_drag_exits_);
+ EXPECT_TRUE(drag_view->drag_done_received_);
+ delete widget;
+}
+
} // namespace test
} // namespace aura
diff --git a/ui/aura_shell/image_grid.h b/ui/aura_shell/image_grid.h
index e53d97d..a5ff264 100644
--- a/ui/aura_shell/image_grid.h
+++ b/ui/aura_shell/image_grid.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/aura_shell/aura_shell_export.h"
#include "ui/gfx/compositor/layer.h"
#include "ui/gfx/compositor/layer_delegate.h"
#include "ui/gfx/rect.h"
@@ -57,7 +58,7 @@ namespace internal {
// | xXX|
// ...
//
-class ImageGrid {
+class AURA_SHELL_EXPORT ImageGrid {
public:
// Helper class for use by tests.
class TestAPI {
diff --git a/ui/aura_shell/shadow.h b/ui/aura_shell/shadow.h
index 0fea19a..ba73285 100644
--- a/ui/aura_shell/shadow.h
+++ b/ui/aura_shell/shadow.h
@@ -8,6 +8,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/aura_shell/aura_shell_export.h"
#include "ui/gfx/rect.h"
namespace ui {
@@ -20,7 +21,7 @@ namespace internal {
class ImageGrid;
// Simple class that draws a drop shadow around content at given bounds.
-class Shadow {
+class AURA_SHELL_EXPORT Shadow {
public:
Shadow();
~Shadow();
diff --git a/ui/aura_shell/shadow_controller.h b/ui/aura_shell/shadow_controller.h
index d2a79f8..6f6a602 100644
--- a/ui/aura_shell/shadow_controller.h
+++ b/ui/aura_shell/shadow_controller.h
@@ -13,6 +13,7 @@
#include "base/memory/linked_ptr.h"
#include "ui/aura/desktop_observer.h"
#include "ui/aura/window_observer.h"
+#include "ui/aura_shell/aura_shell_export.h"
namespace aura {
class Window;
@@ -28,8 +29,8 @@ class Shadow;
// ShadowController observes changes to windows and creates and updates drop
// shadows as needed.
-class ShadowController : public aura::DesktopObserver,
- public aura::WindowObserver {
+class AURA_SHELL_EXPORT ShadowController : public aura::DesktopObserver,
+ public aura::WindowObserver {
public:
class TestApi {
public:
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc
index cf35cc1..7b1805e 100644
--- a/ui/views/widget/native_widget_aura.cc
+++ b/ui/views/widget/native_widget_aura.cc
@@ -235,8 +235,8 @@ void NativeWidgetAura::ReorderLayers() {
}
void NativeWidgetAura::ViewRemoved(View* view) {
- // DropTarget stuff. Most likely http://crbug.com/97845
- //NOTIMPLEMENTED();
+ DCHECK(drop_helper_.get() != NULL);
+ drop_helper_->ResetTargetViewIfEquals(view);
}
void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) {