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

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

Issue 968923004: Use GetDisplayText() instead of text() for rendering text. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: mac typo fix Created 5 years, 9 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 unified diff | Download patch
« ui/gfx/render_text_mac.cc ('K') | « ui/gfx/render_text_mac.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) 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
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
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 example."));
msw 2015/03/02 22:50:55 nit: "This is an example."
Jun Mukai 2015/03/02 23:10:37 Done.
2621 render_text.SetText(text);
2622 render_text.EnsureLayout();
2623 // Note that glyph count matches to the text length because all the characters
msw 2015/03/02 22:50:55 nit: "// NOTE: Character and glyph counts are only
Jun Mukai 2015/03/02 23:10:37 Done.
2624 // in |text| is simple.
2625 EXPECT_EQ(text.size(), CTLineGetGlyphCount(render_text.line_));
2626
2627 render_text.SetElideBehavior(ELIDE_TAIL);
2628 gfx::Size string_size = render_text.GetStringSize();
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(), CTLineGetGlyphCount(render_text.line_));
2633 }
2634 #endif
2635
2611 } // namespace gfx 2636 } // namespace gfx
OLDNEW
« ui/gfx/render_text_mac.cc ('K') | « ui/gfx/render_text_mac.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698