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

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: 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 2578 matching lines...) Expand 10 before | Expand all | Expand 10 after
2619 SkColor color = buffer[width + y * kCanvasSize.width()]; 2625 SkColor color = buffer[width + y * kCanvasSize.width()];
2620 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string; 2626 EXPECT_LT(220U, color_utils::GetLuminanceForColor(color)) << string;
2621 for (int x = 1; x < kTestWidth; ++x) { 2627 for (int x = 1; x < kTestWidth; ++x) {
2622 color = buffer[width + x + y * kCanvasSize.width()]; 2628 color = buffer[width + x + y * kCanvasSize.width()];
2623 EXPECT_EQ(SK_ColorWHITE, color) << string; 2629 EXPECT_EQ(SK_ColorWHITE, color) << string;
2624 } 2630 }
2625 } 2631 }
2626 } 2632 }
2627 } 2633 }
2628 2634
2635 #if defined(OS_MACOSX)
2636 TEST_F(RenderTextTest, Mac_ElidedText) {
2637 RenderTextMac render_text;
2638 base::string16 text(ASCIIToUTF16("This is an example."));
2639 render_text.SetText(text);
2640 render_text.EnsureLayout();
2641 // NOTE: Character and glyph counts are only comparable for simple text.
2642 EXPECT_EQ(text.size(),
2643 static_cast<size_t>(CTLineGetGlyphCount(render_text.line_)));
2644
2645 render_text.SetElideBehavior(ELIDE_TAIL);
2646 gfx::Size string_size = render_text.GetStringSize();
2647 string_size.set_width(string_size.width() / 2);
2648 render_text.SetDisplayRect(gfx::Rect(string_size));
2649 render_text.EnsureLayout();
2650 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_);
2651 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count));
2652 EXPECT_NE(0, glyph_count);
2653 }
2654 #endif
2655
2629 } // namespace gfx 2656 } // 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