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

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

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: 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
« no previous file with comments | « ash/drag_drop/drag_drop_controller.cc ('k') | ash/event_rewriter_delegate.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) 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"
11 #include "ui/aura/event.h"
12 #include "ui/aura/root_window.h" 11 #include "ui/aura/root_window.h"
13 #include "ui/aura/test/event_generator.h" 12 #include "ui/aura/test/event_generator.h"
14 #include "ui/base/clipboard/clipboard.h" 13 #include "ui/base/clipboard/clipboard.h"
15 #include "ui/base/clipboard/scoped_clipboard_writer.h" 14 #include "ui/base/clipboard/scoped_clipboard_writer.h"
16 #include "ui/base/dragdrop/drag_drop_types.h" 15 #include "ui/base/dragdrop/drag_drop_types.h"
17 #include "ui/base/dragdrop/os_exchange_data.h" 16 #include "ui/base/dragdrop/os_exchange_data.h"
17 #include "ui/base/event.h"
18 #include "ui/views/events/event.h" 18 #include "ui/views/events/event.h"
19 #include "ui/views/test/test_views_delegate.h" 19 #include "ui/views/test/test_views_delegate.h"
20 #include "ui/views/view.h" 20 #include "ui/views/view.h"
21 #include "ui/views/views_delegate.h" 21 #include "ui/views/views_delegate.h"
22 #include "ui/views/widget/native_widget_aura.h" 22 #include "ui/views/widget/native_widget_aura.h"
23 #include "ui/views/widget/native_widget_delegate.h" 23 #include "ui/views/widget/native_widget_delegate.h"
24 #include "ui/views/widget/widget.h" 24 #include "ui/views/widget/widget.h"
25 25
26 namespace ash { 26 namespace ash {
27 namespace test { 27 namespace test {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 private: 129 private:
130 int StartDragAndDrop(const ui::OSExchangeData& data, 130 int StartDragAndDrop(const ui::OSExchangeData& data,
131 const gfx::Point& location, 131 const gfx::Point& location,
132 int operation) OVERRIDE { 132 int operation) OVERRIDE {
133 drag_start_received_ = true; 133 drag_start_received_ = true;
134 data.GetString(&drag_string_); 134 data.GetString(&drag_string_);
135 return DragDropController::StartDragAndDrop(data, location, operation); 135 return DragDropController::StartDragAndDrop(data, location, operation);
136 } 136 }
137 137
138 void DragUpdate(aura::Window* target, 138 void DragUpdate(aura::Window* target,
139 const aura::LocatedEvent& event) OVERRIDE { 139 const ui::LocatedEvent& event) OVERRIDE {
140 DragDropController::DragUpdate(target, event); 140 DragDropController::DragUpdate(target, event);
141 num_drag_updates_++; 141 num_drag_updates_++;
142 } 142 }
143 143
144 void Drop(aura::Window* target, const aura::LocatedEvent& event) OVERRIDE { 144 void Drop(aura::Window* target, const ui::LocatedEvent& event) OVERRIDE {
145 DragDropController::Drop(target, event); 145 DragDropController::Drop(target, event);
146 drop_received_ = true; 146 drop_received_ = true;
147 } 147 }
148 148
149 void DragCancel() OVERRIDE { 149 void DragCancel() OVERRIDE {
150 DragDropController::DragCancel(); 150 DragDropController::DragCancel();
151 drag_canceled_ = true; 151 drag_canceled_ = true;
152 } 152 }
153 153
154 DISALLOW_COPY_AND_ASSIGN(TestDragDropController); 154 DISALLOW_COPY_AND_ASSIGN(TestDragDropController);
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 599 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
600 // drag_data_ to a fake drag data object that we created. 600 // drag_data_ to a fake drag data object that we created.
601 if (i > 0) 601 if (i > 0)
602 UpdateDragData(&data); 602 UpdateDragData(&data);
603 generator.MoveMouseBy(0, 1); 603 generator.MoveMouseBy(0, 1);
604 604
605 // We send a unexpected mouse move event. Note that we cannot use 605 // We send a unexpected mouse move event. Note that we cannot use
606 // EventGenerator since it implicitly turns these into mouse drag events. 606 // EventGenerator since it implicitly turns these into mouse drag events.
607 // The DragDropController should simply ignore these events. 607 // The DragDropController should simply ignore these events.
608 gfx::Point mouse_move_location = drag_view->bounds().CenterPoint(); 608 gfx::Point mouse_move_location = drag_view->bounds().CenterPoint();
609 aura::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, 609 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, mouse_move_location,
610 mouse_move_location, mouse_move_location, 0); 610 mouse_move_location, 0);
611 Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()->OnHostMouseEvent( 611 Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()->OnHostMouseEvent(
612 &mouse_move); 612 &mouse_move);
613 } 613 }
614 614
615 generator.ReleaseLeftButton(); 615 generator.ReleaseLeftButton();
616 616
617 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 617 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
618 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(), 618 EXPECT_EQ(num_drags - 1 - drag_view->VerticalDragThreshold(),
619 drag_drop_controller_->num_drag_updates_); 619 drag_drop_controller_->num_drag_updates_);
620 EXPECT_TRUE(drag_drop_controller_->drop_received_); 620 EXPECT_TRUE(drag_drop_controller_->drop_received_);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 } // namespace test 674 } // namespace test
675 } // namespace aura 675 } // namespace aura
OLDNEW
« no previous file with comments | « ash/drag_drop/drag_drop_controller.cc ('k') | ash/event_rewriter_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698