OLD | NEW |
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 <set> | 5 #include <set> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 bad_data.SetPickledData(fmt, Pickle()); | 927 bad_data.SetPickledData(fmt, Pickle()); |
928 bad_data.SetFileContents(base::FilePath(L"x"), "x"); | 928 bad_data.SetFileContents(base::FilePath(L"x"), "x"); |
929 bad_data.SetHtml(string16(ASCIIToUTF16("x")), GURL("x.org")); | 929 bad_data.SetHtml(string16(ASCIIToUTF16("x")), GURL("x.org")); |
930 ui::OSExchangeData::DownloadFileInfo download(base::FilePath(), NULL); | 930 ui::OSExchangeData::DownloadFileInfo download(base::FilePath(), NULL); |
931 bad_data.SetDownloadFileInfo(download); | 931 bad_data.SetDownloadFileInfo(download); |
932 #endif | 932 #endif |
933 EXPECT_FALSE(textfield_view_->CanDrop(bad_data)); | 933 EXPECT_FALSE(textfield_view_->CanDrop(bad_data)); |
934 } | 934 } |
935 #endif | 935 #endif |
936 | 936 |
937 // TODO(erg): Disabled while the other half of drag and drop is being written. | 937 TEST_F(NativeTextfieldViewsTest, DragAndDrop_InitiateDrag) { |
938 // http://crbug.com/130806 | |
939 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
940 #define MAYBE_DragAndDrop_InitiateDrag DISABLED_DragAndDrop_InitiateDrag | |
941 #else | |
942 #define MAYBE_DragAndDrop_InitiateDrag DragAndDrop_InitiateDrag | |
943 #endif | |
944 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_InitiateDrag) { | |
945 InitTextfield(Textfield::STYLE_DEFAULT); | 938 InitTextfield(Textfield::STYLE_DEFAULT); |
946 textfield_->SetText(ASCIIToUTF16("hello string world")); | 939 textfield_->SetText(ASCIIToUTF16("hello string world")); |
947 | 940 |
948 // Ensure the textfield will provide selected text for drag data. | 941 // Ensure the textfield will provide selected text for drag data. |
949 string16 string; | 942 string16 string; |
950 ui::OSExchangeData data; | 943 ui::OSExchangeData data; |
951 const ui::Range kStringRange(6, 12); | 944 const ui::Range kStringRange(6, 12); |
952 textfield_->SelectRange(kStringRange); | 945 textfield_->SelectRange(kStringRange); |
953 const gfx::Point kStringPoint(GetCursorPositionX(9), 0); | 946 const gfx::Point kStringPoint(GetCursorPositionX(9), 0); |
954 textfield_view_->WriteDragDataForView(NULL, kStringPoint, &data); | 947 textfield_view_->WriteDragDataForView(NULL, kStringPoint, &data); |
(...skipping 25 matching lines...) Expand all Loading... |
980 gfx::Point())); | 973 gfx::Point())); |
981 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, | 974 EXPECT_EQ(ui::DragDropTypes::DRAG_COPY, |
982 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); | 975 textfield_view_->GetDragOperationsForView(NULL, kStringPoint)); |
983 EXPECT_TRUE(textfield_view_->CanStartDragForView(NULL, kStringPoint, | 976 EXPECT_TRUE(textfield_view_->CanStartDragForView(NULL, kStringPoint, |
984 gfx::Point())); | 977 gfx::Point())); |
985 // Ensure that textfields support local moves. | 978 // Ensure that textfields support local moves. |
986 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY, | 979 EXPECT_EQ(ui::DragDropTypes::DRAG_MOVE | ui::DragDropTypes::DRAG_COPY, |
987 textfield_view_->GetDragOperationsForView(textfield_view_, kStringPoint)); | 980 textfield_view_->GetDragOperationsForView(textfield_view_, kStringPoint)); |
988 } | 981 } |
989 | 982 |
990 // TODO(erg): Disabled while the other half of drag and drop is being written. | 983 TEST_F(NativeTextfieldViewsTest, DragAndDrop_ToTheRight) { |
991 // http://crbug.com/130806 | |
992 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
993 #define MAYBE_DragAndDrop_ToTheRight DISABLED_DragAndDrop_ToTheRight | |
994 #else | |
995 #define MAYBE_DragAndDrop_ToTheRight DragAndDrop_ToTheRight | |
996 #endif | |
997 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_ToTheRight) { | |
998 InitTextfield(Textfield::STYLE_DEFAULT); | 984 InitTextfield(Textfield::STYLE_DEFAULT); |
999 textfield_->SetText(ASCIIToUTF16("hello world")); | 985 textfield_->SetText(ASCIIToUTF16("hello world")); |
1000 | 986 |
1001 string16 string; | 987 string16 string; |
1002 ui::OSExchangeData data; | 988 ui::OSExchangeData data; |
1003 int formats = 0; | 989 int formats = 0; |
1004 int operations = 0; | 990 int operations = 0; |
1005 std::set<OSExchangeData::CustomFormat> custom_formats; | 991 std::set<OSExchangeData::CustomFormat> custom_formats; |
1006 | 992 |
1007 // Start dragging "ello". | 993 // Start dragging "ello". |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 SendKeyEvent(ui::VKEY_Z, false, true); | 1028 SendKeyEvent(ui::VKEY_Z, false, true); |
1043 EXPECT_STR_EQ("", textfield_->text()); | 1029 EXPECT_STR_EQ("", textfield_->text()); |
1044 SendKeyEvent(ui::VKEY_Y, false, true); | 1030 SendKeyEvent(ui::VKEY_Y, false, true); |
1045 EXPECT_STR_EQ("hello world", textfield_->text()); | 1031 EXPECT_STR_EQ("hello world", textfield_->text()); |
1046 SendKeyEvent(ui::VKEY_Y, false, true); | 1032 SendKeyEvent(ui::VKEY_Y, false, true); |
1047 EXPECT_STR_EQ("h welloorld", textfield_->text()); | 1033 EXPECT_STR_EQ("h welloorld", textfield_->text()); |
1048 SendKeyEvent(ui::VKEY_Y, false, true); | 1034 SendKeyEvent(ui::VKEY_Y, false, true); |
1049 EXPECT_STR_EQ("h welloorld", textfield_->text()); | 1035 EXPECT_STR_EQ("h welloorld", textfield_->text()); |
1050 } | 1036 } |
1051 | 1037 |
1052 // TODO(erg): Disabled while the other half of drag and drop is being written. | 1038 TEST_F(NativeTextfieldViewsTest, DragAndDrop_ToTheLeft) { |
1053 // http://crbug.com/130806 | |
1054 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
1055 #define MAYBE_DragAndDrop_ToTheLeft DISABLED_DragAndDrop_ToTheLeft | |
1056 #else | |
1057 #define MAYBE_DragAndDrop_ToTheLeft DragAndDrop_ToTheLeft | |
1058 #endif | |
1059 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_ToTheLeft) { | |
1060 InitTextfield(Textfield::STYLE_DEFAULT); | 1039 InitTextfield(Textfield::STYLE_DEFAULT); |
1061 textfield_->SetText(ASCIIToUTF16("hello world")); | 1040 textfield_->SetText(ASCIIToUTF16("hello world")); |
1062 | 1041 |
1063 string16 string; | 1042 string16 string; |
1064 ui::OSExchangeData data; | 1043 ui::OSExchangeData data; |
1065 int formats = 0; | 1044 int formats = 0; |
1066 int operations = 0; | 1045 int operations = 0; |
1067 std::set<OSExchangeData::CustomFormat> custom_formats; | 1046 std::set<OSExchangeData::CustomFormat> custom_formats; |
1068 | 1047 |
1069 // Start dragging " worl". | 1048 // Start dragging " worl". |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1104 SendKeyEvent(ui::VKEY_Z, false, true); | 1083 SendKeyEvent(ui::VKEY_Z, false, true); |
1105 EXPECT_STR_EQ("", textfield_->text()); | 1084 EXPECT_STR_EQ("", textfield_->text()); |
1106 SendKeyEvent(ui::VKEY_Y, false, true); | 1085 SendKeyEvent(ui::VKEY_Y, false, true); |
1107 EXPECT_STR_EQ("hello world", textfield_->text()); | 1086 EXPECT_STR_EQ("hello world", textfield_->text()); |
1108 SendKeyEvent(ui::VKEY_Y, false, true); | 1087 SendKeyEvent(ui::VKEY_Y, false, true); |
1109 EXPECT_STR_EQ("h worlellod", textfield_->text()); | 1088 EXPECT_STR_EQ("h worlellod", textfield_->text()); |
1110 SendKeyEvent(ui::VKEY_Y, false, true); | 1089 SendKeyEvent(ui::VKEY_Y, false, true); |
1111 EXPECT_STR_EQ("h worlellod", textfield_->text()); | 1090 EXPECT_STR_EQ("h worlellod", textfield_->text()); |
1112 } | 1091 } |
1113 | 1092 |
1114 // TODO(erg): Disabled while the other half of drag and drop is being written. | 1093 TEST_F(NativeTextfieldViewsTest, DragAndDrop_Canceled) { |
1115 // http://crbug.com/130806 | |
1116 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
1117 #define MAYBE_DragAndDrop_Canceled DISABLED_DragAndDrop_Canceled | |
1118 #else | |
1119 #define MAYBE_DragAndDrop_Canceled DragAndDrop_Canceled | |
1120 #endif | |
1121 TEST_F(NativeTextfieldViewsTest, MAYBE_DragAndDrop_Canceled) { | |
1122 InitTextfield(Textfield::STYLE_DEFAULT); | 1094 InitTextfield(Textfield::STYLE_DEFAULT); |
1123 textfield_->SetText(ASCIIToUTF16("hello world")); | 1095 textfield_->SetText(ASCIIToUTF16("hello world")); |
1124 | 1096 |
1125 // Start dragging "worl". | 1097 // Start dragging "worl". |
1126 textfield_->SelectRange(ui::Range(6, 10)); | 1098 textfield_->SelectRange(ui::Range(6, 10)); |
1127 gfx::Point point(GetCursorPositionX(8), 0); | 1099 gfx::Point point(GetCursorPositionX(8), 0); |
1128 ui::MouseEvent click(ui::ET_MOUSE_PRESSED, point, point, | 1100 ui::MouseEvent click(ui::ET_MOUSE_PRESSED, point, point, |
1129 ui::EF_LEFT_MOUSE_BUTTON); | 1101 ui::EF_LEFT_MOUSE_BUTTON); |
1130 textfield_view_->OnMousePressed(click); | 1102 textfield_view_->OnMousePressed(click); |
1131 ui::OSExchangeData data; | 1103 ui::OSExchangeData data; |
(...skipping 789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1921 textfield_view_->OnGestureEvent(&tap_down); | 1893 textfield_view_->OnGestureEvent(&tap_down); |
1922 // Create a new long press event since the previous one is not marked handled. | 1894 // Create a new long press event since the previous one is not marked handled. |
1923 GestureEventForTest long_press2(ui::ET_GESTURE_LONG_PRESS, eventX, eventY, 0); | 1895 GestureEventForTest long_press2(ui::ET_GESTURE_LONG_PRESS, eventX, eventY, 0); |
1924 textfield_view_->OnGestureEvent(&long_press2); | 1896 textfield_view_->OnGestureEvent(&long_press2); |
1925 EXPECT_STR_EQ("hello", textfield_->GetSelectedText()); | 1897 EXPECT_STR_EQ("hello", textfield_->GetSelectedText()); |
1926 EXPECT_FALSE(GetTouchSelectionController()); | 1898 EXPECT_FALSE(GetTouchSelectionController()); |
1927 } | 1899 } |
1928 #endif | 1900 #endif |
1929 | 1901 |
1930 } // namespace views | 1902 } // namespace views |
OLD | NEW |