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

Side by Side Diff: ui/views/controls/textfield/textfield_unittest.cc

Issue 139983009: ui::LocatedEvent location() returns gfx::PointF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo accidental change. Created 6 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/views/controls/textfield/textfield.h" 5 #include "ui/views/controls/textfield/textfield.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after
866 int formats = 0; 866 int formats = 0;
867 int operations = 0; 867 int operations = 0;
868 std::set<OSExchangeData::CustomFormat> custom_formats; 868 std::set<OSExchangeData::CustomFormat> custom_formats;
869 869
870 // Start dragging "ello". 870 // Start dragging "ello".
871 textfield_->SelectRange(gfx::Range(1, 5)); 871 textfield_->SelectRange(gfx::Range(1, 5));
872 gfx::Point point(GetCursorPositionX(3), 0); 872 gfx::Point point(GetCursorPositionX(3), 0);
873 ui::MouseEvent click_a(ui::ET_MOUSE_PRESSED, point, point, 873 ui::MouseEvent click_a(ui::ET_MOUSE_PRESSED, point, point,
874 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 874 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
875 textfield_->OnMousePressed(click_a); 875 textfield_->OnMousePressed(click_a);
876 EXPECT_TRUE(textfield_->CanStartDragForView(textfield_, click_a.location(), 876 EXPECT_TRUE(textfield_->CanStartDragForView(
877 gfx::Point())); 877 textfield_, gfx::ToFlooredPoint(click_a.location()), gfx::Point()));
878 operations = textfield_->GetDragOperationsForView(textfield_, 878 operations = textfield_->GetDragOperationsForView(
879 click_a.location()); 879 textfield_, gfx::ToFlooredPoint(click_a.location()));
880 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY, 880 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY,
881 operations); 881 operations);
882 textfield_->WriteDragDataForView(NULL, click_a.location(), &data); 882 textfield_->WriteDragDataForView(
883 NULL, gfx::ToFlooredPoint(click_a.location()), &data);
883 EXPECT_TRUE(data.GetString(&string)); 884 EXPECT_TRUE(data.GetString(&string));
884 EXPECT_EQ(textfield_->GetSelectedText(), string); 885 EXPECT_EQ(textfield_->GetSelectedText(), string);
885 EXPECT_TRUE(textfield_->GetDropFormats(&formats, &custom_formats)); 886 EXPECT_TRUE(textfield_->GetDropFormats(&formats, &custom_formats));
886 EXPECT_EQ(ui::OSExchangeData::STRING, formats); 887 EXPECT_EQ(ui::OSExchangeData::STRING, formats);
887 EXPECT_TRUE(custom_formats.empty()); 888 EXPECT_TRUE(custom_formats.empty());
888 889
889 // Drop "ello" after "w". 890 // Drop "ello" after "w".
890 const gfx::Point kDropPoint(GetCursorPositionX(7), 0); 891 const gfx::Point kDropPoint(GetCursorPositionX(7), 0);
891 EXPECT_TRUE(textfield_->CanDrop(data)); 892 EXPECT_TRUE(textfield_->CanDrop(data));
892 ui::DropTargetEvent drop_a(data, kDropPoint, kDropPoint, operations); 893 ui::DropTargetEvent drop_a(data, kDropPoint, kDropPoint, operations);
(...skipping 26 matching lines...) Expand all
919 int formats = 0; 920 int formats = 0;
920 int operations = 0; 921 int operations = 0;
921 std::set<OSExchangeData::CustomFormat> custom_formats; 922 std::set<OSExchangeData::CustomFormat> custom_formats;
922 923
923 // Start dragging " worl". 924 // Start dragging " worl".
924 textfield_->SelectRange(gfx::Range(5, 10)); 925 textfield_->SelectRange(gfx::Range(5, 10));
925 gfx::Point point(GetCursorPositionX(7), 0); 926 gfx::Point point(GetCursorPositionX(7), 0);
926 ui::MouseEvent click_a(ui::ET_MOUSE_PRESSED, point, point, 927 ui::MouseEvent click_a(ui::ET_MOUSE_PRESSED, point, point,
927 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 928 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
928 textfield_->OnMousePressed(click_a); 929 textfield_->OnMousePressed(click_a);
929 EXPECT_TRUE(textfield_->CanStartDragForView(textfield_, click_a.location(), 930 EXPECT_TRUE(textfield_->CanStartDragForView(
930 gfx::Point())); 931 textfield_, gfx::ToFlooredPoint(click_a.location()), gfx::Point()));
931 operations = textfield_->GetDragOperationsForView(textfield_, 932 operations = textfield_->GetDragOperationsForView(
932 click_a.location()); 933 textfield_, gfx::ToFlooredPoint(click_a.location()));
933 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY, 934 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY,
934 operations); 935 operations);
935 textfield_->WriteDragDataForView(NULL, click_a.location(), &data); 936 textfield_->WriteDragDataForView(
937 NULL, gfx::ToFlooredPoint(click_a.location()), &data);
936 EXPECT_TRUE(data.GetString(&string)); 938 EXPECT_TRUE(data.GetString(&string));
937 EXPECT_EQ(textfield_->GetSelectedText(), string); 939 EXPECT_EQ(textfield_->GetSelectedText(), string);
938 EXPECT_TRUE(textfield_->GetDropFormats(&formats, &custom_formats)); 940 EXPECT_TRUE(textfield_->GetDropFormats(&formats, &custom_formats));
939 EXPECT_EQ(ui::OSExchangeData::STRING, formats); 941 EXPECT_EQ(ui::OSExchangeData::STRING, formats);
940 EXPECT_TRUE(custom_formats.empty()); 942 EXPECT_TRUE(custom_formats.empty());
941 943
942 // Drop " worl" after "h". 944 // Drop " worl" after "h".
943 EXPECT_TRUE(textfield_->CanDrop(data)); 945 EXPECT_TRUE(textfield_->CanDrop(data));
944 gfx::Point drop_point(GetCursorPositionX(1), 0); 946 gfx::Point drop_point(GetCursorPositionX(1), 0);
945 ui::DropTargetEvent drop_a(data, drop_point, drop_point, operations); 947 ui::DropTargetEvent drop_a(data, drop_point, drop_point, operations);
(...skipping 21 matching lines...) Expand all
967 InitTextfield(); 969 InitTextfield();
968 textfield_->SetText(ASCIIToUTF16("hello world")); 970 textfield_->SetText(ASCIIToUTF16("hello world"));
969 971
970 // Start dragging "worl". 972 // Start dragging "worl".
971 textfield_->SelectRange(gfx::Range(6, 10)); 973 textfield_->SelectRange(gfx::Range(6, 10));
972 gfx::Point point(GetCursorPositionX(8), 0); 974 gfx::Point point(GetCursorPositionX(8), 0);
973 ui::MouseEvent click(ui::ET_MOUSE_PRESSED, point, point, 975 ui::MouseEvent click(ui::ET_MOUSE_PRESSED, point, point,
974 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON); 976 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
975 textfield_->OnMousePressed(click); 977 textfield_->OnMousePressed(click);
976 ui::OSExchangeData data; 978 ui::OSExchangeData data;
977 textfield_->WriteDragDataForView(NULL, click.location(), &data); 979 textfield_->WriteDragDataForView(
980 NULL, gfx::ToFlooredPoint(click.location()), &data);
978 EXPECT_TRUE(textfield_->CanDrop(data)); 981 EXPECT_TRUE(textfield_->CanDrop(data));
979 // Drag the text over somewhere valid, outside the current selection. 982 // Drag the text over somewhere valid, outside the current selection.
980 gfx::Point drop_point(GetCursorPositionX(2), 0); 983 gfx::Point drop_point(GetCursorPositionX(2), 0);
981 ui::DropTargetEvent drop(data, drop_point, drop_point, 984 ui::DropTargetEvent drop(data, drop_point, drop_point,
982 ui::DragDropTypes::DRAG_MOVE); 985 ui::DragDropTypes::DRAG_MOVE);
983 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE, textfield_->OnDragUpdated(drop)); 986 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE, textfield_->OnDragUpdated(drop));
984 // "Cancel" the drag, via move and release over the selection, and OnDragDone. 987 // "Cancel" the drag, via move and release over the selection, and OnDragDone.
985 gfx::Point drag_point(GetCursorPositionX(9), 0); 988 gfx::Point drag_point(GetCursorPositionX(9), 0);
986 ui::MouseEvent drag(ui::ET_MOUSE_DRAGGED, drag_point, drag_point, 989 ui::MouseEvent drag(ui::ET_MOUSE_DRAGGED, drag_point, drag_point,
987 ui::EF_LEFT_MOUSE_BUTTON, 0); 990 ui::EF_LEFT_MOUSE_BUTTON, 0);
(...skipping 998 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 // Set text which may fall back to a font which has taller baseline than 1989 // Set text which may fall back to a font which has taller baseline than
1987 // the default font. 1990 // the default font.
1988 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91")); 1991 textfield_->SetText(UTF8ToUTF16("\xE0\xB9\x91"));
1989 const int new_baseline = textfield_->GetBaseline(); 1992 const int new_baseline = textfield_->GetBaseline();
1990 1993
1991 // Regardless of the text, the baseline must be the same. 1994 // Regardless of the text, the baseline must be the same.
1992 EXPECT_EQ(new_baseline, old_baseline); 1995 EXPECT_EQ(new_baseline, old_baseline);
1993 } 1996 }
1994 1997
1995 } // namespace views 1998 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698