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

Side by Side Diff: views/controls/textfield/native_textfield_views_unittest.cc

Issue 7841056: fix know issues in RenderText (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: fix a capitalization in break_iterator.h Created 9 years, 3 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 | « ui/gfx/render_text_win.cc ('k') | views/controls/textfield/textfield_views_model.cc » ('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) 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 85
82 void set_text(const string16& text) { text_ = text; } 86 void set_text(const string16& text) { text_ = text; }
83 const string16& text() const { return text_; } 87 const string16& text() const { return text_; }
84 88
85 private: 89 private:
86 string16 text_; 90 string16 text_;
87 91
88 DISALLOW_COPY_AND_ASSIGN(GetTextHelper); 92 DISALLOW_COPY_AND_ASSIGN(GetTextHelper);
89 }; 93 };
90 94
95 const char16 kHebrewLetterSamekh = 0x05E1;
96
91 } // namespace 97 } // namespace
92 98
93 namespace views { 99 namespace views {
94 100
95 // Convert to Wide so that the printed string will be readable when 101 // Convert to Wide so that the printed string will be readable when
96 // check fails. 102 // check fails.
97 #define EXPECT_STR_EQ(ascii, utf16) \ 103 #define EXPECT_STR_EQ(ascii, utf16) \
98 EXPECT_EQ(ASCIIToWide(ascii), UTF16ToWide(utf16)) 104 EXPECT_EQ(ASCIIToWide(ascii), UTF16ToWide(utf16))
99 #define EXPECT_STR_NE(ascii, utf16) \ 105 #define EXPECT_STR_NE(ascii, utf16) \
100 EXPECT_NE(ASCIIToWide(ascii), UTF16ToWide(utf16)) 106 EXPECT_NE(ASCIIToWide(ascii), UTF16ToWide(utf16))
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 214 }
209 215
210 void SendKeyEvent(ui::KeyboardCode key_code, bool shift, bool control) { 216 void SendKeyEvent(ui::KeyboardCode key_code, bool shift, bool control) {
211 SendKeyEvent(key_code, shift, control, false); 217 SendKeyEvent(key_code, shift, control, false);
212 } 218 }
213 219
214 void SendKeyEvent(ui::KeyboardCode key_code) { 220 void SendKeyEvent(ui::KeyboardCode key_code) {
215 SendKeyEvent(key_code, false, false); 221 SendKeyEvent(key_code, false, false);
216 } 222 }
217 223
224 void SendKeyEvent(char16 ch) {
225 if (ch < 0x80) {
226 ui::KeyboardCode code =
227 ch == ' ' ? ui::VKEY_SPACE :
228 static_cast<ui::KeyboardCode>(ui::VKEY_A + ch - 'a');
229 SendKeyEvent(code);
230 } else {
231 KeyEvent event(ui::ET_KEY_PRESSED, ui::VKEY_UNKNOWN, 0);
232 event.set_character(ch);
233 input_method_->DispatchKeyEvent(event);
234 }
235 }
236
218 View* GetFocusedView() { 237 View* GetFocusedView() {
219 return widget_->GetFocusManager()->GetFocusedView(); 238 return widget_->GetFocusManager()->GetFocusedView();
220 } 239 }
221 240
222 int GetCursorPositionX(int cursor_pos) { 241 int GetCursorPositionX(int cursor_pos) {
223 gfx::RenderText* render_text = textfield_view_->GetRenderText(); 242 gfx::RenderText* render_text = textfield_view_->GetRenderText();
224 return render_text->GetCursorBounds( 243 return render_text->GetCursorBounds(
225 gfx::SelectionModel(cursor_pos), false).x(); 244 gfx::SelectionModel(cursor_pos), false).x();
226 } 245 }
227 246
247 // Get the current cursor bounds.
248 gfx::Rect GetCursorBounds() {
249 gfx::RenderText* render_text = textfield_view_->GetRenderText();
250 gfx::Rect bounds = render_text->GetUpdatedCursorBounds();
251 return bounds;
252 }
253
254 // Get the cursor bounds of |sel|.
255 gfx::Rect GetCursorBounds(const gfx::SelectionModel& sel) {
256 gfx::RenderText* render_text = textfield_view_->GetRenderText();
257 gfx::Rect bounds = render_text->GetCursorBounds(sel, true);
258 return bounds;
259 }
260
261 gfx::Rect GetDisplayRect() {
262 return textfield_view_->GetRenderText()->display_rect();
263 }
264
265 // Mouse click on the point whose x-axis is |bound|'s x plus |x_offset| and
266 // y-axis is in the middle of |bound|'s vertical range.
267 void MouseClick(const gfx::Rect bound, int x_offset) {
268 int x = bound.x() + x_offset;
269 int y = bound.y() + bound.height() / 2;
270 MouseEvent click(ui::ET_MOUSE_PRESSED, x, y, ui::EF_LEFT_BUTTON_DOWN);
271 textfield_view_->OnMousePressed(click);
272 MouseEvent release(ui::ET_MOUSE_RELEASED, x, y, ui::EF_LEFT_BUTTON_DOWN);
273 textfield_view_->OnMouseReleased(release);
274 }
275
276 // This is to avoid double/triple click.
277 void NonClientMouseClick() {
278 MouseEvent click(ui::ET_MOUSE_PRESSED, 0, 0,
279 ui::EF_LEFT_BUTTON_DOWN | ui::EF_IS_NON_CLIENT);
280 textfield_view_->OnMousePressed(click);
281 MouseEvent release(ui::ET_MOUSE_RELEASED, 0, 0,
282 ui::EF_LEFT_BUTTON_DOWN | ui::EF_IS_NON_CLIENT);
283 textfield_view_->OnMouseReleased(release);
284 }
285
228 // Wrap for visibility in test classes. 286 // Wrap for visibility in test classes.
229 ui::TextInputType GetTextInputType() { 287 ui::TextInputType GetTextInputType() {
230 return textfield_view_->GetTextInputType(); 288 return textfield_view_->GetTextInputType();
231 } 289 }
232 290
233 // We need widget to populate wrapper class. 291 // We need widget to populate wrapper class.
234 Widget* widget_; 292 Widget* widget_;
235 293
236 TestTextfield* textfield_; 294 TestTextfield* textfield_;
237 NativeTextfieldViews* textfield_view_; 295 NativeTextfieldViews* textfield_view_;
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1134 SendKeyEvent(ui::VKEY_A); 1192 SendKeyEvent(ui::VKEY_A);
1135 EXPECT_STR_EQ("a23", textfield_->text()); 1193 EXPECT_STR_EQ("a23", textfield_->text());
1136 SendKeyEvent(ui::VKEY_B); 1194 SendKeyEvent(ui::VKEY_B);
1137 EXPECT_STR_EQ("ab3", textfield_->text()); 1195 EXPECT_STR_EQ("ab3", textfield_->text());
1138 SendKeyEvent(ui::VKEY_Z, false, true); 1196 SendKeyEvent(ui::VKEY_Z, false, true);
1139 EXPECT_STR_EQ("123", textfield_->text()); 1197 EXPECT_STR_EQ("123", textfield_->text());
1140 SendKeyEvent(ui::VKEY_Y, false, true); 1198 SendKeyEvent(ui::VKEY_Y, false, true);
1141 EXPECT_STR_EQ("ab3", textfield_->text()); 1199 EXPECT_STR_EQ("ab3", textfield_->text());
1142 } 1200 }
1143 1201
1202 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayTest) {
1203 InitTextfield(Textfield::STYLE_DEFAULT);
1204 // LTR-RTL string in LTR context.
1205 SendKeyEvent('a');
1206 EXPECT_STR_EQ("a", textfield_->text());
1207 int x = GetCursorBounds().x();
1208 int prev_x = x;
1209
1210 SendKeyEvent('b');
1211 EXPECT_STR_EQ("ab", textfield_->text());
1212 x = GetCursorBounds().x();
1213 EXPECT_LT(prev_x, x);
1214 prev_x = x;
1215
1216 SendKeyEvent(0x05E1);
1217 EXPECT_EQ(WideToUTF16(L"ab\x05E1"), textfield_->text());
1218 x = GetCursorBounds().x();
1219 EXPECT_EQ(prev_x, x);
1220
1221 SendKeyEvent(0x05E2);
1222 EXPECT_EQ(WideToUTF16(L"ab\x05E1\x5E2"), textfield_->text());
1223 x = GetCursorBounds().x();
1224 EXPECT_EQ(prev_x, x);
1225
1226 // Clear text.
1227 SendKeyEvent(ui::VKEY_A, false, true);
1228 SendKeyEvent('\n');
1229
1230 // RTL-LTR string in LTR context.
1231 SendKeyEvent(0x05E1);
1232 EXPECT_EQ(WideToUTF16(L"\x05E1"), textfield_->text());
1233 x = GetCursorBounds().x();
1234 EXPECT_EQ(GetDisplayRect().x(), x);
1235 prev_x = x;
1236
1237 SendKeyEvent(0x05E2);
1238 EXPECT_EQ(WideToUTF16(L"\x05E1\x05E2"), textfield_->text());
1239 x = GetCursorBounds().x();
1240 EXPECT_EQ(prev_x, x);
1241
1242 SendKeyEvent('a');
1243 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"a"), textfield_->text());
1244 x = GetCursorBounds().x();
1245 EXPECT_LT(prev_x, x);
1246 prev_x = x;
1247
1248 SendKeyEvent('b');
1249 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"ab"), textfield_->text());
1250 x = GetCursorBounds().x();
1251 EXPECT_LT(prev_x, x);
1252 }
1253
1254 TEST_F(NativeTextfieldViewsTest, TextCursorDisplayInRTLTest) {
1255 std::string locale = l10n_util::GetApplicationLocale("");
1256 base::i18n::SetICUDefaultLocale("he");
1257
1258 InitTextfield(Textfield::STYLE_DEFAULT);
1259 // LTR-RTL string in RTL context.
1260 SendKeyEvent('a');
1261 EXPECT_STR_EQ("a", textfield_->text());
1262 int x = GetCursorBounds().x();
1263 EXPECT_EQ(GetDisplayRect().right() - 1, x);
1264 int prev_x = x;
1265
1266 SendKeyEvent('b');
1267 EXPECT_STR_EQ("ab", textfield_->text());
1268 x = GetCursorBounds().x();
1269 EXPECT_EQ(prev_x, x);
1270
1271 SendKeyEvent(0x05E1);
1272 EXPECT_EQ(WideToUTF16(L"ab\x05E1"), textfield_->text());
1273 x = GetCursorBounds().x();
1274 EXPECT_GT(prev_x, x);
1275 prev_x = x;
1276
1277 SendKeyEvent(0x05E2);
1278 EXPECT_EQ(WideToUTF16(L"ab\x05E1\x5E2"), textfield_->text());
1279 x = GetCursorBounds().x();
1280 EXPECT_GT(prev_x, x);
1281
1282 SendKeyEvent(ui::VKEY_A, false, true);
1283 SendKeyEvent('\n');
1284
1285 // RTL-LTR string in RTL context.
1286 SendKeyEvent(0x05E1);
1287 EXPECT_EQ(WideToUTF16(L"\x05E1"), textfield_->text());
1288 x = GetCursorBounds().x();
1289 prev_x = x;
1290
1291 SendKeyEvent(0x05E2);
1292 EXPECT_EQ(WideToUTF16(L"\x05E1\x05E2"), textfield_->text());
1293 x = GetCursorBounds().x();
1294 EXPECT_GT(prev_x, x);
1295 prev_x = x;
1296
1297 SendKeyEvent('a');
1298 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"a"), textfield_->text());
1299 x = GetCursorBounds().x();
1300 #if defined(OS_WIN)
1301 // In Windows, the text is always in LTR directionality even in RTL UI.
1302 // TODO(xji): it should change if we fix the directionality in Window's
1303 // NativeTextfieldViews
1304 EXPECT_LT(prev_x, x);
1305 #else
1306 EXPECT_EQ(prev_x, x);
1307 #endif
1308 prev_x = x;
1309
1310 SendKeyEvent('b');
1311 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2"L"ab"), textfield_->text());
1312 x = GetCursorBounds().x();
1313 EXPECT_EQ(prev_x, x);
1314
1315 // Reset locale.
1316 base::i18n::SetICUDefaultLocale(locale);
1317 }
1318
1319 TEST_F(NativeTextfieldViewsTest, HitInsideTextAreaTest) {
1320 InitTextfield(Textfield::STYLE_DEFAULT);
1321 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2"));
1322 std::vector<gfx::Rect> cursor_bounds;
1323
1324 // Save each cursor bound.
1325 gfx::SelectionModel sel(0, 0, gfx::SelectionModel::LEADING);
1326 cursor_bounds.push_back(GetCursorBounds(sel));
1327
1328 sel = gfx::SelectionModel(1, 0, gfx::SelectionModel::TRAILING);
1329 gfx::Rect bound = GetCursorBounds(sel);
1330 sel = gfx::SelectionModel(1, 1, gfx::SelectionModel::LEADING);
1331 EXPECT_EQ(bound, GetCursorBounds(sel));
1332 cursor_bounds.push_back(bound);
1333
1334 sel = gfx::SelectionModel(2, 1, gfx::SelectionModel::TRAILING);
1335 bound = GetCursorBounds(sel);
1336 sel = gfx::SelectionModel(4, 3, gfx::SelectionModel::TRAILING);
1337 EXPECT_EQ(bound, GetCursorBounds(sel));
1338 cursor_bounds.push_back(bound);
1339
1340 sel = gfx::SelectionModel(3, 2, gfx::SelectionModel::TRAILING);
1341 bound = GetCursorBounds(sel);
1342 sel = gfx::SelectionModel(3, 3, gfx::SelectionModel::LEADING);
1343 EXPECT_EQ(bound, GetCursorBounds(sel));
1344 cursor_bounds.push_back(bound);
1345
1346 sel = gfx::SelectionModel(2, 2, gfx::SelectionModel::LEADING);
1347 bound = GetCursorBounds(sel);
1348 sel = gfx::SelectionModel(4, 2, gfx::SelectionModel::LEADING);
1349 EXPECT_EQ(bound, GetCursorBounds(sel));
1350 cursor_bounds.push_back(bound);
1351
1352 // Expected cursor position when clicking left and right of each character.
1353 size_t cursor_pos_expected[] = {0, 1, 1, 2, 4, 3, 3, 2};
1354
1355 int index = 0;
1356 for (int i = 0; i < static_cast<int>(cursor_bounds.size() - 1); ++i) {
1357 int half_width = (cursor_bounds[i + 1].x() - cursor_bounds[i].x()) / 2;
1358 MouseClick(cursor_bounds[i], half_width / 2);
1359 EXPECT_EQ(cursor_pos_expected[index++], textfield_->GetCursorPosition());
1360
1361 // To avoid trigger double click. Not using sleep() since it takes longer
1362 // for the test to run if using sleep().
1363 NonClientMouseClick();
1364
1365 MouseClick(cursor_bounds[i + 1], - (half_width / 2));
1366 EXPECT_EQ(cursor_pos_expected[index++], textfield_->GetCursorPosition());
1367
1368 NonClientMouseClick();
1369 }
1370 }
1371
1372 TEST_F(NativeTextfieldViewsTest, HitOutsideTextAreaTest) {
1373 InitTextfield(Textfield::STYLE_DEFAULT);
1374
1375 // LTR-RTL string in LTR context.
1376 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2"));
1377
1378 SendKeyEvent(ui::VKEY_HOME);
1379 gfx::Rect bound = GetCursorBounds();
1380 MouseClick(bound, -10);
1381 EXPECT_EQ(bound, GetCursorBounds());
1382
1383 SendKeyEvent(ui::VKEY_END);
1384 bound = GetCursorBounds();
1385 MouseClick(bound, 10);
1386 EXPECT_EQ(bound, GetCursorBounds());
1387
1388 NonClientMouseClick();
1389
1390 // RTL-LTR string in LTR context.
1391 textfield_->SetText(WideToUTF16(L"\x05E1\x5E2"L"ab"));
1392
1393 SendKeyEvent(ui::VKEY_HOME);
1394 bound = GetCursorBounds();
1395 #if defined(OS_WIN)
1396 MouseClick(bound, -10);
1397 #else
1398 MouseClick(bound, 10);
1399 #endif
1400 EXPECT_EQ(bound, GetCursorBounds());
1401
1402 SendKeyEvent(ui::VKEY_END);
1403 bound = GetCursorBounds();
1404 #if defined(OS_WIN)
1405 MouseClick(bound, 10);
1406 #else
1407 MouseClick(bound, -10);
1408 #endif
1409 EXPECT_EQ(bound, GetCursorBounds());
1410 }
1411
1412 TEST_F(NativeTextfieldViewsTest, HitOutsideTextAreaInRTLTest) {
1413 std::string locale = l10n_util::GetApplicationLocale("");
1414 base::i18n::SetICUDefaultLocale("he");
1415
1416 InitTextfield(Textfield::STYLE_DEFAULT);
1417
1418 // RTL-LTR string in RTL context.
1419 textfield_->SetText(WideToUTF16(L"\x05E1\x5E2"L"ab"));
1420 SendKeyEvent(ui::VKEY_HOME);
1421 gfx::Rect bound = GetCursorBounds();
1422 MouseClick(bound, 10);
1423 EXPECT_EQ(bound, GetCursorBounds());
1424
1425 SendKeyEvent(ui::VKEY_END);
1426 bound = GetCursorBounds();
1427 MouseClick(bound, -10);
1428 EXPECT_EQ(bound, GetCursorBounds());
1429
1430 NonClientMouseClick();
1431
1432 // LTR-RTL string in RTL context.
1433 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2"));
1434 SendKeyEvent(ui::VKEY_HOME);
1435 bound = GetCursorBounds();
1436 #if defined(OS_WIN)
1437 MouseClick(bound, 10);
1438 #else
1439 MouseClick(bound, -10);
1440 #endif
1441 EXPECT_EQ(bound, GetCursorBounds());
1442
1443 SendKeyEvent(ui::VKEY_END);
1444 bound = GetCursorBounds();
1445 #if defined(OS_WIN)
1446 MouseClick(bound, -10);
1447 #else
1448 MouseClick(bound, 10);
1449 #endif
1450 EXPECT_EQ(bound, GetCursorBounds());
1451
1452 // Reset locale.
1453 base::i18n::SetICUDefaultLocale(locale);
1454 }
1455
1456 // This verifies that |bound| is contained by |display|. |bound|'s right edge
1457 // must be less than |diaplay|'s right edge.
1458 void OverflowCursorBoundTestVerifier(const gfx::Rect& display,
1459 const gfx::Rect& bound) {
1460 EXPECT_LE(display.x(), bound.x());
1461 EXPECT_GT(display.right(), bound.right());
1462 EXPECT_LE(display.y(), bound.y());
1463 EXPECT_GE(display.bottom(), bound.bottom());
1464 }
1465
1466 TEST_F(NativeTextfieldViewsTest, OverflowTest) {
1467 InitTextfield(Textfield::STYLE_DEFAULT);
1468
1469 string16 str;
1470 for (int i = 0; i < 500; ++i)
1471 SendKeyEvent('a');
1472 SendKeyEvent(kHebrewLetterSamekh);
1473 gfx::Rect bound = GetCursorBounds();
1474 gfx::Rect display = GetDisplayRect();
1475 OverflowCursorBoundTestVerifier(display, bound);
1476
1477 // Test mouse pointing.
1478 MouseClick(bound, -1);
1479 EXPECT_EQ(500U, textfield_->GetCursorPosition());
1480
1481 // Clear text.
1482 SendKeyEvent(ui::VKEY_A, false, true);
1483 SendKeyEvent('\n');
1484
1485 for (int i = 0; i < 500; ++i)
1486 SendKeyEvent(kHebrewLetterSamekh);
1487 SendKeyEvent('a');
1488 bound = GetCursorBounds();
1489 display = GetDisplayRect();
1490 OverflowCursorBoundTestVerifier(display, bound);
1491
1492 MouseClick(bound, -1);
1493 EXPECT_EQ(501U, textfield_->GetCursorPosition());
1494 }
1495
1496 TEST_F(NativeTextfieldViewsTest, OverflowInRTLTest) {
1497 std::string locale = l10n_util::GetApplicationLocale("");
1498 base::i18n::SetICUDefaultLocale("he");
1499
1500 InitTextfield(Textfield::STYLE_DEFAULT);
1501
1502 string16 str;
1503 for (int i = 0; i < 500; ++i)
1504 SendKeyEvent('a');
1505 SendKeyEvent(kHebrewLetterSamekh);
1506 gfx::Rect bound = GetCursorBounds();
1507 gfx::Rect display = GetDisplayRect();
1508 OverflowCursorBoundTestVerifier(display, bound);
1509
1510 MouseClick(bound, 1);
1511 EXPECT_EQ(501U, textfield_->GetCursorPosition());
1512
1513 // Clear text.
1514 SendKeyEvent(ui::VKEY_A, false, true);
1515 SendKeyEvent('\n');
1516
1517 for (int i = 0; i < 500; ++i)
1518 SendKeyEvent(kHebrewLetterSamekh);
1519 SendKeyEvent('a');
1520 bound = GetCursorBounds();
1521 display = GetDisplayRect();
1522 OverflowCursorBoundTestVerifier(display, bound);
1523
1524 MouseClick(bound, 1);
1525 #if defined(OS_WIN)
1526 // In Windows, the text is always in LTR directionality even in RTL UI.
1527 // TODO(xji): it should change if we fix the directionality in Window's
1528 // NativeTextfieldViews
1529 EXPECT_EQ(0U, textfield_->GetCursorPosition());
1530 #else
1531 EXPECT_EQ(500U, textfield_->GetCursorPosition());
1532 #endif
1533
1534 // Reset locale.
1535 base::i18n::SetICUDefaultLocale(locale);
1536 }
1537
1144 } // namespace views 1538 } // namespace views
OLDNEW
« no previous file with comments | « ui/gfx/render_text_win.cc ('k') | views/controls/textfield/textfield_views_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698