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 10 matching lines...) Expand all Loading... | |
21 #include "ui/gfx/font.h" | 21 #include "ui/gfx/font.h" |
22 #include "ui/gfx/range/range.h" | 22 #include "ui/gfx/range/range.h" |
23 #include "ui/gfx/range/range_f.h" | 23 #include "ui/gfx/range/range_f.h" |
24 #include "ui/gfx/render_text_harfbuzz.h" | 24 #include "ui/gfx/render_text_harfbuzz.h" |
25 | 25 |
26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
27 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
28 #include "ui/gfx/platform_font_win.h" | 28 #include "ui/gfx/platform_font_win.h" |
29 #endif | 29 #endif |
30 | 30 |
31 #if defined(OS_MACOSX) | |
32 #include <ApplicationServices/ApplicationServices.h> | |
33 | |
34 #include "ui/gfx/render_text_mac.h" | |
35 #endif | |
36 | |
31 using base::ASCIIToUTF16; | 37 using base::ASCIIToUTF16; |
32 using base::UTF8ToUTF16; | 38 using base::UTF8ToUTF16; |
33 using base::WideToUTF16; | 39 using base::WideToUTF16; |
34 using base::WideToUTF8; | 40 using base::WideToUTF8; |
35 | 41 |
36 namespace gfx { | 42 namespace gfx { |
37 | 43 |
38 namespace { | 44 namespace { |
39 | 45 |
40 // Various weak, LTR, RTL, and Bidi string cases with three characters each. | 46 // Various weak, LTR, RTL, and Bidi string cases with three characters each. |
(...skipping 2560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2601 SkColor color = buffer[width + y * kCanvasSize.width()]; | 2607 SkColor color = buffer[width + y * kCanvasSize.width()]; |
2602 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; | 2608 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; |
2603 for (int x = 1; x < kTestWidth; ++x) { | 2609 for (int x = 1; x < kTestWidth; ++x) { |
2604 color = buffer[width + x + y * kCanvasSize.width()]; | 2610 color = buffer[width + x + y * kCanvasSize.width()]; |
2605 EXPECT_EQ(SK_ColorWHITE, color) << string; | 2611 EXPECT_EQ(SK_ColorWHITE, color) << string; |
2606 } | 2612 } |
2607 } | 2613 } |
2608 } | 2614 } |
2609 } | 2615 } |
2610 | 2616 |
2617 #if defined(OS_MACOSX) | |
2618 TEST_F(RenderTextTest, Mac_ElidedText) { | |
2619 RenderTextMac render_text; | |
2620 base::string16 text(ASCIIToUTF16("This is an example.")); | |
2621 render_text.SetText(text); | |
2622 render_text.EnsureLayout(); | |
2623 // NOTE: Character and glyph counts are only comparable for simple text. | |
2624 EXPECT_EQ(text.size(), | |
2625 static_cast<size_t>(CTLineGetGlyphCount(render_text.line_))); | |
2626 | |
2627 render_text.SetElideBehavior(ELIDE_TAIL); | |
2628 gfx::Size string_size = render_text.GetStringSize(); | |
tapted
2015/03/02 23:36:11
It looks like this always returns 0-width, because
| |
2629 string_size.set_width(string_size.width() / 2); | |
2630 render_text.SetDisplayRect(gfx::Rect(string_size)); | |
2631 render_text.EnsureLayout(); | |
2632 EXPECT_GT(text.size(), | |
2633 static_cast<size_t>(CTLineGetGlyphCount(render_text.line_))); | |
2634 } | |
2635 #endif | |
2636 | |
2611 } // namespace gfx | 2637 } // namespace gfx |
OLD | NEW |