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

Unified Diff: ui/views/controls/textfield/textfield_model_unittest.cc

Issue 2886313002: Prevent the IME candidate window from flickering on Chrome OS (Closed)
Patch Set: add more tests Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/views/controls/textfield/textfield_model.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/textfield/textfield_model_unittest.cc
diff --git a/ui/views/controls/textfield/textfield_model_unittest.cc b/ui/views/controls/textfield/textfield_model_unittest.cc
index be0a344f5a31dd00520eae84e69d5055d59fd7a0..f824943569472fdea5e8c8868312d59f2cb70a76 100644
--- a/ui/views/controls/textfield/textfield_model_unittest.cc
+++ b/ui/views/controls/textfield/textfield_model_unittest.cc
@@ -893,14 +893,23 @@ TEST_F(TextfieldModelTest, CompositionTextTest) {
composition_text_confirmed_or_cleared_ = false;
// Restart composition with targeting "67" in "678".
- composition.selection = gfx::Range(0, 2);
+ composition.selection = gfx::Range(1, 3);
Yusuke Sato 2017/05/18 17:14:31 Changed to (1, 3) to make sure L898 has the preced
composition.underlines.clear();
composition.underlines.push_back(ui::CompositionUnderline(0, 2, 0, true));
composition.underlines.push_back(ui::CompositionUnderline(2, 3, 0, false));
model.SetCompositionText(composition);
EXPECT_TRUE(model.HasCompositionText());
EXPECT_TRUE(model.HasSelection());
+#if !defined(OS_CHROMEOS)
+ // |composition.selection| is ignored because SetCompositionText checks
+ // if a bold underline exists first.
EXPECT_EQ(gfx::Range(5, 7), model.render_text()->selection());
+ EXPECT_EQ(7U, model.render_text()->cursor_position());
+#else
+ // See SelectRangeInCompositionText().
+ EXPECT_EQ(gfx::Range(7, 5), model.render_text()->selection());
+ EXPECT_EQ(5U, model.render_text()->cursor_position());
+#endif
model.GetTextRange(&range);
EXPECT_EQ(10U, range.end());
@@ -910,7 +919,6 @@ TEST_F(TextfieldModelTest, CompositionTextTest) {
EXPECT_EQ(gfx::Range(5, 8), range);
// Check the composition text.
EXPECT_STR_EQ("456", model.GetTextFromRange(gfx::Range(3, 6)));
- EXPECT_EQ(gfx::Range(5, 7), model.render_text()->selection());
Yusuke Sato 2017/05/18 17:14:31 Removed as this line looked just redundant.
EXPECT_FALSE(composition_text_confirmed_or_cleared_);
model.CancelCompositionText();
@@ -927,8 +935,19 @@ TEST_F(TextfieldModelTest, CompositionTextTest) {
composition_text_confirmed_or_cleared_ = false;
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, gfx::SELECTION_NONE);
+ composition.selection = gfx::Range(0, 1);
Yusuke Sato 2017/05/18 17:14:31 Added a case where composition.selection exists bu
Shu Chen 2017/05/21 03:54:30 nit: pls put this as a code comment.
Yusuke Sato 2017/05/22 05:49:00 Done.
+ composition.underlines.clear();
model.SetCompositionText(composition);
EXPECT_STR_EQ("1234567890678", model.text());
+ EXPECT_TRUE(model.HasSelection());
+#if !defined(OS_CHROMEOS)
+ EXPECT_EQ(gfx::Range(10, 11), model.render_text()->selection());
+ EXPECT_EQ(11U, model.render_text()->cursor_position());
+#else
+ // See SelectRangeInCompositionText().
+ EXPECT_EQ(gfx::Range(11, 10), model.render_text()->selection());
+ EXPECT_EQ(10U, model.render_text()->cursor_position());
+#endif
model.InsertText(base::UTF8ToUTF16("-"));
EXPECT_TRUE(composition_text_confirmed_or_cleared_);
« no previous file with comments | « ui/views/controls/textfield/textfield_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698