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

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

Issue 7458014: Implement Uniscribe RenderText for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits. Created 9 years, 4 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
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 "base/auto_reset.h" 5 #include "base/auto_reset.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/base/clipboard/clipboard.h" 10 #include "ui/base/clipboard/clipboard.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 model.InsertChar('X'); 191 model.InsertChar('X');
192 EXPECT_STR_EQ("*", model.GetVisibleText()); 192 EXPECT_STR_EQ("*", model.GetVisibleText());
193 EXPECT_STR_EQ("X", model.GetText()); 193 EXPECT_STR_EQ("X", model.GetText());
194 } 194 }
195 195
196 TEST_F(TextfieldViewsModelTest, Word) { 196 TEST_F(TextfieldViewsModelTest, Word) {
197 TextfieldViewsModel model(NULL); 197 TextfieldViewsModel model(NULL);
198 model.Append( 198 model.Append(
199 ASCIIToUTF16("The answer to Life, the Universe, and Everything")); 199 ASCIIToUTF16("The answer to Life, the Universe, and Everything"));
200 model.MoveCursorRight(gfx::WORD_BREAK, false); 200 model.MoveCursorRight(gfx::WORD_BREAK, false);
201 #if defined(OS_WIN)
202 // TODO(msw): Revise word break algorithms and improve tests.
203 // Breaks are at "|The |answer |to |Life, |the |Universe, |and |Everything".
204 EXPECT_EQ(4U, model.GetCursorPosition());
205 model.MoveCursorRight(gfx::WORD_BREAK, false);
206 EXPECT_EQ(11U, model.GetCursorPosition());
207 model.MoveCursorRight(gfx::WORD_BREAK, false);
208 model.MoveCursorRight(gfx::WORD_BREAK, false);
209 EXPECT_EQ(20U, model.GetCursorPosition());
210
211 model.MoveCursorLeft(gfx::CHARACTER_BREAK, false);
212 model.MoveCursorLeft(gfx::CHARACTER_BREAK, false);
213 // Should pass the non word char ',', but stop at ", |the |".
214 model.MoveCursorRight(gfx::WORD_BREAK, true);
215 model.MoveCursorRight(gfx::WORD_BREAK, true);
216 model.MoveCursorLeft(gfx::CHARACTER_BREAK, true);
217 #else
201 EXPECT_EQ(3U, model.GetCursorPosition()); 218 EXPECT_EQ(3U, model.GetCursorPosition());
202 model.MoveCursorRight(gfx::WORD_BREAK, false); 219 model.MoveCursorRight(gfx::WORD_BREAK, false);
203 EXPECT_EQ(10U, model.GetCursorPosition()); 220 EXPECT_EQ(10U, model.GetCursorPosition());
204 model.MoveCursorRight(gfx::WORD_BREAK, false); 221 model.MoveCursorRight(gfx::WORD_BREAK, false);
205 model.MoveCursorRight(gfx::WORD_BREAK, false); 222 model.MoveCursorRight(gfx::WORD_BREAK, false);
206 EXPECT_EQ(18U, model.GetCursorPosition()); 223 EXPECT_EQ(18U, model.GetCursorPosition());
207 224
208 // Should passes the non word char ',' 225 // Should pass the non word char ','.
209 model.MoveCursorRight(gfx::WORD_BREAK, true); 226 model.MoveCursorRight(gfx::WORD_BREAK, true);
227 #endif
210 EXPECT_EQ(23U, model.GetCursorPosition()); 228 EXPECT_EQ(23U, model.GetCursorPosition());
211 EXPECT_STR_EQ(", the", model.GetSelectedText()); 229 EXPECT_STR_EQ(", the", model.GetSelectedText());
212 230
213 // Move to the end. 231 // Move to the end.
214 model.MoveCursorRight(gfx::WORD_BREAK, true); 232 model.MoveCursorRight(gfx::WORD_BREAK, true);
215 model.MoveCursorRight(gfx::WORD_BREAK, true); 233 model.MoveCursorRight(gfx::WORD_BREAK, true);
216 model.MoveCursorRight(gfx::WORD_BREAK, true); 234 model.MoveCursorRight(gfx::WORD_BREAK, true);
235 #if defined(OS_WIN)
236 // TODO(msw): Revise word break algorithms and improve tests.
237 // Breaks are at "|The |answer |to |Life, |the |Universe, |and |Everything".
238 model.MoveCursorRight(gfx::WORD_BREAK, true);
239 #endif
217 EXPECT_STR_EQ(", the Universe, and Everything", model.GetSelectedText()); 240 EXPECT_STR_EQ(", the Universe, and Everything", model.GetSelectedText());
218 // Should be safe to go next word at the end. 241 // Should be safe to go next word at the end.
219 model.MoveCursorRight(gfx::WORD_BREAK, true); 242 model.MoveCursorRight(gfx::WORD_BREAK, true);
220 EXPECT_STR_EQ(", the Universe, and Everything", model.GetSelectedText()); 243 EXPECT_STR_EQ(", the Universe, and Everything", model.GetSelectedText());
221 model.InsertChar('2'); 244 model.InsertChar('2');
222 EXPECT_EQ(19U, model.GetCursorPosition()); 245 EXPECT_EQ(19U, model.GetCursorPosition());
223 246
224 // Now backwards. 247 // Now backwards.
225 model.MoveCursorLeft(gfx::CHARACTER_BREAK, false); // leave 2. 248 model.MoveCursorLeft(gfx::CHARACTER_BREAK, false); // leave 2.
226 model.MoveCursorLeft(gfx::WORD_BREAK, true); 249 model.MoveCursorLeft(gfx::WORD_BREAK, true);
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 model.GetSelectedRange(&range); 391 model.GetSelectedRange(&range);
369 EXPECT_TRUE(range.is_empty()); 392 EXPECT_TRUE(range.is_empty());
370 EXPECT_EQ(0U, range.start()); 393 EXPECT_EQ(0U, range.start());
371 EXPECT_EQ(0U, range.end()); 394 EXPECT_EQ(0U, range.end());
372 395
373 model.MoveCursorRight(gfx::WORD_BREAK, true); 396 model.MoveCursorRight(gfx::WORD_BREAK, true);
374 model.GetSelectedRange(&range); 397 model.GetSelectedRange(&range);
375 EXPECT_FALSE(range.is_empty()); 398 EXPECT_FALSE(range.is_empty());
376 EXPECT_FALSE(range.is_reversed()); 399 EXPECT_FALSE(range.is_reversed());
377 EXPECT_EQ(0U, range.start()); 400 EXPECT_EQ(0U, range.start());
401 #if defined(OS_WIN)
402 // TODO(msw): Revise word break algorithms and improve tests.
403 // The current breaks are at "|HELLO |WORLD|".
404 EXPECT_EQ(6U, range.end());
405 #else
378 EXPECT_EQ(5U, range.end()); 406 EXPECT_EQ(5U, range.end());
407 #endif
379 408
380 model.MoveCursorLeft(gfx::CHARACTER_BREAK, true); 409 model.MoveCursorLeft(gfx::CHARACTER_BREAK, true);
381 model.GetSelectedRange(&range); 410 model.GetSelectedRange(&range);
382 EXPECT_FALSE(range.is_empty()); 411 EXPECT_FALSE(range.is_empty());
383 EXPECT_EQ(0U, range.start()); 412 EXPECT_EQ(0U, range.start());
413 #if defined(OS_WIN)
414 // TODO(msw): Revise word break algorithms and improve tests.
415 // The current breaks are at "|HELLO |WORLD|".
416 EXPECT_EQ(5U, range.end());
417 #else
384 EXPECT_EQ(4U, range.end()); 418 EXPECT_EQ(4U, range.end());
419 #endif
385 420
386 model.MoveCursorLeft(gfx::WORD_BREAK, true); 421 model.MoveCursorLeft(gfx::WORD_BREAK, true);
387 model.GetSelectedRange(&range); 422 model.GetSelectedRange(&range);
388 EXPECT_TRUE(range.is_empty()); 423 EXPECT_TRUE(range.is_empty());
389 EXPECT_EQ(0U, range.start()); 424 EXPECT_EQ(0U, range.start());
390 EXPECT_EQ(0U, range.end()); 425 EXPECT_EQ(0U, range.end());
391 426
392 // now from the end. 427 // now from the end.
393 model.MoveCursorRight(gfx::LINE_BREAK, false); 428 model.MoveCursorRight(gfx::LINE_BREAK, false);
394 model.GetSelectedRange(&range); 429 model.GetSelectedRange(&range);
(...skipping 740 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 EXPECT_TRUE(model.Undo()); 1170 EXPECT_TRUE(model.Undo());
1136 EXPECT_STR_EQ("ABCDE", model.GetText()); 1171 EXPECT_STR_EQ("ABCDE", model.GetText());
1137 EXPECT_TRUE(model.Redo()); 1172 EXPECT_TRUE(model.Redo());
1138 EXPECT_STR_EQ("1234", model.GetText()); 1173 EXPECT_STR_EQ("1234", model.GetText());
1139 EXPECT_FALSE(model.Redo()); 1174 EXPECT_FALSE(model.Redo());
1140 1175
1141 // TODO(oshima): We need MockInputMethod to test the behavior with IME. 1176 // TODO(oshima): We need MockInputMethod to test the behavior with IME.
1142 } 1177 }
1143 1178
1144 } // namespace views 1179 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698