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

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: Created 3 years, 10 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");
sadrul 2017/02/23 03:41:21 I think you need to restore |locale| at the end of
yiyix 2017/02/23 16:38:46 Done, i added the restoring part.
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 plaec after inserting new charactors in RTL mode.
sadrul 2017/02/23 03:41:21 *place
yiyix 2017/02/23 16:38:46 Done.
2412 EXPECT_EQ(text_cursor_position_prev, text_cursor_position_new);
2413 }
2414
2415 TEST_F(TextfieldTest, TextCursorPositionInLTRTest) {
2416 InitTextfield();
2417
2418 // LTR-RTL string in LTR context.
2419 int text_cursor_position_prev = test_api_->GetCursorViewOrigin().x();
2420 SendKeyEvent('a');
2421 SendKeyEvent('b');
2422 EXPECT_STR_EQ("ab", textfield_->text());
2423 int text_cursor_position_new = test_api_->GetCursorViewOrigin().x();
2424 // Text cursor moves to right after inserting new charactors in LTR mode.
2425 EXPECT_LT(text_cursor_position_prev, text_cursor_position_new);
2426 }
2427
2400 TEST_F(TextfieldTest, HitInsideTextAreaTest) { 2428 TEST_F(TextfieldTest, HitInsideTextAreaTest) {
2401 InitTextfield(); 2429 InitTextfield();
2402 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2")); 2430 textfield_->SetText(WideToUTF16(L"ab\x05E1\x5E2"));
2403 std::vector<gfx::Rect> cursor_bounds; 2431 std::vector<gfx::Rect> cursor_bounds;
2404 2432
2405 // Save each cursor bound. 2433 // Save each cursor bound.
2406 gfx::SelectionModel sel(0, gfx::CURSOR_FORWARD); 2434 gfx::SelectionModel sel(0, gfx::CURSOR_FORWARD);
2407 cursor_bounds.push_back(GetCursorBounds(sel)); 2435 cursor_bounds.push_back(GetCursorBounds(sel));
2408 2436
2409 sel = gfx::SelectionModel(1, gfx::CURSOR_BACKWARD); 2437 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; 3103 ui::AXNodeData node_data_protected;
3076 node_data_protected.state = 0; 3104 node_data_protected.state = 0;
3077 textfield_->GetAccessibleNodeData(&node_data_protected); 3105 textfield_->GetAccessibleNodeData(&node_data_protected);
3078 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role); 3106 EXPECT_EQ(ui::AX_ROLE_TEXT_FIELD, node_data_protected.role);
3079 EXPECT_EQ(ASCIIToUTF16("********"), 3107 EXPECT_EQ(ASCIIToUTF16("********"),
3080 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE)); 3108 node_data_protected.GetString16Attribute(ui::AX_ATTR_VALUE));
3081 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED)); 3109 EXPECT_TRUE(node_data_protected.HasStateFlag(ui::AX_STATE_PROTECTED));
3082 } 3110 }
3083 3111
3084 } // namespace views 3112 } // 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