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

Side by Side Diff: ui/gfx/render_text_unittest.cc

Issue 8747001: Reintroduce password support to NativeTextfieldViews (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: delete more dead code, address recent comments 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
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 "ui/gfx/render_text.h" 5 #include "ui/gfx/render_text.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.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 10
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 EXPECT_EQ(ui::Range(0, 3), render_text->style_ranges()[0].range); 271 EXPECT_EQ(ui::Range(0, 3), render_text->style_ranges()[0].range);
272 272
273 SetTextWith2ExtraStyles(render_text.get()); 273 SetTextWith2ExtraStyles(render_text.get());
274 EXPECT_EQ(3U, render_text->style_ranges().size()); 274 EXPECT_EQ(3U, render_text->style_ranges().size());
275 275
276 render_text->SetText(ASCIIToUTF16("a")); 276 render_text->SetText(ASCIIToUTF16("a"));
277 EXPECT_EQ(1U, render_text->style_ranges().size()); 277 EXPECT_EQ(1U, render_text->style_ranges().size());
278 EXPECT_EQ(ui::Range(0, 1), render_text->style_ranges()[0].range); 278 EXPECT_EQ(ui::Range(0, 1), render_text->style_ranges()[0].range);
279 } 279 }
280 280
281 TEST_F(RenderTextTest, PasswordCensorship) {
282 const string16 seuss = ASCIIToUTF16("hop on pop");
283 const string16 no_seuss = ASCIIToUTF16("**********");
284 scoped_ptr<RenderText> render_text(RenderText::CreateRenderText());
285
286 // GetObscuredText should return asterisks when the obscured bit is set.
287 render_text->SetText(seuss);
288 render_text->SetObscured(true);
289 EXPECT_EQ(seuss, render_text->text());
290 EXPECT_EQ(no_seuss, render_text->GetObscuredText());
291 render_text->SetObscured(false);
292 EXPECT_EQ(seuss, render_text->text());
293 EXPECT_EQ(seuss, render_text->GetObscuredText());
294 }
295
281 void RunMoveCursorLeftRightTest(RenderText* render_text, 296 void RunMoveCursorLeftRightTest(RenderText* render_text,
282 const std::vector<SelectionModel>& expected, 297 const std::vector<SelectionModel>& expected,
283 bool move_right) { 298 bool move_right) {
284 for (int i = 0; i < static_cast<int>(expected.size()); ++i) { 299 for (int i = 0; i < static_cast<int>(expected.size()); ++i) {
285 SelectionModel sel = expected[i]; 300 SelectionModel sel = expected[i];
286 EXPECT_TRUE(render_text->selection_model().Equals(sel)); 301 EXPECT_TRUE(render_text->selection_model().Equals(sel));
287 if (move_right) 302 if (move_right)
288 render_text->MoveCursorRight(CHARACTER_BREAK, false); 303 render_text->MoveCursorRight(CHARACTER_BREAK, false);
289 else 304 else
290 render_text->MoveCursorLeft(CHARACTER_BREAK, false); 305 render_text->MoveCursorLeft(CHARACTER_BREAK, false);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 EXPECT_EQ(5U, render_text->GetCursorPosition()); 761 EXPECT_EQ(5U, render_text->GetCursorPosition());
747 render_text->MoveCursorRight(WORD_BREAK, false); 762 render_text->MoveCursorRight(WORD_BREAK, false);
748 EXPECT_EQ(6U, render_text->GetCursorPosition()); 763 EXPECT_EQ(6U, render_text->GetCursorPosition());
749 render_text->MoveCursorRight(WORD_BREAK, false); 764 render_text->MoveCursorRight(WORD_BREAK, false);
750 EXPECT_EQ(6U, render_text->GetCursorPosition()); 765 EXPECT_EQ(6U, render_text->GetCursorPosition());
751 } 766 }
752 767
753 #endif 768 #endif
754 769
755 } // namespace gfx 770 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698