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

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

Issue 2709633003: Fix: Cursor of Omnibox stays in LTR mode after setting to RTL mode (Closed)
Patch Set: address comments Created 3 years, 9 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
« no previous file with comments | « ui/views/controls/textfield/textfield_test_api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2390 2390
2391 SendKeyEvent('b'); 2391 SendKeyEvent('b');
2392 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2" L"ab"), textfield_->text()); 2392 EXPECT_EQ(WideToUTF16(L"\x05E1\x5E2" L"ab"), textfield_->text());
2393 x = GetCursorBounds().x(); 2393 x = GetCursorBounds().x();
2394 EXPECT_GE(1, std::abs(x - prev_x)); 2394 EXPECT_GE(1, std::abs(x - prev_x));
2395 2395
2396 // Reset locale. 2396 // Reset locale.
2397 base::i18n::SetICUDefaultLocale(locale); 2397 base::i18n::SetICUDefaultLocale(locale);
2398 } 2398 }
2399 2399
2400 TEST_F(TextfieldTest, TextCursorPositionInRTLTest) {
2401 std::string locale = base::i18n::GetConfiguredLocale();
2402 base::i18n::SetICUDefaultLocale("he");
2403
2404 InitTextfield();
2405 // LTR-RTL string in RTL context.
2406 int text_cursor_position_prev = test_api_->GetCursorViewOrigin().x();
2407 SendKeyEvent('a');
2408 SendKeyEvent('b');
2409 EXPECT_STR_EQ("ab", textfield_->text());
2410 int text_cursor_position_new = test_api_->GetCursorViewOrigin().x();
2411 // Text cursor stays at same place after inserting new charactors in RTL mode.
2412 EXPECT_EQ(text_cursor_position_prev, text_cursor_position_new);
2413
2414 // Reset locale.
2415 base::i18n::SetICUDefaultLocale(locale);
2416 }
2417
2418 TEST_F(TextfieldTest, TextCursorPositionInLTRTest) {
2419 InitTextfield();
2420
2421 // LTR-RTL string in LTR context.
2422 int text_cursor_position_prev = test_api_->GetCursorViewOrigin().x();
2423 SendKeyEvent('a');
2424 SendKeyEvent('b');
2425 EXPECT_STR_EQ("ab", textfield_->text());
2426 int text_cursor_position_new = test_api_->GetCursorViewOrigin().x();
2427 // Text cursor moves to right after inserting new charactors in LTR mode.
2428 EXPECT_LT(text_cursor_position_prev, text_cursor_position_new);
2429 }
2430
2400 TEST_F(TextfieldTest, HitInsideTextAreaTest) { 2431 TEST_F(TextfieldTest, HitInsideTextAreaTest) {
2401 InitTextfield(); 2432 InitTextfield();
2402 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); 2433 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2"));
2403 std::vector<gfx::Rect> cursor_bounds; 2434 std::vector<gfx::Rect> cursor_bounds;
2404 2435
2405 // Save each cursor bound. 2436 // Save each cursor bound.
2406 gfx::SelectionModel sel(0, gfx::CURSOR_FORWARD); 2437 gfx::SelectionModel sel(0, gfx::CURSOR_FORWARD);
2407 cursor_bounds.push_back(GetCursorBounds(sel)); 2438 cursor_bounds.push_back(GetCursorBounds(sel));
2408 2439
2409 sel = gfx::SelectionModel(1, gfx::CURSOR_BACKWARD); 2440 sel = gfx::SelectionModel(1, gfx::CURSOR_BACKWARD);
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
3075 ui::AXNodeData node_data_protected; 3106 ui::AXNodeData node_data_protected;
3076 node_data_protected.state = 0; 3107 node_data_protected.state = 0;
3077 textfield_->GetAccessibleNodeData(&node_data_protected); 3108 textfield_->GetAccessibleNodeData(&node_data_protected);
3078 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role); 3109 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role);
3079 EXPECT_EQ(ASCIIToUTF16("********"), 3110 EXPECT_EQ(ASCIIToUTF16("********"),
3080 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE)); 3111 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE));
3081 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 3112 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
3082 } 3113 }
3083 3114
3084 } // namespace views 3115 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/textfield/textfield_test_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698