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
parent 290fc49d
...@@ -367,5 +367,60 @@ TEST_F(DragDropControllerTest, DragDropInMultipleViewsMultipleWidgetsTest) { ...@@ -367,5 +367,60 @@ TEST_F(DragDropControllerTest, DragDropInMultipleViewsMultipleWidgetsTest) {
delete widget2; 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 test
} // namespace aura } // namespace aura
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.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.h"
#include "ui/gfx/compositor/layer_delegate.h" #include "ui/gfx/compositor/layer_delegate.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
...@@ -57,7 +58,7 @@ namespace internal { ...@@ -57,7 +58,7 @@ namespace internal {
// | xXX| // | xXX|
// ... // ...
// //
class ImageGrid { class AURA_SHELL_EXPORT ImageGrid {
public: public:
// Helper class for use by tests. // Helper class for use by tests.
class TestAPI { class TestAPI {
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "ui/aura_shell/aura_shell_export.h"
#include "ui/gfx/rect.h" #include "ui/gfx/rect.h"
namespace ui { namespace ui {
...@@ -20,7 +21,7 @@ namespace internal { ...@@ -20,7 +21,7 @@ namespace internal {
class ImageGrid; class ImageGrid;
// Simple class that draws a drop shadow around content at given bounds. // Simple class that draws a drop shadow around content at given bounds.
class Shadow { class AURA_SHELL_EXPORT Shadow {
public: public:
Shadow(); Shadow();
~Shadow(); ~Shadow();
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/memory/linked_ptr.h" #include "base/memory/linked_ptr.h"
#include "ui/aura/desktop_observer.h" #include "ui/aura/desktop_observer.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/aura_shell/aura_shell_export.h"
namespace aura { namespace aura {
class Window; class Window;
...@@ -28,8 +29,8 @@ class Shadow; ...@@ -28,8 +29,8 @@ class Shadow;
// ShadowController observes changes to windows and creates and updates drop // ShadowController observes changes to windows and creates and updates drop
// shadows as needed. // shadows as needed.
class ShadowController : public aura::DesktopObserver, class AURA_SHELL_EXPORT ShadowController : public aura::DesktopObserver,
public aura::WindowObserver { public aura::WindowObserver {
public: public:
class TestApi { class TestApi {
public: public:
......
...@@ -235,8 +235,8 @@ void NativeWidgetAura::ReorderLayers() { ...@@ -235,8 +235,8 @@ void NativeWidgetAura::ReorderLayers() {
} }
void NativeWidgetAura::ViewRemoved(View* view) { void NativeWidgetAura::ViewRemoved(View* view) {
// DropTarget stuff. Most likely http://crbug.com/97845 DCHECK(drop_helper_.get() != NULL);
//NOTIMPLEMENTED(); drop_helper_->ResetTargetViewIfEquals(view);
} }
void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) { void NativeWidgetAura::SetNativeWindowProperty(const char* name, void* value) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment