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

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

Issue 8575020: Improve RenderTextWin font fallback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: sync Created 9 years 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
« ui/gfx/render_text_win.cc ('K') | « ui/gfx/render_text_win.cc ('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 (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 <vector> 5 #include <vector>
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/string16.h" 10 #include "base/string16.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // Delete should delete the whole grapheme. 178 // Delete should delete the whole grapheme.
179 model.MoveCursorTo(gfx::SelectionModel(0U)); 179 model.MoveCursorTo(gfx::SelectionModel(0U));
180 // TODO(xji): temporarily disable in platform Win since the complex script 180 // TODO(xji): temporarily disable in platform Win since the complex script
181 // characters turned into empty square due to font regression. So, not able 181 // characters turned into empty square due to font regression. So, not able
182 // to test 2 characters belong to the same grapheme. 182 // to test 2 characters belong to the same grapheme.
183 #if defined(OS_LINUX) 183 #if defined(OS_LINUX)
184 EXPECT_TRUE(model.Delete()); 184 EXPECT_TRUE(model.Delete());
185 EXPECT_EQ(WideToUTF16(L"\x0061\x0062\x0915\x0915\x094d\x092e\x094d"), 185 EXPECT_EQ(WideToUTF16(L"\x0061\x0062\x0915\x0915\x094d\x092e\x094d"),
186 model.GetText()); 186 model.GetText());
187 model.MoveCursorTo(gfx::SelectionModel(model.GetText().length())); 187 model.MoveCursorTo(gfx::SelectionModel(model.GetText().length()));
188 EXPECT_EQ(model.GetText().length(), model.GetCursorPosition());
188 EXPECT_TRUE(model.Backspace()); 189 EXPECT_TRUE(model.Backspace());
189 EXPECT_EQ(WideToUTF16(L"\x0061\x0062\x0915\x0915\x094d\x092e"), 190 EXPECT_EQ(WideToUTF16(L"\x0061\x0062\x0915\x0915\x094d\x092e"),
190 model.GetText()); 191 model.GetText());
191 #endif 192 #endif
192 193
193 // Test cursor position and deletion for Hindi Virama. 194 // Test cursor position and deletion for Hindi Virama.
194 model.SetText(WideToUTF16(L"\x0D38\x0D4D\x0D15\x0D16\x0D2E")); 195 model.SetText(WideToUTF16(L"\x0D38\x0D4D\x0D15\x0D16\x0D2E"));
195 model.MoveCursorTo(gfx::SelectionModel(0)); 196 model.MoveCursorTo(gfx::SelectionModel(0));
196 EXPECT_EQ(0U, model.GetCursorPosition()); 197 EXPECT_EQ(0U, model.GetCursorPosition());
197 198
198 // TODO(xji): temporarily disable in platform Win since the complex script 199 // TODO(xji): temporarily disable in platform Win since the complex script
199 // characters turned into empty square due to font regression. So, not able 200 // characters turned into empty square due to font regression. So, not able
200 // to test 2 characters belong to the same grapheme. 201 // to test 2 characters belong to the same grapheme.
201 #if defined(OS_LINUX) 202 #if defined(OS_LINUX)
202 model.MoveCursorTo(gfx::SelectionModel(1)); 203 model.MoveCursorTo(gfx::SelectionModel(1));
203 EXPECT_EQ(0U, model.GetCursorPosition()); 204 EXPECT_EQ(0U, model.GetCursorPosition());
204 #endif 205 #endif
205 206
206 model.MoveCursorTo(gfx::SelectionModel(2));
207 EXPECT_EQ(2U, model.GetCursorPosition());
208
209 model.MoveCursorTo(gfx::SelectionModel(3)); 207 model.MoveCursorTo(gfx::SelectionModel(3));
210 EXPECT_EQ(3U, model.GetCursorPosition()); 208 EXPECT_EQ(3U, model.GetCursorPosition());
211 209
210 // TODO(asvitkine): Temporarily disable the following check on Windows. It
211 // seems Windows treats "\x0D38\x0D4D\x0D15" as a single grapheme.
212 #if !defined(OS_WIN)
212 model.MoveCursorTo(gfx::SelectionModel(2)); 213 model.MoveCursorTo(gfx::SelectionModel(2));
213 214 EXPECT_EQ(2U, model.GetCursorPosition());
214 EXPECT_TRUE(model.Backspace()); 215 EXPECT_TRUE(model.Backspace());
215 EXPECT_EQ(WideToUTF16(L"\x0D38\x0D15\x0D16\x0D2E"), model.GetText()); 216 EXPECT_EQ(WideToUTF16(L"\x0D38\x0D15\x0D16\x0D2E"), model.GetText());
217 #endif
216 218
217 // Test Delete/Backspace on Hebrew with non-spacing marks. 219 // Test Delete/Backspace on Hebrew with non-spacing marks.
218 // TODO(xji): temporarily disable in platform Win since the complex script 220 // TODO(xji): temporarily disable in platform Win since the complex script
msw 2011/11/29 20:42:00 Can we enable these codepaths on Windows now that
xji 2011/11/29 21:15:48 Agree.
219 // characters turned into empty square due to font regression. So, not able 221 // characters turned into empty square due to font regression. So, not able
220 // to test 2 characters belong to the same grapheme. 222 // to test 2 characters belong to the same grapheme.
221 #if defined(OS_LINUX) 223 #if defined(OS_LINUX)
222 model.SetText(WideToUTF16(L"\x05d5\x05b7\x05D9\x05B0\x05D4\x05B4\x05D9")); 224 model.SetText(WideToUTF16(L"\x05d5\x05b7\x05D9\x05B0\x05D4\x05B4\x05D9"));
223 model.MoveCursorTo(gfx::SelectionModel(0)); 225 model.MoveCursorTo(gfx::SelectionModel(0));
224 EXPECT_TRUE(model.Delete()); 226 EXPECT_TRUE(model.Delete());
225 EXPECT_TRUE(model.Delete()); 227 EXPECT_TRUE(model.Delete());
226 EXPECT_TRUE(model.Delete()); 228 EXPECT_TRUE(model.Delete());
227 EXPECT_TRUE(model.Delete()); 229 EXPECT_TRUE(model.Delete());
228 EXPECT_EQ(WideToUTF16(L""), model.GetText()); 230 EXPECT_EQ(WideToUTF16(L""), model.GetText());
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 model.ClearSelection(); 556 model.ClearSelection();
555 model.MoveCursorRight(gfx::LINE_BREAK, false); 557 model.MoveCursorRight(gfx::LINE_BREAK, false);
556 model.MoveCursorLeft(gfx::WORD_BREAK, true); 558 model.MoveCursorLeft(gfx::WORD_BREAK, true);
557 EXPECT_TRUE(model.Paste()); 559 EXPECT_TRUE(model.Paste());
558 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text); 560 clipboard->ReadText(ui::Clipboard::BUFFER_STANDARD, &clipboard_text);
559 EXPECT_STR_EQ("HELLO HELLO WORLD", clipboard_text); 561 EXPECT_STR_EQ("HELLO HELLO WORLD", clipboard_text);
560 EXPECT_STR_EQ("HELLO HELLO HELLO HELLO WORLD", model.GetText()); 562 EXPECT_STR_EQ("HELLO HELLO HELLO HELLO WORLD", model.GetText());
561 EXPECT_EQ(29U, model.GetCursorPosition()); 563 EXPECT_EQ(29U, model.GetCursorPosition());
562 } 564 }
563 565
564 void SelectWordTestVerifier(TextfieldViewsModel &model, 566 static void SelectWordTestVerifier(const TextfieldViewsModel& model,
565 const string16 &expected_selected_string, size_t expected_cursor_pos) { 567 const string16 &expected_selected_string, size_t expected_cursor_pos) {
566 EXPECT_EQ(expected_selected_string, model.GetSelectedText()); 568 EXPECT_EQ(expected_selected_string, model.GetSelectedText());
567 EXPECT_EQ(expected_cursor_pos, model.GetCursorPosition()); 569 EXPECT_EQ(expected_cursor_pos, model.GetCursorPosition());
568 } 570 }
569 571
570 TEST_F(TextfieldViewsModelTest, SelectWordTest) { 572 TEST_F(TextfieldViewsModelTest, SelectWordTest) {
571 TextfieldViewsModel model(NULL); 573 TextfieldViewsModel model(NULL);
572 model.Append(ASCIIToUTF16(" HELLO !! WO RLD ")); 574 model.Append(ASCIIToUTF16(" HELLO !! WO RLD "));
573 575
574 // Test when cursor is at the beginning. 576 // Test when cursor is at the beginning.
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 EXPECT_TRUE(model.Undo()); 1529 EXPECT_TRUE(model.Undo());
1528 EXPECT_STR_EQ("ABCDE", model.GetText()); 1530 EXPECT_STR_EQ("ABCDE", model.GetText());
1529 EXPECT_TRUE(model.Redo()); 1531 EXPECT_TRUE(model.Redo());
1530 EXPECT_STR_EQ("1234", model.GetText()); 1532 EXPECT_STR_EQ("1234", model.GetText());
1531 EXPECT_FALSE(model.Redo()); 1533 EXPECT_FALSE(model.Redo());
1532 1534
1533 // TODO(oshima): We need MockInputMethod to test the behavior with IME. 1535 // TODO(oshima): We need MockInputMethod to test the behavior with IME.
1534 } 1536 }
1535 1537
1536 } // namespace views 1538 } // namespace views
OLDNEW
« ui/gfx/render_text_win.cc ('K') | « ui/gfx/render_text_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698