OLD | NEW |
---|---|
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 <string> | |
6 #include <vector> | |
7 | |
5 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
6 #include "base/bind.h" | 9 #include "base/bind.h" |
7 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
8 #include "base/callback.h" | 11 #include "base/callback.h" |
9 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
10 #include "base/pickle.h" | 13 #include "base/pickle.h" |
11 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
12 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "ui/base/clipboard/clipboard.h" | 17 #include "ui/base/clipboard/clipboard.h" |
15 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 18 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
16 #include "ui/base/dragdrop/drag_drop_types.h" | 19 #include "ui/base/dragdrop/drag_drop_types.h" |
17 #include "ui/base/keycodes/keyboard_codes.h" | 20 #include "ui/base/keycodes/keyboard_codes.h" |
21 #include "ui/base/l10n/l10n_util.h" | |
18 #include "ui/gfx/render_text.h" | 22 #include "ui/gfx/render_text.h" |
19 #include "views/controls/textfield/native_textfield_views.h" | 23 #include "views/controls/textfield/native_textfield_views.h" |
20 #include "views/controls/textfield/textfield.h" | 24 #include "views/controls/textfield/textfield.h" |
21 #include "views/controls/textfield/textfield_controller.h" | 25 #include "views/controls/textfield/textfield_controller.h" |
22 #include "views/controls/textfield/textfield_views_model.h" | 26 #include "views/controls/textfield/textfield_views_model.h" |
23 #include "views/events/event.h" | 27 #include "views/events/event.h" |
24 #include "views/focus/focus_manager.h" | 28 #include "views/focus/focus_manager.h" |
25 #include "views/ime/mock_input_method.h" | 29 #include "views/ime/mock_input_method.h" |
26 #include "views/ime/text_input_client.h" | 30 #include "views/ime/text_input_client.h" |
27 #include "views/test/test_views_delegate.h" | 31 #include "views/test/test_views_delegate.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 } | 212 } |
209 | 213 |
210 void SendKeyEvent(ui::KeyboardCode key_code, bool shift, bool control) { | 214 void SendKeyEvent(ui::KeyboardCode key_code, bool shift, bool control) { |
211 SendKeyEvent(key_code, shift, control, false); | 215 SendKeyEvent(key_code, shift, control, false); |
212 } | 216 } |
213 | 217 |
214 void SendKeyEvent(ui::KeyboardCode key_code) { | 218 void SendKeyEvent(ui::KeyboardCode key_code) { |
215 SendKeyEvent(key_code, false, false); | 219 SendKeyEvent(key_code, false, false); |
216 } | 220 } |
217 | 221 |
222 void SendKeyEvent(char16 ch) { | |
223 if (ch < 0x80) { | |
224 ui::KeyboardCode code = | |
225 ch == ' ' ? ui::VKEY_SPACE : | |
226 static_cast<ui::KeyboardCode>(ui::VKEY_A + ch - 'a'); | |
227 SendKeyEvent(code); | |
228 } else { | |
229 KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0); | |
230 event.set_character(ch); | |
231 input_method_->DispatchKeyEvent(event); | |
232 } | |
233 } | |
234 | |
218 View* GetFocusedView() { | 235 View* GetFocusedView() { |
219 return widget_->GetFocusManager()->GetFocusedView(); | 236 return widget_->GetFocusManager()->GetFocusedView(); |
220 } | 237 } |
221 | 238 |
222 int GetCursorPositionX(int cursor_pos) { | 239 int GetCursorPositionX(int cursor_pos) { |
223 gfx::RenderText* render_text = textfield_view_->GetRenderText(); | 240 gfx::RenderText* render_text = textfield_view_->GetRenderText(); |
224 return render_text->GetCursorBounds( | 241 return render_text->GetCursorBounds( |
225 gfx::SelectionModel(cursor_pos), false).x(); | 242 gfx::SelectionModel(cursor_pos), false).x(); |
226 } | 243 } |
227 | 244 |
245 // Get the current cursor bounds. | |
246 gfx::Rect GetCursorBounds() { | |
247 gfx::RenderText* render_text = textfield_view_->GetRenderText(); | |
248 gfx::Rect bounds = render_text->GetUpdatedCursorBounds(); | |
249 return bounds; | |
250 } | |
251 | |
252 // Get the cursor bounds of |sel|. | |
253 gfx::Rect GetCursorBounds(const gfx::SelectionModel& sel) { | |
254 gfx::RenderText* render_text = textfield_view_->GetRenderText(); | |
255 gfx::Rect bounds = render_text->GetCursorBounds(sel, true); | |
256 return bounds; | |
257 } | |
258 | |
259 gfx::Rect GetDisplayRect() { | |
260 return textfield_view_->GetRenderText()->display_rect(); | |
261 } | |
262 | |
263 // Mouse click on the point whose x-axis is |bound|'s x plus |x_offset| and | |
264 // y-axis is in the middle of |bound|'s vertical range. | |
265 void MouseClick(const gfx::Rect bound, int x_offset) { | |
msw
2011/09/09 23:03:24
Why not use a Point instead of a Rect? Use Rect::o
xji
2011/09/12 21:31:48
I need rect.height() as well.
| |
266 int x = bound.x() + x_offset; | |
267 int y = bound.y() + bound.height() / 2; | |
268 MouseEvent click(ui::ET_MOUSE_PRESSED, x, y, ui::EF_LEFT_BUTTON_DOWN); | |
269 textfield_view_->OnMousePressed(click); | |
270 MouseEvent release(ui::ET_MOUSE_RELEASED, 0, 0, ui::EF_LEFT_BUTTON_DOWN); | |
msw
2011/09/09 23:03:24
The release event should probably be at the same x
xji
2011/09/12 21:31:48
Done.
| |
271 textfield_view_->OnMouseReleased(release); | |
272 } | |
273 | |
274 void NonClientMouseClick() { | |
msw
2011/09/09 23:03:24
Using this to avoid double/triple click is pretty
xji
2011/09/12 21:31:48
Done.
| |
275 MouseEvent click(ui::ET_MOUSE_PRESSED, 0, 0, | |
276 ui::EF_LEFT_BUTTON_DOWN | ui::EF_IS_NON_CLIENT); | |
277 textfield_view_->OnMousePressed(click); | |
278 MouseEvent release(ui::ET_MOUSE_RELEASED, 0, 0, | |
279 ui::EF_LEFT_BUTTON_DOWN | ui::EF_IS_NON_CLIENT); | |
280 textfield_view_->OnMouseReleased(release); | |
281 } | |
282 | |
228 // Wrap for visibility in test classes. | 283 // Wrap for visibility in test classes. |
229 ui::TextInputType GetTextInputType() { | 284 ui::TextInputType GetTextInputType() { |
230 return textfield_view_->GetTextInputType(); | 285 return textfield_view_->GetTextInputType(); |
231 } | 286 } |
232 | 287 |
233 // We need widget to populate wrapper class. | 288 // We need widget to populate wrapper class. |
234 Widget* widget_; | 289 Widget* widget_; |
235 | 290 |
236 TestTextfield* textfield_; | 291 TestTextfield* textfield_; |
237 NativeTextfieldViews* textfield_view_; | 292 NativeTextfieldViews* textfield_view_; |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1134 SendKeyEvent(ui::VKEY_A); | 1189 SendKeyEvent(ui::VKEY_A); |
1135 EXPECT_STR_EQ("a23", textfield_->text()); | 1190 EXPECT_STR_EQ("a23", textfield_->text()); |
1136 SendKeyEvent(ui::VKEY_B); | 1191 SendKeyEvent(ui::VKEY_B); |
1137 EXPECT_STR_EQ("ab3", textfield_->text()); | 1192 EXPECT_STR_EQ("ab3", textfield_->text()); |
1138 SendKeyEvent(ui::VKEY_Z, false, true); | 1193 SendKeyEvent(ui::VKEY_Z, false, true); |
1139 EXPECT_STR_EQ("123", textfield_->text()); | 1194 EXPECT_STR_EQ("123", textfield_->text()); |
1140 SendKeyEvent(ui::VKEY_Y, false, true); | 1195 SendKeyEvent(ui::VKEY_Y, false, true); |
1141 EXPECT_STR_EQ("ab3", textfield_->text()); | 1196 EXPECT_STR_EQ("ab3", textfield_->text()); |
1142 } | 1197 } |
1143 | 1198 |
1199 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayTest) { | |
msw
2011/09/09 23:03:24
Some of these tests might be better suited as Rend
xji
2011/09/12 21:31:48
Looking at those tests again, I think in NativeTex
| |
1200 InitTextfield(Textfield::STYLE_DEFAULT); | |
1201 // LTR-RTL string in LTR context. | |
1202 SendKeyEvent('a'); | |
1203 EXPECT_STR_EQ("a", textfield_->text()); | |
1204 int x = GetCursorBounds().x(); | |
1205 int prev_x = x; | |
1206 | |
1207 SendKeyEvent('b'); | |
1208 EXPECT_STR_EQ("ab", textfield_->text()); | |
1209 x = GetCursorBounds().x(); | |
1210 EXPECT_LT(prev_x, x); | |
1211 prev_x = x; | |
1212 | |
1213 SendKeyEvent(0x05E1); | |
msw
2011/09/09 23:03:24
Defining constants (if none exist) would be prefer
xji
2011/09/12 21:31:48
Hm... I tried that. But that makes the subsequent
| |
1214 EXPECT_EQ(WideToUTF16(L"ab\x05E1"), textfield_->text()); | |
1215 x = GetCursorBounds().x(); | |
1216 EXPECT_EQ(prev_x, x); | |
1217 | |
1218 SendKeyEvent(0x05E2); | |
1219 EXPECT_EQ(WideToUTF16(L"ab\x05E1\x5E2"), textfield_->text()); | |
1220 x = GetCursorBounds().x(); | |
1221 EXPECT_EQ(prev_x, x); | |
1222 | |
1223 // Clear text. | |
1224 SendKeyEvent(ui::VKEY_A, false, true); | |
msw
2011/09/09 23:03:24
You can just call SetText here and elsewhere that
xji
2011/09/12 21:31:48
I am trying to emulate the real UI operations. May
| |
1225 SendKeyEvent('\n'); | |
1226 | |
1227 // RTL-LTR string in LTR context. | |
1228 SendKeyEvent(0x05E1); | |
1229 EXPECT_EQ(WideToUTF16(L"\x05E1"), textfield_->text()); | |
1230 x = GetCursorBounds().x(); | |
1231 EXPECT_EQ(GetDisplayRect().x(), x); | |
1232 prev_x = x; | |
1233 | |
1234 SendKeyEvent(0x05E2); | |
1235 EXPECT_EQ(WideToUTF16(L"\x05E1\x05E2"), textfield_->text()); | |
1236 x = GetCursorBounds().x(); | |
1237 EXPECT_EQ(prev_x, x); | |
1238 | |
1239 SendKeyEvent('a'); | |
1240 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"a"), textfield_->text()); | |
1241 x = GetCursorBounds().x(); | |
1242 EXPECT_LT(prev_x, x); | |
1243 prev_x = x; | |
1244 | |
1245 SendKeyEvent('b'); | |
1246 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"ab"), textfield_->text()); | |
1247 x = GetCursorBounds().x(); | |
1248 EXPECT_LT(prev_x, x); | |
1249 } | |
1250 | |
1251 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayInRTLTest) { | |
1252 std::string locale = l10n_util::GetApplicationLocale(""); | |
1253 base::i18n::SetICUDefaultLocale("he"); | |
1254 | |
1255 InitTextfield(Textfield::STYLE_DEFAULT); | |
1256 // LTR-RTL string in RTL context. | |
1257 SendKeyEvent('a'); | |
1258 EXPECT_STR_EQ("a", textfield_->text()); | |
1259 int x = GetCursorBounds().x(); | |
1260 EXPECT_EQ(GetDisplayRect().right() - 1, x); | |
1261 int prev_x = x; | |
1262 | |
1263 SendKeyEvent('b'); | |
1264 EXPECT_STR_EQ("ab", textfield_->text()); | |
1265 x = GetCursorBounds().x(); | |
1266 EXPECT_EQ(prev_x, x); | |
1267 | |
1268 SendKeyEvent(0x05E1); | |
1269 EXPECT_EQ(WideToUTF16(L"ab\x05E1"), textfield_->text()); | |
1270 x = GetCursorBounds().x(); | |
1271 EXPECT_GT(prev_x, x); | |
1272 prev_x = x; | |
1273 | |
1274 SendKeyEvent(0x05E2); | |
1275 EXPECT_EQ(WideToUTF16(L"ab\x05E1\x5E2"), textfield_->text()); | |
1276 x = GetCursorBounds().x(); | |
1277 EXPECT_GT(prev_x, x); | |
1278 | |
1279 SendKeyEvent(ui::VKEY_A, false, true); | |
msw
2011/09/09 23:03:24
SetText
| |
1280 SendKeyEvent('\n'); | |
1281 | |
1282 // RTL-LTR string in RTL context. | |
1283 SendKeyEvent(0x05E1); | |
1284 EXPECT_EQ(WideToUTF16(L"\x05E1"), textfield_->text()); | |
1285 x = GetCursorBounds().x(); | |
1286 prev_x = x; | |
1287 | |
1288 SendKeyEvent(0x05E2); | |
1289 EXPECT_EQ(WideToUTF16(L"\x05E1\x05E2"), textfield_->text()); | |
1290 x = GetCursorBounds().x(); | |
1291 EXPECT_GT(prev_x, x); | |
1292 prev_x = x; | |
1293 | |
1294 SendKeyEvent('a'); | |
1295 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"a"), textfield_->text()); | |
1296 x = GetCursorBounds().x(); | |
1297 EXPECT_EQ(prev_x, x); | |
1298 | |
1299 SendKeyEvent('b'); | |
1300 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"ab"), textfield_->text()); | |
1301 x = GetCursorBounds().x(); | |
1302 EXPECT_EQ(prev_x, x); | |
1303 | |
1304 // Reset locale. | |
1305 base::i18n::SetICUDefaultLocale(locale); | |
1306 } | |
1307 | |
1308 TEST_F(NativeTextfieldViewsTest, HitInsideTextAreaTest) { | |
1309 InitTextfield(Textfield::STYLE_DEFAULT); | |
1310 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); | |
1311 std::vector<gfx::Rect> cursor_bounds; | |
1312 | |
1313 // Save each cursor bound. | |
1314 gfx::SelectionModel sel(0, 0, gfx::SelectionModel::LEADING); | |
1315 cursor_bounds.push_back(GetCursorBounds(sel)); | |
1316 | |
1317 sel = gfx::SelectionModel(1, 0, gfx::SelectionModel::TRAILING); | |
1318 gfx::Rect bound = GetCursorBounds(sel); | |
1319 sel = gfx::SelectionModel(1, 1, gfx::SelectionModel::LEADING); | |
1320 EXPECT_EQ(bound, GetCursorBounds(sel)); | |
1321 cursor_bounds.push_back(bound); | |
1322 | |
1323 sel = gfx::SelectionModel(2, 1, gfx::SelectionModel::TRAILING); | |
1324 bound = GetCursorBounds(sel); | |
1325 sel = gfx::SelectionModel(4, 3, gfx::SelectionModel::TRAILING); | |
1326 EXPECT_EQ(bound, GetCursorBounds(sel)); | |
1327 cursor_bounds.push_back(bound); | |
1328 | |
1329 sel = gfx::SelectionModel(3, 2, gfx::SelectionModel::TRAILING); | |
1330 bound = GetCursorBounds(sel); | |
1331 sel = gfx::SelectionModel(3, 3, gfx::SelectionModel::LEADING); | |
1332 EXPECT_EQ(bound, GetCursorBounds(sel)); | |
1333 cursor_bounds.push_back(bound); | |
1334 | |
1335 sel = gfx::SelectionModel(2, 2, gfx::SelectionModel::LEADING); | |
1336 bound = GetCursorBounds(sel); | |
1337 sel = gfx::SelectionModel(4, 2, gfx::SelectionModel::LEADING); | |
1338 EXPECT_EQ(bound, GetCursorBounds(sel)); | |
1339 cursor_bounds.push_back(bound); | |
1340 | |
1341 // Expected cursor position when clicking left and right of each character. | |
1342 size_t cursor_pos_expected[] = {0, 1, 1, 2, 4, 3, 3, 2}; | |
1343 | |
1344 int index = 0; | |
1345 for (int i = 0; i < static_cast<int>(cursor_bounds.size() - 1); ++i) { | |
1346 int half_width = (cursor_bounds[i + 1].x() - cursor_bounds[i].x()) / 2; | |
1347 MouseClick(cursor_bounds[i], half_width / 2); | |
1348 EXPECT_EQ(cursor_pos_expected[index++], textfield_->GetCursorPosition()); | |
1349 | |
1350 // To avoid trigger double click. Not using sleep() since it takes longer | |
1351 // for the test to run if using sleep(). | |
1352 NonClientMouseClick(); | |
1353 | |
1354 MouseClick(cursor_bounds[i + 1], -(half_width / 2)); | |
msw
2011/09/09 23:03:24
space between '-' and '('
xji
2011/09/12 21:31:48
Done.
| |
1355 EXPECT_EQ(cursor_pos_expected[index++], textfield_->GetCursorPosition()); | |
1356 | |
1357 NonClientMouseClick(); | |
1358 } | |
1359 } | |
1360 | |
1361 TEST_F(NativeTextfieldViewsTest, HitOutsideTextAreaTest) { | |
1362 InitTextfield(Textfield::STYLE_DEFAULT); | |
1363 | |
1364 // LTR-RTL string in LTR context. | |
1365 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); | |
1366 | |
1367 SendKeyEvent(ui::VKEY_HOME); | |
1368 gfx::Rect bound = GetCursorBounds(); | |
1369 MouseClick(bound, -10); | |
1370 EXPECT_EQ(bound, GetCursorBounds()); | |
1371 | |
1372 SendKeyEvent(ui::VKEY_END); | |
1373 bound = GetCursorBounds(); | |
1374 MouseClick(bound, 10); | |
msw
2011/09/09 23:03:24
Is 10 pixels really longer than the text width?
Us
xji
2011/09/12 21:31:48
10 pixel is the x_offset from END position's x-axi
| |
1375 EXPECT_EQ(bound, GetCursorBounds()); | |
1376 | |
1377 NonClientMouseClick(); | |
1378 | |
1379 // RTL-LTR string in LTR context. | |
1380 textfield_->SetText(WideToUTF16(L"\x05E1\x5E2"L"ab")); | |
1381 | |
1382 SendKeyEvent(ui::VKEY_HOME); | |
1383 bound = GetCursorBounds(); | |
1384 #if defined(OS_WIN) | |
1385 MouseClick(bound, -10); | |
1386 #else | |
1387 MouseClick(bound, 10); | |
1388 #endif | |
1389 EXPECT_EQ(bound, GetCursorBounds()); | |
1390 | |
1391 SendKeyEvent(ui::VKEY_END); | |
1392 bound = GetCursorBounds(); | |
1393 #if defined(OS_WIN) | |
1394 MouseClick(bound, 10); | |
1395 #else | |
1396 MouseClick(bound, -10); | |
1397 #endif | |
1398 EXPECT_EQ(bound, GetCursorBounds()); | |
1399 } | |
1400 | |
1401 TEST_F(NativeTextfieldViewsTest, HitOutsideTextAreaInRTLTest) { | |
1402 std::string locale = l10n_util::GetApplicationLocale(""); | |
1403 base::i18n::SetICUDefaultLocale("he"); | |
1404 | |
1405 InitTextfield(Textfield::STYLE_DEFAULT); | |
1406 | |
1407 // RTL-LTR string in RTL context. | |
1408 textfield_->SetText(WideToUTF16(L"\x05E1\x5E2"L"ab")); | |
1409 SendKeyEvent(ui::VKEY_HOME); | |
1410 gfx::Rect bound = GetCursorBounds(); | |
1411 MouseClick(bound, 10); | |
1412 EXPECT_EQ(bound, GetCursorBounds()); | |
1413 | |
1414 SendKeyEvent(ui::VKEY_END); | |
1415 bound = GetCursorBounds(); | |
1416 MouseClick(bound, -10); | |
1417 EXPECT_EQ(bound, GetCursorBounds()); | |
1418 | |
1419 NonClientMouseClick(); | |
1420 | |
1421 // LTR-RTL string in RTL context. | |
1422 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); | |
1423 SendKeyEvent(ui::VKEY_HOME); | |
1424 bound = GetCursorBounds(); | |
1425 #if defined(OS_WIN) | |
1426 MouseClick(bound, 10); | |
1427 #else | |
1428 MouseClick(bound, -10); | |
1429 #endif | |
1430 EXPECT_EQ(bound, GetCursorBounds()); | |
1431 | |
1432 SendKeyEvent(ui::VKEY_END); | |
1433 bound = GetCursorBounds(); | |
1434 #if defined(OS_WIN) | |
1435 MouseClick(bound, -10); | |
1436 #else | |
1437 MouseClick(bound, 10); | |
1438 #endif | |
1439 EXPECT_EQ(bound, GetCursorBounds()); | |
1440 | |
1441 // Reset locale. | |
1442 base::i18n::SetICUDefaultLocale(locale); | |
1443 } | |
1444 | |
1445 void OverflowCursorBoundTestVerifier(const gfx::Rect& display, | |
msw
2011/09/09 23:03:24
A comment would be appreciated:
This verifies that
xji
2011/09/12 21:31:48
Done.
| |
1446 const gfx::Rect& bound) { | |
msw
2011/09/09 23:03:24
Indent this line to match the line above.
xji
2011/09/12 21:31:48
Done.
| |
1447 EXPECT_LE(display.x(), bound.x()); | |
1448 EXPECT_GT(display.right(), bound.right()); | |
1449 EXPECT_LE(display.y(), bound.y()); | |
1450 EXPECT_GE(display.bottom(), bound.bottom()); | |
1451 } | |
1452 | |
1453 TEST_F(NativeTextfieldViewsTest, OverflowTest) { | |
1454 InitTextfield(Textfield::STYLE_DEFAULT); | |
1455 | |
1456 string16 str; | |
1457 for (int i = 0; i < 500; ++i) | |
1458 SendKeyEvent('a'); | |
1459 SendKeyEvent(0x05E1); | |
msw
2011/09/09 23:03:24
Don't we have a bug where on overflow from LTR tex
xji
2011/09/12 21:31:48
Yes we do have that bug.
This test does not test w
| |
1460 gfx::Rect bound = GetCursorBounds(); | |
1461 gfx::Rect display = GetDisplayRect(); | |
1462 OverflowCursorBoundTestVerifier(display, bound); | |
1463 | |
1464 // Test mouse pointing. | |
1465 MouseClick(bound, -1); | |
1466 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | |
1467 | |
1468 // Clear text. | |
1469 SendKeyEvent(ui::VKEY_A, false, true); | |
msw
2011/09/09 23:03:24
SetText
| |
1470 SendKeyEvent('\n'); | |
1471 | |
1472 for (int i = 0; i < 500; ++i) | |
1473 SendKeyEvent(0x05E1); | |
1474 SendKeyEvent('a'); | |
1475 bound = GetCursorBounds(); | |
1476 display = GetDisplayRect(); | |
1477 OverflowCursorBoundTestVerifier(display, bound); | |
1478 | |
1479 MouseClick(bound, -1); | |
1480 EXPECT_EQ(501U, textfield_->GetCursorPosition()); | |
1481 } | |
1482 | |
1483 TEST_F(NativeTextfieldViewsTest, OverflowInRTLTest) { | |
1484 std::string locale = l10n_util::GetApplicationLocale(""); | |
1485 base::i18n::SetICUDefaultLocale("he"); | |
1486 | |
1487 InitTextfield(Textfield::STYLE_DEFAULT); | |
1488 | |
1489 string16 str; | |
1490 for (int i = 0; i < 500; ++i) | |
1491 SendKeyEvent('a'); | |
1492 SendKeyEvent(0x05E1); | |
1493 gfx::Rect bound = GetCursorBounds(); | |
1494 gfx::Rect display = GetDisplayRect(); | |
1495 OverflowCursorBoundTestVerifier(display, bound); | |
1496 | |
1497 MouseClick(bound, 1); | |
1498 EXPECT_EQ(501U, textfield_->GetCursorPosition()); | |
1499 | |
1500 // Clear text. | |
1501 SendKeyEvent(ui::VKEY_A, false, true); | |
msw
2011/09/09 23:03:24
SetText
| |
1502 SendKeyEvent('\n'); | |
1503 | |
1504 for (int i = 0; i < 500; ++i) | |
1505 SendKeyEvent(0x05E1); | |
1506 SendKeyEvent('a'); | |
1507 bound = GetCursorBounds(); | |
1508 display = GetDisplayRect(); | |
1509 OverflowCursorBoundTestVerifier(display, bound); | |
1510 | |
1511 MouseClick(bound, 1); | |
1512 EXPECT_EQ(500U, textfield_->GetCursorPosition()); | |
1513 | |
1514 // Reset locale. | |
1515 base::i18n::SetICUDefaultLocale(locale); | |
1516 } | |
1517 | |
1144 } // namespace views | 1518 } // namespace views |
OLD | NEW |