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

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

Issue 1372253002: gfx: Make conversions from gfx::Point to PointF explicit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pointfconvert-gfx: . Created 5 years, 2 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
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/drag_drop/drag_drop_tracker.h" 7 #include "ash/drag_drop/drag_drop_tracker.h"
8 #include "ash/drag_drop/drag_image_view.h" 8 #include "ash/drag_drop/drag_image_view.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 views::View* contents_view = widget->GetContentsView(); 255 views::View* contents_view = widget->GetContentsView();
256 contents_view->AddChildView(view); 256 contents_view->AddChildView(view);
257 view->SetBounds(contents_view->width(), 0, 100, 100); 257 view->SetBounds(contents_view->width(), 0, 100, 100);
258 gfx::Rect contents_view_bounds = contents_view->bounds(); 258 gfx::Rect contents_view_bounds = contents_view->bounds();
259 contents_view_bounds.Union(view->bounds()); 259 contents_view_bounds.Union(view->bounds());
260 contents_view->SetBoundsRect(contents_view_bounds); 260 contents_view->SetBoundsRect(contents_view_bounds);
261 widget->SetBounds(contents_view_bounds); 261 widget->SetBounds(contents_view_bounds);
262 } 262 }
263 263
264 void DispatchGesture(ui::EventType gesture_type, gfx::Point location) { 264 void DispatchGesture(ui::EventType gesture_type, const gfx::PointF& location) {
265 ui::GestureEventDetails event_details(gesture_type); 265 ui::GestureEventDetails event_details(gesture_type);
266 event_details.set_oldest_touch_id(1); 266 event_details.set_oldest_touch_id(1);
267 ui::GestureEvent gesture_event( 267 ui::GestureEvent gesture_event(
268 location.x(), location.y(), 0, ui::EventTimeForNow(), event_details); 268 location.x(), location.y(), 0, ui::EventTimeForNow(), event_details);
269 ui::EventSource* event_source = 269 ui::EventSource* event_source =
270 Shell::GetPrimaryRootWindow()->GetHost()->GetEventSource(); 270 Shell::GetPrimaryRootWindow()->GetHost()->GetEventSource();
271 ui::EventSourceTestApi event_source_test(event_source); 271 ui::EventSourceTestApi event_source_test(event_source);
272 ui::EventDispatchDetails details = 272 ui::EventDispatchDetails details =
273 event_source_test.SendEventToProcessor(&gesture_event); 273 event_source_test.SendEventToProcessor(&gesture_event);
274 CHECK(!details.dispatcher_destroyed); 274 CHECK(!details.dispatcher_destroyed);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 // TODO(win_aura) http://crbug.com/154081 555 // TODO(win_aura) http://crbug.com/154081
556 #if defined(OS_WIN) 556 #if defined(OS_WIN)
557 #define MAYBE_ViewRemovedWhileInDragDropTest DISABLED_ViewRemovedWhileInDragDrop Test 557 #define MAYBE_ViewRemovedWhileInDragDropTest DISABLED_ViewRemovedWhileInDragDrop Test
558 #else 558 #else
559 #define MAYBE_ViewRemovedWhileInDragDropTest ViewRemovedWhileInDragDropTest 559 #define MAYBE_ViewRemovedWhileInDragDropTest ViewRemovedWhileInDragDropTest
560 #endif 560 #endif
561 TEST_F(DragDropControllerTest, MAYBE_ViewRemovedWhileInDragDropTest) { 561 TEST_F(DragDropControllerTest, MAYBE_ViewRemovedWhileInDragDropTest) {
562 scoped_ptr<views::Widget> widget(CreateNewWidget()); 562 scoped_ptr<views::Widget> widget(CreateNewWidget());
563 scoped_ptr<DragTestView> drag_view(new DragTestView); 563 scoped_ptr<DragTestView> drag_view(new DragTestView);
564 AddViewToWidgetAndResize(widget.get(), drag_view.get()); 564 AddViewToWidgetAndResize(widget.get(), drag_view.get());
565 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint();
566 ui::OSExchangeData data; 565 ui::OSExchangeData data;
567 data.SetString(base::UTF8ToUTF16("I am being dragged")); 566 data.SetString(base::UTF8ToUTF16("I am being dragged"));
568 567
569 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 568 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
570 generator.MoveMouseToCenterOf(widget->GetNativeView()); 569 generator.MoveMouseToCenterOf(widget->GetNativeView());
571 generator.PressLeftButton(); 570 generator.PressLeftButton();
572 571
573 int num_drags_1 = 17; 572 int num_drags_1 = 17;
574 for (int i = 0; i < num_drags_1; ++i) { 573 for (int i = 0; i < num_drags_1; ++i) {
575 // Because we are not doing a blocking drag and drop, the original 574 // Because we are not doing a blocking drag and drop, the original
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 // OSDragExchangeData object is lost as soon as we return from the drag 711 // OSDragExchangeData object is lost as soon as we return from the drag
713 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 712 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
714 // drag_data_ to a fake drag data object that we created. 713 // drag_data_ to a fake drag data object that we created.
715 if (i > 0) 714 if (i > 0)
716 UpdateDragData(&data); 715 UpdateDragData(&data);
717 generator.MoveMouseBy(0, 1); 716 generator.MoveMouseBy(0, 1);
718 717
719 // We send a unexpected mouse move event. Note that we cannot use 718 // We send a unexpected mouse move event. Note that we cannot use
720 // EventGenerator since it implicitly turns these into mouse drag events. 719 // EventGenerator since it implicitly turns these into mouse drag events.
721 // The DragDropController should simply ignore these events. 720 // The DragDropController should simply ignore these events.
722 gfx::Point mouse_move_location = drag_view->bounds().CenterPoint(); 721 auto mouse_move_location = gfx::PointF(drag_view->bounds().CenterPoint());
723 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, mouse_move_location, 722 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, mouse_move_location,
724 mouse_move_location, ui::EventTimeForNow(), 0, 0); 723 mouse_move_location, ui::EventTimeForNow(), 0, 0);
725 ui::EventDispatchDetails details = Shell::GetPrimaryRootWindow()-> 724 ui::EventDispatchDetails details = Shell::GetPrimaryRootWindow()->
726 GetHost()->event_processor()->OnEventFromSource(&mouse_move); 725 GetHost()->event_processor()->OnEventFromSource(&mouse_move);
727 ASSERT_FALSE(details.dispatcher_destroyed); 726 ASSERT_FALSE(details.dispatcher_destroyed);
728 } 727 }
729 728
730 generator.ReleaseLeftButton(); 729 generator.ReleaseLeftButton();
731 730
732 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 731 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
858 gfx::Rect widget2_bounds = widget2->GetClientAreaBoundsInScreen(); 857 gfx::Rect widget2_bounds = widget2->GetClientAreaBoundsInScreen();
859 widget2->SetBounds(gfx::Rect(widget1_bounds.width(), 0, 858 widget2->SetBounds(gfx::Rect(widget1_bounds.width(), 0,
860 widget2_bounds.width(), widget2_bounds.height())); 859 widget2_bounds.width(), widget2_bounds.height()));
861 860
862 ui::OSExchangeData data; 861 ui::OSExchangeData data;
863 data.SetString(base::UTF8ToUTF16("I am being dragged")); 862 data.SetString(base::UTF8ToUTF16("I am being dragged"));
864 863
865 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 864 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
866 widget1->GetNativeView()); 865 widget1->GetNativeView());
867 generator.PressTouch(); 866 generator.PressTouch();
868 gfx::Point point = gfx::Rect(drag_view1->bounds()).CenterPoint(); 867 auto point = gfx::PointF(gfx::Rect(drag_view1->bounds()).CenterPoint());
869 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point); 868 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point);
870 // Because we are not doing a blocking drag and drop, the original 869 // Because we are not doing a blocking drag and drop, the original
871 // OSDragExchangeData object is lost as soon as we return from the drag 870 // OSDragExchangeData object is lost as soon as we return from the drag
872 // initiation in DragDropController::StartDragAndDrop(). Hence we set the 871 // initiation in DragDropController::StartDragAndDrop(). Hence we set the
873 // drag_data_ to a fake drag data object that we created. 872 // drag_data_ to a fake drag data object that we created.
874 UpdateDragData(&data); 873 UpdateDragData(&data);
875 gfx::Point gesture_location = point; 874 gfx::PointF gesture_location = point;
876 int num_drags = drag_view1->width(); 875 int num_drags = drag_view1->width();
877 for (int i = 0; i < num_drags; ++i) { 876 for (int i = 0; i < num_drags; ++i) {
878 gesture_location.Offset(1, 0); 877 gesture_location.Offset(1.f, 0.f);
879 DispatchGesture(ui::ET_GESTURE_SCROLL_UPDATE, gesture_location); 878 DispatchGesture(ui::ET_GESTURE_SCROLL_UPDATE, gesture_location);
880 879
881 // Execute any scheduled draws to process deferred mouse events. 880 // Execute any scheduled draws to process deferred mouse events.
882 RunAllPendingInMessageLoop(); 881 RunAllPendingInMessageLoop();
883 } 882 }
884 883
885 DispatchGesture(ui::ET_GESTURE_SCROLL_END, gesture_location); 884 DispatchGesture(ui::ET_GESTURE_SCROLL_END, gesture_location);
886 885
887 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 886 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
888 EXPECT_EQ(num_drags, drag_drop_controller_->num_drag_updates_); 887 EXPECT_EQ(num_drags, drag_drop_controller_->num_drag_updates_);
(...skipping 20 matching lines...) Expand all
909 TEST_F(DragDropControllerTest, TouchDragDropCancelsOnLongTap) { 908 TEST_F(DragDropControllerTest, TouchDragDropCancelsOnLongTap) {
910 base::CommandLine::ForCurrentProcess()->AppendSwitch( 909 base::CommandLine::ForCurrentProcess()->AppendSwitch(
911 switches::kEnableTouchDragDrop); 910 switches::kEnableTouchDragDrop);
912 scoped_ptr<views::Widget> widget(CreateNewWidget()); 911 scoped_ptr<views::Widget> widget(CreateNewWidget());
913 DragTestView* drag_view = new DragTestView; 912 DragTestView* drag_view = new DragTestView;
914 AddViewToWidgetAndResize(widget.get(), drag_view); 913 AddViewToWidgetAndResize(widget.get(), drag_view);
915 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 914 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
916 widget->GetNativeView()); 915 widget->GetNativeView());
917 916
918 generator.PressTouch(); 917 generator.PressTouch();
919 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); 918 auto point = gfx::PointF(gfx::Rect(drag_view->bounds()).CenterPoint());
920 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point); 919 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point);
921 DispatchGesture(ui::ET_GESTURE_LONG_TAP, point); 920 DispatchGesture(ui::ET_GESTURE_LONG_TAP, point);
922 921
923 EXPECT_TRUE(drag_drop_controller_->drag_start_received_); 922 EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
924 EXPECT_TRUE(drag_drop_controller_->drag_canceled_); 923 EXPECT_TRUE(drag_drop_controller_->drag_canceled_);
925 EXPECT_EQ(0, drag_drop_controller_->num_drag_updates_); 924 EXPECT_EQ(0, drag_drop_controller_->num_drag_updates_);
926 EXPECT_FALSE(drag_drop_controller_->drop_received_); 925 EXPECT_FALSE(drag_drop_controller_->drop_received_);
927 EXPECT_EQ(base::UTF8ToUTF16("I am being dragged"), 926 EXPECT_EQ(base::UTF8ToUTF16("I am being dragged"),
928 drag_drop_controller_->drag_string_); 927 drag_drop_controller_->drag_string_);
929 EXPECT_EQ(0, drag_view->num_drag_enters_); 928 EXPECT_EQ(0, drag_view->num_drag_enters_);
930 EXPECT_EQ(0, drag_view->num_drops_); 929 EXPECT_EQ(0, drag_view->num_drops_);
931 EXPECT_EQ(0, drag_view->num_drag_exits_); 930 EXPECT_EQ(0, drag_view->num_drag_exits_);
932 EXPECT_TRUE(drag_view->drag_done_received_); 931 EXPECT_TRUE(drag_view->drag_done_received_);
933 } 932 }
934 933
935 TEST_F(DragDropControllerTest, TouchDragDropLongTapGestureIsForwarded) { 934 TEST_F(DragDropControllerTest, TouchDragDropLongTapGestureIsForwarded) {
936 base::CommandLine::ForCurrentProcess()->AppendSwitch( 935 base::CommandLine::ForCurrentProcess()->AppendSwitch(
937 switches::kEnableTouchDragDrop); 936 switches::kEnableTouchDragDrop);
938 scoped_ptr<views::Widget> widget(CreateNewWidget()); 937 scoped_ptr<views::Widget> widget(CreateNewWidget());
939 DragTestView* drag_view = new DragTestView; 938 DragTestView* drag_view = new DragTestView;
940 AddViewToWidgetAndResize(widget.get(), drag_view); 939 AddViewToWidgetAndResize(widget.get(), drag_view);
941 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 940 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
942 widget->GetNativeView()); 941 widget->GetNativeView());
943 942
944 generator.PressTouch(); 943 generator.PressTouch();
945 gfx::Point point = gfx::Rect(drag_view->bounds()).CenterPoint(); 944 auto point = gfx::PointF(gfx::Rect(drag_view->bounds()).CenterPoint());
946 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point); 945 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, point);
947 946
948 // Since we are not running inside a nested loop, the |drag_source_window_| 947 // Since we are not running inside a nested loop, the |drag_source_window_|
949 // will get destroyed immediately. Hence we reassign it. 948 // will get destroyed immediately. Hence we reassign it.
950 EXPECT_EQ(NULL, GetDragSourceWindow()); 949 EXPECT_EQ(NULL, GetDragSourceWindow());
951 SetDragSourceWindow(widget->GetNativeView()); 950 SetDragSourceWindow(widget->GetNativeView());
952 EXPECT_FALSE(drag_view->long_tap_received_); 951 EXPECT_FALSE(drag_view->long_tap_received_);
953 DispatchGesture(ui::ET_GESTURE_LONG_TAP, point); 952 DispatchGesture(ui::ET_GESTURE_LONG_TAP, point);
954 CompleteCancelAnimation(); 953 CompleteCancelAnimation();
955 EXPECT_TRUE(drag_view->long_tap_received_); 954 EXPECT_TRUE(drag_view->long_tap_received_);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 window, 997 window,
999 gfx::Point(5, 5), 998 gfx::Point(5, 5),
1000 ui::DragDropTypes::DRAG_MOVE, 999 ui::DragDropTypes::DRAG_MOVE,
1001 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 1000 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
1002 1001
1003 DragImageWindowObserver observer; 1002 DragImageWindowObserver observer;
1004 ASSERT_TRUE(GetDragImageWindow()); 1003 ASSERT_TRUE(GetDragImageWindow());
1005 GetDragImageWindow()->AddObserver(&observer); 1004 GetDragImageWindow()->AddObserver(&observer);
1006 1005
1007 { 1006 {
1008 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), 1007 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::PointF(200.f, 0.f),
1009 gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, 1008 gfx::PointF(200.f, 0.f), ui::EventTimeForNow(),
1010 ui::EF_NONE); 1009 ui::EF_NONE, ui::EF_NONE);
1011 drag_drop_controller_->DragUpdate(window, e); 1010 drag_drop_controller_->DragUpdate(window, e);
1012 } 1011 }
1013 { 1012 {
1014 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), 1013 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::PointF(600.f, 0.f),
1015 gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, 1014 gfx::PointF(600.f, 0.f), ui::EventTimeForNow(),
1016 ui::EF_NONE); 1015 ui::EF_NONE, ui::EF_NONE);
1017 drag_drop_controller_->DragUpdate(window, e); 1016 drag_drop_controller_->DragUpdate(window, e);
1018 } 1017 }
1019 1018
1020 drag_drop_controller_->DragCancel(); 1019 drag_drop_controller_->DragCancel();
1021 CompleteCancelAnimation(); 1020 CompleteCancelAnimation();
1022 1021
1023 EXPECT_EQ("5,5", observer.window_location_on_destroying().ToString()); 1022 EXPECT_EQ("5,5", observer.window_location_on_destroying().ToString());
1024 } 1023 }
1025 1024
1026 { 1025 {
1027 scoped_ptr<views::Widget> widget(CreateNewWidget()); 1026 scoped_ptr<views::Widget> widget(CreateNewWidget());
1028 aura::Window* window = widget->GetNativeWindow(); 1027 aura::Window* window = widget->GetNativeWindow();
1029 drag_drop_controller_->StartDragAndDrop( 1028 drag_drop_controller_->StartDragAndDrop(
1030 data, 1029 data,
1031 window->GetRootWindow(), 1030 window->GetRootWindow(),
1032 window, 1031 window,
1033 gfx::Point(405, 405), 1032 gfx::Point(405, 405),
1034 ui::DragDropTypes::DRAG_MOVE, 1033 ui::DragDropTypes::DRAG_MOVE,
1035 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 1034 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
1036 DragImageWindowObserver observer; 1035 DragImageWindowObserver observer;
1037 ASSERT_TRUE(GetDragImageWindow()); 1036 ASSERT_TRUE(GetDragImageWindow());
1038 GetDragImageWindow()->AddObserver(&observer); 1037 GetDragImageWindow()->AddObserver(&observer);
1039 1038
1040 { 1039 {
1041 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(600, 0), 1040 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::PointF(600.f, 0.f),
1042 gfx::Point(600, 0), ui::EventTimeForNow(), ui::EF_NONE, 1041 gfx::PointF(600.f, 0.f), ui::EventTimeForNow(),
1043 ui::EF_NONE); 1042 ui::EF_NONE, ui::EF_NONE);
1044 drag_drop_controller_->DragUpdate(window, e); 1043 drag_drop_controller_->DragUpdate(window, e);
1045 } 1044 }
1046 { 1045 {
1047 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::Point(200, 0), 1046 ui::MouseEvent e(ui::ET_MOUSE_DRAGGED, gfx::PointF(200.f, 0.f),
1048 gfx::Point(200, 0), ui::EventTimeForNow(), ui::EF_NONE, 1047 gfx::PointF(200.f, 0.f), ui::EventTimeForNow(),
1049 ui::EF_NONE); 1048 ui::EF_NONE, ui::EF_NONE);
1050 drag_drop_controller_->DragUpdate(window, e); 1049 drag_drop_controller_->DragUpdate(window, e);
1051 } 1050 }
1052 1051
1053 drag_drop_controller_->DragCancel(); 1052 drag_drop_controller_->DragCancel();
1054 CompleteCancelAnimation(); 1053 CompleteCancelAnimation();
1055 1054
1056 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString()); 1055 EXPECT_EQ("405,405", observer.window_location_on_destroying().ToString());
1057 } 1056 }
1058 for (aura::Window::Windows::iterator iter = root_windows.begin(); 1057 for (aura::Window::Windows::iterator iter = root_windows.begin();
1059 iter != root_windows.end(); ++iter) { 1058 iter != root_windows.end(); ++iter) {
1060 aura::client::SetDragDropClient(*iter, NULL); 1059 aura::client::SetDragDropClient(*iter, NULL);
1061 } 1060 }
1062 } 1061 }
1063 1062
1064 TEST_F(DragDropControllerTest, TouchDragDropCompletesOnFling) { 1063 TEST_F(DragDropControllerTest, TouchDragDropCompletesOnFling) {
1065 base::CommandLine::ForCurrentProcess()->AppendSwitch( 1064 base::CommandLine::ForCurrentProcess()->AppendSwitch(
1066 switches::kEnableTouchDragDrop); 1065 switches::kEnableTouchDragDrop);
1067 ui::GestureConfiguration::GetInstance() 1066 ui::GestureConfiguration::GetInstance()
1068 ->set_max_touch_move_in_pixels_for_click(1); 1067 ->set_max_touch_move_in_pixels_for_click(1);
1069 scoped_ptr<views::Widget> widget(CreateNewWidget()); 1068 scoped_ptr<views::Widget> widget(CreateNewWidget());
1070 DragTestView* drag_view = new DragTestView; 1069 DragTestView* drag_view = new DragTestView;
1071 AddViewToWidgetAndResize(widget.get(), drag_view); 1070 AddViewToWidgetAndResize(widget.get(), drag_view);
1072 ui::OSExchangeData data; 1071 ui::OSExchangeData data;
1073 data.SetString(base::UTF8ToUTF16("I am being dragged")); 1072 data.SetString(base::UTF8ToUTF16("I am being dragged"));
1074 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 1073 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
1075 widget->GetNativeView()); 1074 widget->GetNativeView());
1076 1075
1077 gfx::Point start = gfx::Rect(drag_view->bounds()).CenterPoint(); 1076 auto start = gfx::PointF(gfx::Rect(drag_view->bounds()).CenterPoint());
1078 gfx::Point mid = start + gfx::Vector2d(drag_view->bounds().width() / 6, 0); 1077 gfx::PointF mid =
1079 gfx::Point end = start + gfx::Vector2d(drag_view->bounds().width() / 3, 0); 1078 start + gfx::Vector2dF(drag_view->bounds().width() / 6.f, 0.f);
1079 gfx::PointF end =
1080 start + gfx::Vector2dF(drag_view->bounds().width() / 3.f, 0.f);
1080 1081
1081 base::TimeDelta timestamp = ui::EventTimeForNow(); 1082 base::TimeDelta timestamp = ui::EventTimeForNow();
1082 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, 0, timestamp); 1083 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, 0, timestamp);
1083 generator.Dispatch(&press); 1084 generator.Dispatch(&press);
1084 1085
1085 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, start); 1086 DispatchGesture(ui::ET_GESTURE_LONG_PRESS, start);
1086 UpdateDragData(&data); 1087 UpdateDragData(&data);
1087 timestamp += base::TimeDelta::FromMilliseconds(10); 1088 timestamp += base::TimeDelta::FromMilliseconds(10);
1088 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, mid, 0, timestamp); 1089 ui::TouchEvent move1(ui::ET_TOUCH_MOVED, mid, 0, timestamp);
1089 generator.Dispatch(&move1); 1090 generator.Dispatch(&move1);
(...skipping 13 matching lines...) Expand all
1103 drag_drop_controller_->drag_string_); 1104 drag_drop_controller_->drag_string_);
1104 EXPECT_EQ(1, drag_view->num_drag_enters_); 1105 EXPECT_EQ(1, drag_view->num_drag_enters_);
1105 EXPECT_EQ(2, drag_view->num_drag_updates_); 1106 EXPECT_EQ(2, drag_view->num_drag_updates_);
1106 EXPECT_EQ(1, drag_view->num_drops_); 1107 EXPECT_EQ(1, drag_view->num_drops_);
1107 EXPECT_EQ(0, drag_view->num_drag_exits_); 1108 EXPECT_EQ(0, drag_view->num_drag_exits_);
1108 EXPECT_TRUE(drag_view->drag_done_received_); 1109 EXPECT_TRUE(drag_view->drag_done_received_);
1109 } 1110 }
1110 1111
1111 } // namespace test 1112 } // namespace test
1112 } // namespace ash 1113 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698