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

Side by Side Diff: ash/drag_drop/drag_drop_controller_unittest.cc

Issue 10825143: aura: Fix a couple of drag drop issues: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 8 years, 4 months 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/drag_drop/drag_drop_controller.h" 5 #include "ash/drag_drop/drag_drop_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 114
115 void Reset() { 115 void Reset() {
116 drag_start_received_ = false; 116 drag_start_received_ = false;
117 num_drag_updates_ = 0; 117 num_drag_updates_ = 0;
118 drop_received_ = false; 118 drop_received_ = false;
119 drag_canceled_ = false; 119 drag_canceled_ = false;
120 drag_string_.clear(); 120 drag_string_.clear();
121 } 121 }
122 122
123 bool drag_start_received_;
124 int num_drag_updates_;
125 bool drop_received_;
126 bool drag_canceled_;
127 string16 drag_string_;
128
129 private:
130 int StartDragAndDrop(const ui::OSExchangeData& data, 123 int StartDragAndDrop(const ui::OSExchangeData& data,
131 const gfx::Point& location, 124 const gfx::Point& location,
132 int operation) OVERRIDE { 125 int operation) OVERRIDE {
133 drag_start_received_ = true; 126 drag_start_received_ = true;
134 data.GetString(&drag_string_); 127 data.GetString(&drag_string_);
135 return DragDropController::StartDragAndDrop(data, location, operation); 128 return DragDropController::StartDragAndDrop(data, location, operation);
136 } 129 }
137 130
131 void DragCancel() OVERRIDE {
132 DragDropController::DragCancel();
133 drag_canceled_ = true;
134 }
135
136 bool drag_start_received_;
137 int num_drag_updates_;
138 bool drop_received_;
139 bool drag_canceled_;
140 string16 drag_string_;
141
142 private:
138 void DragUpdate(aura::Window* target, 143 void DragUpdate(aura::Window* target,
139 const aura::LocatedEvent& event) OVERRIDE { 144 const aura::LocatedEvent& event) OVERRIDE {
140 DragDropController::DragUpdate(target, event); 145 DragDropController::DragUpdate(target, event);
141 num_drag_updates_++; 146 num_drag_updates_++;
142 } 147 }
143 148
144 void Drop(aura::Window* target, const aura::LocatedEvent& event) OVERRIDE { 149 void Drop(aura::Window* target, const aura::LocatedEvent& event) OVERRIDE {
145 DragDropController::Drop(target, event); 150 DragDropController::Drop(target, event);
146 drop_received_ = true; 151 drop_received_ = true;
147 } 152 }
148 153
149 void DragCancel() OVERRIDE {
150 DragDropController::DragCancel();
151 drag_canceled_ = true;
152 }
153
154 DISALLOW_COPY_AND_ASSIGN(TestDragDropController); 154 DISALLOW_COPY_AND_ASSIGN(TestDragDropController);
155 }; 155 };
156 156
157 class TestNativeWidgetAura : public views::NativeWidgetAura { 157 class TestNativeWidgetAura : public views::NativeWidgetAura {
158 public: 158 public:
159 explicit TestNativeWidgetAura(views::internal::NativeWidgetDelegate* delegate) 159 explicit TestNativeWidgetAura(views::internal::NativeWidgetDelegate* delegate)
160 : NativeWidgetAura(delegate), 160 : NativeWidgetAura(delegate),
161 check_if_capture_lost_(false) { 161 check_if_capture_lost_(false) {
162 } 162 }
163 163
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 drag_drop_controller_->drag_string_); 664 drag_drop_controller_->drag_string_);
665 665
666 EXPECT_EQ(1, drag_view->num_drag_enters_); 666 EXPECT_EQ(1, drag_view->num_drag_enters_);
667 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(), 667 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(),
668 drag_view->num_drag_updates_); 668 drag_view->num_drag_updates_);
669 EXPECT_EQ(0, drag_view->num_drops_); 669 EXPECT_EQ(0, drag_view->num_drops_);
670 EXPECT_EQ(1, drag_view->num_drag_exits_); 670 EXPECT_EQ(1, drag_view->num_drag_exits_);
671 EXPECT_TRUE(drag_view->drag_done_received_); 671 EXPECT_TRUE(drag_view->drag_done_received_);
672 } 672 }
673 673
674 TEST_F(DragDropControllerTest, LockCursorWhileInDrag) {
675 ui::OSExchangeData data;
676 drag_drop_controller_->StartDragAndDrop(data, gfx::Point(), 0);
677
678 // We should not be able to change cursor
679 EXPECT_TRUE(ash::Shell::GetInstance()->cursor_manager()->is_cursor_locked());
680 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->last_cursor() ==
681 ui::kCursorProgress);
682 ash::Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorProgress);
683 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->last_cursor() ==
684 ui::kCursorProgress);
685
686 drag_drop_controller_->DragCancel();
687
688 // Now we can change cursor
689 EXPECT_FALSE(ash::Shell::GetInstance()->cursor_manager()->is_cursor_locked());
690 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->last_cursor() ==
691 ui::kCursorProgress);
692 ash::Shell::GetInstance()->cursor_manager()->SetCursor(ui::kCursorProgress);
693 EXPECT_TRUE(Shell::GetPrimaryRootWindow()->last_cursor() ==
694 ui::kCursorProgress);
695 }
696
674 } // namespace test 697 } // namespace test
675 } // namespace aura 698 } // namespace aura
OLDNEW
« ash/drag_drop/drag_drop_controller.cc ('K') | « ash/drag_drop/drag_drop_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698