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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 10693160: Add and specify Views::Textfield::SelectAll |reversed| flag, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove redundant comments. Created 8 years, 5 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/gfx/render_text.cc ('k') | ui/views/controls/message_box_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_unittest.cc
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index 46a3a7809992c21aef8de27d9989897d43e956d2..a8ca5413c387715f2e04cf8e269578df11695963 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -727,7 +727,38 @@ TEST_F(RenderTextTest, EdgeSelectionModels) {
}
}
-TEST_F(RenderTextTest, MoveCursorLeftRightWithSelection) {
+TEST_F(RenderTextTest, SelectAll) {
+ const wchar_t* const cases[] = {
+ L"abc",
+ L"a"L"\x5d0\x5d1",
+ L"a"L"\x5d1"L"b",
+ L"\x5d0\x5d1\x5d2",
+ L"\x5d0\x5d1"L"a",
+ L"\x5d0"L"a"L"\x5d1",
+ };
+
+ // Ensure that SelectAll respects the |reversed| argument regardless of
+ // application locale and text content directionality.
+ scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
+ const SelectionModel expected_reversed(ui::Range(3, 0), CURSOR_FORWARD);
+ const SelectionModel expected_forwards(ui::Range(0, 3), CURSOR_BACKWARD);
+ const bool was_rtl = base::i18n::IsRTL();
+
+ for (size_t i = 0; i < 2; ++i) {
+ SetRTL(!base::i18n::IsRTL());
+ for (size_t j = 0; j < ARRAYSIZE_UNSAFE(cases); j++) {
+ render_text->SetText(WideToUTF16(cases[j]));
+ render_text->SelectAll(false);
+ EXPECT_EQ(render_text->selection_model(), expected_forwards);
+ render_text->SelectAll(true);
+ EXPECT_EQ(render_text->selection_model(), expected_reversed);
+ }
+ }
+
+ EXPECT_EQ(was_rtl, base::i18n::IsRTL());
+}
+
+ TEST_F(RenderTextTest, MoveCursorLeftRightWithSelection) {
scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
render_text->SetText(WideToUTF16(L"abc\x05d0\x05d1\x05d2"));
// Left arrow on select ranging (6, 4).
« no previous file with comments | « ui/gfx/render_text.cc ('k') | ui/views/controls/message_box_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698