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

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

Issue 8771015: Rename Desktop->RootWindow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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 | « ui/aura_shell/drag_drop_controller.cc ('k') | ui/aura_shell/examples/aura_shell_main.cc » ('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"
11 #include "ui/aura/event.h" 10 #include "ui/aura/event.h"
12 #include "ui/aura_shell/desktop_event_filter.h" 11 #include "ui/aura/root_window.h"
12 #include "ui/aura_shell/root_window_event_filter.h"
13 #include "ui/aura_shell/test/aura_shell_test_base.h" 13 #include "ui/aura_shell/test/aura_shell_test_base.h"
14 #include "ui/base/dragdrop/drag_drop_types.h" 14 #include "ui/base/dragdrop/drag_drop_types.h"
15 #include "ui/base/dragdrop/os_exchange_data.h" 15 #include "ui/base/dragdrop/os_exchange_data.h"
16 #include "ui/views/events/event.h" 16 #include "ui/views/events/event.h"
17 #include "ui/views/view.h" 17 #include "ui/views/view.h"
18 #include "ui/views/widget/widget.h" 18 #include "ui/views/widget/widget.h"
19 19
20 namespace aura_shell { 20 namespace aura_shell {
21 namespace test { 21 namespace test {
22 22
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 139
140 DISALLOW_COPY_AND_ASSIGN(TestDragDropController); 140 DISALLOW_COPY_AND_ASSIGN(TestDragDropController);
141 }; 141 };
142 142
143 views::Widget* CreateNewWidget() { 143 views::Widget* CreateNewWidget() {
144 views::Widget* widget = new views::Widget; 144 views::Widget* widget = new views::Widget;
145 views::Widget::InitParams params; 145 views::Widget::InitParams params;
146 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; 146 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS;
147 params.accept_events = true; 147 params.accept_events = true;
148 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 148 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
149 params.parent = aura::Desktop::GetInstance(); 149 params.parent = aura::RootWindow::GetInstance();
150 params.child = true; 150 params.child = true;
151 widget->Init(params); 151 widget->Init(params);
152 widget->Show(); 152 widget->Show();
153 return widget; 153 return widget;
154 } 154 }
155 155
156 void AddViewToWidgetAndResize(views::Widget* widget, views::View* view) { 156 void AddViewToWidgetAndResize(views::Widget* widget, views::View* view) {
157 if (!widget->GetContentsView()) { 157 if (!widget->GetContentsView()) {
158 views::View* contents_view = new views::View; 158 views::View* contents_view = new views::View;
159 widget->SetContentsView(contents_view); 159 widget->SetContentsView(contents_view);
160 } 160 }
161 161
162 views::View* contents_view = widget->GetContentsView(); 162 views::View* contents_view = widget->GetContentsView();
163 contents_view->AddChildView(view); 163 contents_view->AddChildView(view);
164 view->SetBounds(contents_view->width(), 0, 100, 100); 164 view->SetBounds(contents_view->width(), 0, 100, 100);
165 gfx::Rect contents_view_bounds = contents_view->bounds(); 165 gfx::Rect contents_view_bounds = contents_view->bounds();
166 contents_view_bounds = contents_view_bounds.Union(view->bounds()); 166 contents_view_bounds = contents_view_bounds.Union(view->bounds());
167 contents_view->SetBoundsRect(contents_view_bounds); 167 contents_view->SetBoundsRect(contents_view_bounds);
168 widget->SetBounds(contents_view_bounds); 168 widget->SetBounds(contents_view_bounds);
169 } 169 }
170 170
171 } // namespace 171 } // namespace
172 172
173 class DragDropControllerTest : public AuraShellTestBase { 173 class DragDropControllerTest : public AuraShellTestBase {
174 public: 174 public:
175 DragDropControllerTest() : AuraShellTestBase() { 175 DragDropControllerTest() : AuraShellTestBase() {
176 } 176 }
177 177
178 virtual ~DragDropControllerTest() { 178 virtual ~DragDropControllerTest() {
179 aura::Desktop::GetInstance()->SetProperty(aura::kDesktopDragDropClientKey, 179 aura::RootWindow::GetInstance()->SetProperty(
180 aura::kRootWindowDragDropClientKey,
180 NULL); 181 NULL);
181 } 182 }
182 183
183 void SetUp() OVERRIDE { 184 void SetUp() OVERRIDE {
184 AuraShellTestBase::SetUp(); 185 AuraShellTestBase::SetUp();
185 drag_drop_controller_ = new TestDragDropController; 186 drag_drop_controller_ = new TestDragDropController;
186 drag_drop_controller_->set_should_block_during_drag_drop(false); 187 drag_drop_controller_->set_should_block_during_drag_drop(false);
187 aura::Desktop::GetInstance()->SetProperty(aura::kDesktopDragDropClientKey, 188 aura::RootWindow::GetInstance()->SetProperty(
189 aura::kRootWindowDragDropClientKey,
188 drag_drop_controller_); 190 drag_drop_controller_);
189 } 191 }
190 192
191 void TearDown() OVERRIDE { 193 void TearDown() OVERRIDE {
192 delete drag_drop_controller_; 194 delete drag_drop_controller_;
193 drag_drop_controller_ = NULL; 195 drag_drop_controller_ = NULL;
194 AuraShellTestBase::TearDown(); 196 AuraShellTestBase::TearDown();
195 } 197 }
196 198
197 void UpdateDragData(ui::OSExchangeData* data) { 199 void UpdateDragData(ui::OSExchangeData* data) {
198 drag_drop_controller_->drag_data_ = data; 200 drag_drop_controller_->drag_data_ = data;
199 } 201 }
200 202
201 protected: 203 protected:
202 TestDragDropController* drag_drop_controller_; 204 TestDragDropController* drag_drop_controller_;
203 205
204 private: 206 private:
205 DISALLOW_COPY_AND_ASSIGN(DragDropControllerTest); 207 DISALLOW_COPY_AND_ASSIGN(DragDropControllerTest);
206 }; 208 };
207 209
208 TEST_F(DragDropControllerTest, DragDropInSingleViewTest) { 210 TEST_F(DragDropControllerTest, DragDropInSingleViewTest) {
209 views::Widget* widget = CreateNewWidget(); 211 views::Widget* widget = CreateNewWidget();
210 DragTestView* drag_view = new DragTestView; 212 DragTestView* drag_view = new DragTestView;
211 AddViewToWidgetAndResize(widget, drag_view); 213 AddViewToWidgetAndResize(widget, drag_view);
212 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); 214 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint();
213 ui::OSExchangeData data; 215 ui::OSExchangeData data;
214 data.SetString(UTF8ToUTF16("I am being dragged")); 216 data.SetString(UTF8ToUTF16("I am being dragged"));
215 217
216 aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN); 218 aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN);
217 aura::Desktop::GetInstance()->DispatchMouseEvent(&event1); 219 aura::RootWindow::GetInstance()->DispatchMouseEvent(&event1);
218 220
219 int num_drags = 17; 221 int num_drags = 17;
220 for (int i = 0; i < num_drags; ++i) { 222 for (int i = 0; i < num_drags; ++i) {
221 // Because we are not doing a blocking drag and drop, the original 223 // Because we are not doing a blocking drag and drop, the original
222 // OSDragExchangeData object is lost as soon as we return from the drag 224 // OSDragExchangeData object is lost as soon as we return from the drag
223 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 225 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
224 // drag_data_ to a fake drag data object that we created. 226 // drag_data_ to a fake drag data object that we created.
225 if (i > 0) 227 if (i > 0)
226 UpdateDragData(&data); 228 UpdateDragData(&data);
227 point.Offset(0, 1); 229 point.Offset(0, 1);
228 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point, 230 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point,
229 ui::EF_LEFT_BUTTON_DOWN); 231 ui::EF_LEFT_BUTTON_DOWN);
230 aura::Desktop::GetInstance()->DispatchMouseEvent(&drag_event); 232 aura::RootWindow::GetInstance()->DispatchMouseEvent(&drag_event);
231 } 233 }
232 234
233 aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0); 235 aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0);
234 aura::Desktop::GetInstance()->DispatchMouseEvent(&event2); 236 aura::RootWindow::GetInstance()->DispatchMouseEvent(&event2);
235 237
236 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 238 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
237 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(), 239 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(),
238 drag_drop_controller_->num_drag_updates_); 240 drag_drop_controller_->num_drag_updates_);
239 EXPECT_TRUE(drag_drop_controller_->drop_received_); 241 EXPECT_TRUE(drag_drop_controller_->drop_received_);
240 EXPECT_EQ(UTF8ToUTF16("I am being dragged"), 242 EXPECT_EQ(UTF8ToUTF16("I am being dragged"),
241 drag_drop_controller_->drag_string_); 243 drag_drop_controller_->drag_string_);
242 244
243 EXPECT_EQ(1, drag_view->num_drag_enters_); 245 EXPECT_EQ(1, drag_view->num_drag_enters_);
244 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(), 246 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(),
245 drag_view->num_drag_updates_); 247 drag_view->num_drag_updates_);
246 EXPECT_EQ(1, drag_view->num_drops_); 248 EXPECT_EQ(1, drag_view->num_drops_);
247 EXPECT_EQ(0, drag_view->num_drag_exits_); 249 EXPECT_EQ(0, drag_view->num_drag_exits_);
248 EXPECT_TRUE(drag_view->drag_done_received_); 250 EXPECT_TRUE(drag_view->drag_done_received_);
249 delete widget; 251 delete widget;
250 } 252 }
251 253
252 TEST_F(DragDropControllerTest, DragDropInMultipleViewsSingleWidgetTest) { 254 TEST_F(DragDropControllerTest, DragDropInMultipleViewsSingleWidgetTest) {
253 views::Widget* widget = CreateNewWidget(); 255 views::Widget* widget = CreateNewWidget();
254 DragTestView* drag_view1 = new DragTestView; 256 DragTestView* drag_view1 = new DragTestView;
255 AddViewToWidgetAndResize(widget, drag_view1); 257 AddViewToWidgetAndResize(widget, drag_view1);
256 gfx::Point point = drag_view1->bounds().CenterPoint(); 258 gfx::Point point = drag_view1->bounds().CenterPoint();
257 DragTestView* drag_view2 = new DragTestView; 259 DragTestView* drag_view2 = new DragTestView;
258 AddViewToWidgetAndResize(widget, drag_view2); 260 AddViewToWidgetAndResize(widget, drag_view2);
259 261
260 ui::OSExchangeData data; 262 ui::OSExchangeData data;
261 data.SetString(UTF8ToUTF16("I am being dragged")); 263 data.SetString(UTF8ToUTF16("I am being dragged"));
262 264
263 aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN); 265 aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN);
264 aura::Desktop::GetInstance()->DispatchMouseEvent(&event1); 266 aura::RootWindow::GetInstance()->DispatchMouseEvent(&event1);
265 267
266 int num_drags = drag_view1->width(); 268 int num_drags = drag_view1->width();
267 for (int i = 0; i < num_drags; ++i) { 269 for (int i = 0; i < num_drags; ++i) {
268 // Because we are not doing a blocking drag and drop, the original 270 // Because we are not doing a blocking drag and drop, the original
269 // OSDragExchangeData object is lost as soon as we return from the drag 271 // OSDragExchangeData object is lost as soon as we return from the drag
270 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 272 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
271 // drag_data_ to a fake drag data object that we created. 273 // drag_data_ to a fake drag data object that we created.
272 if (i > 0) 274 if (i > 0)
273 UpdateDragData(&data); 275 UpdateDragData(&data);
274 point.Offset(1, 0); 276 point.Offset(1, 0);
275 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point, 277 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point,
276 ui::EF_LEFT_BUTTON_DOWN); 278 ui::EF_LEFT_BUTTON_DOWN);
277 aura::Desktop::GetInstance()->DispatchMouseEvent(&drag_event); 279 aura::RootWindow::GetInstance()->DispatchMouseEvent(&drag_event);
278 } 280 }
279 281
280 aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0); 282 aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0);
281 aura::Desktop::GetInstance()->DispatchMouseEvent(&event2); 283 aura::RootWindow::GetInstance()->DispatchMouseEvent(&event2);
282 284
283 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 285 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
284 EXPECT_EQ(num_drags - 1 - drag_view1->HorizontalDragThreshold(), 286 EXPECT_EQ(num_drags - 1 - drag_view1->HorizontalDragThreshold(),
285 drag_drop_controller_->num_drag_updates_); 287 drag_drop_controller_->num_drag_updates_);
286 EXPECT_TRUE(drag_drop_controller_->drop_received_); 288 EXPECT_TRUE(drag_drop_controller_->drop_received_);
287 EXPECT_EQ(UTF8ToUTF16("I am being dragged"), 289 EXPECT_EQ(UTF8ToUTF16("I am being dragged"),
288 drag_drop_controller_->drag_string_); 290 drag_drop_controller_->drag_string_);
289 291
290 EXPECT_EQ(1, drag_view1->num_drag_enters_); 292 EXPECT_EQ(1, drag_view1->num_drag_enters_);
291 int num_expected_updates = drag_view1->bounds().width() - 293 int num_expected_updates = drag_view1->bounds().width() -
(...skipping 23 matching lines...) Expand all
315 AddViewToWidgetAndResize(widget2, drag_view2); 317 AddViewToWidgetAndResize(widget2, drag_view2);
316 gfx::Rect widget1_bounds = widget1->GetClientAreaScreenBounds(); 318 gfx::Rect widget1_bounds = widget1->GetClientAreaScreenBounds();
317 gfx::Rect widget2_bounds = widget2->GetClientAreaScreenBounds(); 319 gfx::Rect widget2_bounds = widget2->GetClientAreaScreenBounds();
318 widget2->SetBounds(gfx::Rect(widget1_bounds.width(), 0, 320 widget2->SetBounds(gfx::Rect(widget1_bounds.width(), 0,
319 widget2_bounds.width(), widget2_bounds.height())); 321 widget2_bounds.width(), widget2_bounds.height()));
320 322
321 ui::OSExchangeData data; 323 ui::OSExchangeData data;
322 data.SetString(UTF8ToUTF16("I am being dragged")); 324 data.SetString(UTF8ToUTF16("I am being dragged"));
323 325
324 aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN); 326 aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN);
325 aura::Desktop::GetInstance()->DispatchMouseEvent(&event1); 327 aura::RootWindow::GetInstance()->DispatchMouseEvent(&event1);
326 328
327 int num_drags = drag_view1->width(); 329 int num_drags = drag_view1->width();
328 for (int i = 0; i < num_drags; ++i) { 330 for (int i = 0; i < num_drags; ++i) {
329 // Because we are not doing a blocking drag and drop, the original 331 // Because we are not doing a blocking drag and drop, the original
330 // OSDragExchangeData object is lost as soon as we return from the drag 332 // OSDragExchangeData object is lost as soon as we return from the drag
331 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 333 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
332 // drag_data_ to a fake drag data object that we created. 334 // drag_data_ to a fake drag data object that we created.
333 if (i > 0) 335 if (i > 0)
334 UpdateDragData(&data); 336 UpdateDragData(&data);
335 point.Offset(1, 0); 337 point.Offset(1, 0);
336 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point, 338 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point,
337 ui::EF_LEFT_BUTTON_DOWN); 339 ui::EF_LEFT_BUTTON_DOWN);
338 aura::Desktop::GetInstance()->DispatchMouseEvent(&drag_event); 340 aura::RootWindow::GetInstance()->DispatchMouseEvent(&drag_event);
339 } 341 }
340 342
341 aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0); 343 aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0);
342 aura::Desktop::GetInstance()->DispatchMouseEvent(&event2); 344 aura::RootWindow::GetInstance()->DispatchMouseEvent(&event2);
343 345
344 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 346 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
345 EXPECT_EQ(num_drags - 1 - drag_view1->HorizontalDragThreshold(), 347 EXPECT_EQ(num_drags - 1 - drag_view1->HorizontalDragThreshold(),
346 drag_drop_controller_->num_drag_updates_); 348 drag_drop_controller_->num_drag_updates_);
347 EXPECT_TRUE(drag_drop_controller_->drop_received_); 349 EXPECT_TRUE(drag_drop_controller_->drop_received_);
348 EXPECT_EQ(UTF8ToUTF16("I am being dragged"), 350 EXPECT_EQ(UTF8ToUTF16("I am being dragged"),
349 drag_drop_controller_->drag_string_); 351 drag_drop_controller_->drag_string_);
350 352
351 EXPECT_EQ(1, drag_view1->num_drag_enters_); 353 EXPECT_EQ(1, drag_view1->num_drag_enters_);
352 int num_expected_updates = drag_view1->bounds().width() - 354 int num_expected_updates = drag_view1->bounds().width() -
(...skipping 16 matching lines...) Expand all
369 371
370 TEST_F(DragDropControllerTest, ViewRemovedWhileInDragDropTest) { 372 TEST_F(DragDropControllerTest, ViewRemovedWhileInDragDropTest) {
371 views::Widget* widget = CreateNewWidget(); 373 views::Widget* widget = CreateNewWidget();
372 DragTestView* drag_view = new DragTestView; 374 DragTestView* drag_view = new DragTestView;
373 AddViewToWidgetAndResize(widget, drag_view); 375 AddViewToWidgetAndResize(widget, drag_view);
374 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); 376 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint();
375 ui::OSExchangeData data; 377 ui::OSExchangeData data;
376 data.SetString(UTF8ToUTF16("I am being dragged")); 378 data.SetString(UTF8ToUTF16("I am being dragged"));
377 379
378 aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN); 380 aura::MouseEvent event1(ui::ET_MOUSE_PRESSED, point, ui::EF_LEFT_BUTTON_DOWN);
379 aura::Desktop::GetInstance()->DispatchMouseEvent(&event1); 381 aura::RootWindow::GetInstance()->DispatchMouseEvent(&event1);
380 382
381 int num_drags_1 = 17; 383 int num_drags_1 = 17;
382 for (int i = 0; i < num_drags_1; ++i) { 384 for (int i = 0; i < num_drags_1; ++i) {
383 // Because we are not doing a blocking drag and drop, the original 385 // 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 386 // OSDragExchangeData object is lost as soon as we return from the drag
385 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 387 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
386 // drag_data_ to a fake drag data object that we created. 388 // drag_data_ to a fake drag data object that we created.
387 if (i > 0) 389 if (i > 0)
388 UpdateDragData(&data); 390 UpdateDragData(&data);
389 point.Offset(0, 1); 391 point.Offset(0, 1);
390 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point, 392 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point,
391 ui::EF_LEFT_BUTTON_DOWN); 393 ui::EF_LEFT_BUTTON_DOWN);
392 aura::Desktop::GetInstance()->DispatchMouseEvent(&drag_event); 394 aura::RootWindow::GetInstance()->DispatchMouseEvent(&drag_event);
393 } 395 }
394 396
395 drag_view->parent()->RemoveChildView(drag_view); 397 drag_view->parent()->RemoveChildView(drag_view);
396 // View has been removed. We will not get any of the following drag updates. 398 // View has been removed. We will not get any of the following drag updates.
397 int num_drags_2 = 23; 399 int num_drags_2 = 23;
398 for (int i = 0; i < num_drags_2; ++i) { 400 for (int i = 0; i < num_drags_2; ++i) {
399 UpdateDragData(&data); 401 UpdateDragData(&data);
400 point.Offset(0, 1); 402 point.Offset(0, 1);
401 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point, 403 aura::MouseEvent drag_event(ui::ET_MOUSE_DRAGGED, point,
402 ui::EF_LEFT_BUTTON_DOWN); 404 ui::EF_LEFT_BUTTON_DOWN);
403 aura::Desktop::GetInstance()->DispatchMouseEvent(&drag_event); 405 aura::RootWindow::GetInstance()->DispatchMouseEvent(&drag_event);
404 } 406 }
405 407
406 aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0); 408 aura::MouseEvent event2(ui::ET_MOUSE_RELEASED, point, 0);
407 aura::Desktop::GetInstance()->DispatchMouseEvent(&event2); 409 aura::RootWindow::GetInstance()->DispatchMouseEvent(&event2);
408 410
409 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 411 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
410 EXPECT_EQ(num_drags_1 + num_drags_2 - 1 - drag_view->VerticalDragThreshold(), 412 EXPECT_EQ(num_drags_1 + num_drags_2 - 1 - drag_view->VerticalDragThreshold(),
411 drag_drop_controller_->num_drag_updates_); 413 drag_drop_controller_->num_drag_updates_);
412 EXPECT_TRUE(drag_drop_controller_->drop_received_); 414 EXPECT_TRUE(drag_drop_controller_->drop_received_);
413 EXPECT_EQ(UTF8ToUTF16("I am being dragged"), 415 EXPECT_EQ(UTF8ToUTF16("I am being dragged"),
414 drag_drop_controller_->drag_string_); 416 drag_drop_controller_->drag_string_);
415 417
416 EXPECT_EQ(1, drag_view->num_drag_enters_); 418 EXPECT_EQ(1, drag_view->num_drag_enters_);
417 EXPECT_EQ(num_drags_1 - 1 - drag_view->VerticalDragThreshold(), 419 EXPECT_EQ(num_drags_1 - 1 - drag_view->VerticalDragThreshold(),
418 drag_view->num_drag_updates_); 420 drag_view->num_drag_updates_);
419 EXPECT_EQ(0, drag_view->num_drops_); 421 EXPECT_EQ(0, drag_view->num_drops_);
420 EXPECT_EQ(0, drag_view->num_drag_exits_); 422 EXPECT_EQ(0, drag_view->num_drag_exits_);
421 EXPECT_TRUE(drag_view->drag_done_received_); 423 EXPECT_TRUE(drag_view->drag_done_received_);
422 delete widget; 424 delete widget;
423 } 425 }
424 426
425 } // namespace test 427 } // namespace test
426 } // namespace aura 428 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura_shell/drag_drop_controller.cc ('k') | ui/aura_shell/examples/aura_shell_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698