OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
712 | 712 |
713 expected.clear(); | 713 expected.clear(); |
714 expected.push_back(SelectionModel(4, CURSOR_FORWARD)); | 714 expected.push_back(SelectionModel(4, CURSOR_FORWARD)); |
715 // The cursor hops over the elided text to preceeding text. | 715 // The cursor hops over the elided text to preceeding text. |
716 expected.push_back(SelectionModel(1, CURSOR_FORWARD)); | 716 expected.push_back(SelectionModel(1, CURSOR_FORWARD)); |
717 expected.push_back(SelectionModel(0, CURSOR_FORWARD)); | 717 expected.push_back(SelectionModel(0, CURSOR_FORWARD)); |
718 expected.push_back(SelectionModel(0, CURSOR_BACKWARD)); | 718 expected.push_back(SelectionModel(0, CURSOR_BACKWARD)); |
719 RunMoveCursorLeftRightTest(render_text.get(), expected, CURSOR_RIGHT); | 719 RunMoveCursorLeftRightTest(render_text.get(), expected, CURSOR_RIGHT); |
720 } | 720 } |
721 | 721 |
722 TEST_F(RenderTextTest, HarfBuzz_ElideEmail) { | |
msw
2015/03/25 23:17:09
nit: Rename Elide[d]Email, move after ElidedText o
Jun Mukai
2015/03/26 16:34:12
Done.
| |
723 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | |
724 render_text->SetText(ASCIIToUTF16("test@example.com")); | |
725 const gfx::Size size = render_text->GetStringSize(); | |
726 | |
727 const base::string16 long_email = | |
728 ASCIIToUTF16("longemailaddresstest@example.com"); | |
729 render_text->SetText(long_email); | |
730 render_text->SetElideBehavior(ELIDE_EMAIL); | |
731 render_text->SetDisplayRect(gfx::Rect(size)); | |
732 EXPECT_GE(size.width(), render_text->GetStringSize().width()); | |
733 EXPECT_NE(long_email, render_text->GetDisplayText()); | |
msw
2015/03/25 23:17:09
optional nit: you can remove this, the statement b
Jun Mukai
2015/03/26 16:34:12
Done.
| |
734 EXPECT_GT(long_email.size(), render_text->GetDisplayText().size()); | |
735 } | |
736 | |
722 TEST_F(RenderTextTest, GetDisplayTextDirection) { | 737 TEST_F(RenderTextTest, GetDisplayTextDirection) { |
723 struct { | 738 struct { |
724 const wchar_t* text; | 739 const wchar_t* text; |
725 const base::i18n::TextDirection text_direction; | 740 const base::i18n::TextDirection text_direction; |
726 } cases[] = { | 741 } cases[] = { |
727 // Blank strings and those with no/weak directionality default to LTR. | 742 // Blank strings and those with no/weak directionality default to LTR. |
728 { L"", base::i18n::LEFT_TO_RIGHT }, | 743 { L"", base::i18n::LEFT_TO_RIGHT }, |
729 { kWeak, base::i18n::LEFT_TO_RIGHT }, | 744 { kWeak, base::i18n::LEFT_TO_RIGHT }, |
730 // Strings that begin with strong LTR characters. | 745 // Strings that begin with strong LTR characters. |
731 { kLtr, base::i18n::LEFT_TO_RIGHT }, | 746 { kLtr, base::i18n::LEFT_TO_RIGHT }, |
(...skipping 2090 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2822 string_size.set_width(string_size.width() / 2); | 2837 string_size.set_width(string_size.width() / 2); |
2823 render_text.SetDisplayRect(gfx::Rect(string_size)); | 2838 render_text.SetDisplayRect(gfx::Rect(string_size)); |
2824 render_text.EnsureLayout(); | 2839 render_text.EnsureLayout(); |
2825 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); | 2840 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); |
2826 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); | 2841 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); |
2827 EXPECT_NE(0, glyph_count); | 2842 EXPECT_NE(0, glyph_count); |
2828 } | 2843 } |
2829 #endif | 2844 #endif |
2830 | 2845 |
2831 } // namespace gfx | 2846 } // namespace gfx |
OLD | NEW |