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

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

Issue 1020853018: DNCI [RenderText] Added font size options in RenderText. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added font sizes to mac font style iterator 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
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 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 << ", width " << width << ", stride_ " 195 << ", width " << width << ", stride_ "
196 << stride_; 196 << stride_;
197 for (int y = top; y < top + height; ++y) { 197 for (int y = top; y < top + height; ++y) {
198 for (int x = left; x < left + width; ++x) { 198 for (int x = left; x < left + width; ++x) {
199 SkColor buffer_color = buffer_[x + y * stride_]; 199 SkColor buffer_color = buffer_[x + y * stride_];
200 EXPECT_EQ(color, buffer_color) << string_ << " at " << x << ", " << y; 200 EXPECT_EQ(color, buffer_color) << string_ << " at " << x << ", " << y;
201 } 201 }
202 } 202 }
203 } 203 }
204 204
205 void EnsureSolidBorder(SkColor color, const Rect& rect) const {
206 {
207 SCOPED_TRACE("EnsureSolidBorder Top Side");
208 EnsureSolidRect(SK_ColorWHITE, 0, 0, stride_, rect.y());
209 }
210 {
211 SCOPED_TRACE("EnsureSolidBorder Bottom Side");
212 EnsureSolidRect(SK_ColorWHITE, 0, rect.y() + rect.height(), stride_,
213 row_count_ - rect.y() - rect.height());
214 }
215 {
216 SCOPED_TRACE("EnsureSolidBorder Left Side");
217 EnsureSolidRect(SK_ColorWHITE, 0, rect.y(), rect.x(), rect.height());
218 }
219 {
220 SCOPED_TRACE("EnsureSolidBorder Right Side");
221 EnsureSolidRect(SK_ColorWHITE, rect.x() + rect.width(), rect.y(),
222 stride_ - rect.x() - rect.width(), rect.height());
223 }
224 }
225
205 private: 226 private:
206 const wchar_t* string_; 227 const wchar_t* string_;
207 const SkColor* buffer_; 228 const SkColor* buffer_;
208 int stride_; 229 int stride_;
209 int row_count_; 230 int row_count_;
210 231
211 DISALLOW_COPY_AND_ASSIGN(TestRectangleBuffer); 232 DISALLOW_COPY_AND_ASSIGN(TestRectangleBuffer);
212 }; 233 };
213 234
214 } // namespace 235 } // namespace
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 668 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
648 render_text->set_truncate_length(5); 669 render_text->set_truncate_length(5);
649 for (size_t i = 0; i < arraysize(cases); i++) { 670 for (size_t i = 0; i < arraysize(cases); i++) {
650 render_text->SetText(WideToUTF16(cases[i].text)); 671 render_text->SetText(WideToUTF16(cases[i].text));
651 EXPECT_EQ(WideToUTF16(cases[i].text), render_text->text()); 672 EXPECT_EQ(WideToUTF16(cases[i].text), render_text->text());
652 EXPECT_EQ(WideToUTF16(cases[i].display_text), render_text->GetDisplayText()) 673 EXPECT_EQ(WideToUTF16(cases[i].display_text), render_text->GetDisplayText())
653 << "For case " << i << ": " << cases[i].text; 674 << "For case " << i << ": " << cases[i].text;
654 } 675 }
655 } 676 }
656 677
678 TEST_F(RenderTextTest, FontSize) {
679 SCOPED_TRACE("FontSize");
680 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
681 const wchar_t* string = L"0gl1gl2gl3gl";
682 render_text->SetText(WideToUTF16(string));
683 const Size kCanvasSize(150, 50);
684 const int kTestSize = 10;
685
686 struct Tests {
687 int a_size;
688 int b_size;
689 int c_size;
690 BaselineStyle a_baseline;
691 bool b_bold;
692 SkColor c_color;
693 } const kTests[] = {
694 {18, 26, 0, NORMAL_BASELINE, false, SK_ColorBLACK},
695 {26, 18, 8, SUPERSCRIPT, true, SK_ColorLTGRAY},
696 {18, 26, 0, INFERIOR, false, SK_ColorRED},
697 {26, 18, 8, SUPERIOR, true, SK_ColorBLUE},
698 };
699
700 render_text->SetHorizontalAlignment(ALIGN_LEFT);
701 render_text->SetVerticalAlignment(VALIGN_TOP);
702 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
703 SkSurface::NewRasterN32Premul(kCanvasSize.width(), kCanvasSize.height()));
704 scoped_ptr<Canvas> canvas(
705 Canvas::CreateCanvasWithoutScaling(surface->getCanvas(), 1.0f));
706 Rect bounds = Rect(kTestSize, kTestSize, kCanvasSize.width() - kTestSize * 2,
707 kCanvasSize.height() - kTestSize * 2);
708 render_text->SetDisplayRect(bounds);
709 render_text->set_clip_to_display_rect(false);
710 const uint32* buffer =
711 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr));
712 ASSERT_NE(nullptr, buffer);
713 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(),
714 kCanvasSize.height());
715 for (const auto& test : kTests) {
716 surface->getCanvas()->clear(SK_ColorWHITE);
717 render_text->ApplyFontSize(test.a_size, Range(0, 3));
718 render_text->ApplyFontSize(test.b_size, Range(3, 6));
719 render_text->ApplyFontSize(test.c_size, Range(6, 9));
720 render_text->ApplyBaselineStyle(test.a_baseline, Range(2, 3));
721 render_text->ApplyStyle(BOLD, test.b_bold, Range(4, 6));
722 render_text->ApplyColor(test.c_color, Range(7, 9));
723 const Size string_size = render_text->GetStringSize();
724 ASSERT_LE(string_size.width() + kTestSize * 2, kCanvasSize.width());
725 ASSERT_LE(string_size.height() + kTestSize * 2, kCanvasSize.height());
726 Rect expected_rect(kTestSize, kTestSize, string_size.width(),
727 string_size.height());
728 render_text->Draw(canvas.get());
729 expected_rect.Inset(-1, -1);
730 rect_buffer.EnsureSolidBorder(SK_ColorWHITE, expected_rect);
731 }
732 }
733
657 TEST_F(RenderTextTest, TruncatedObscuredText) { 734 TEST_F(RenderTextTest, TruncatedObscuredText) {
658 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 735 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
659 render_text->set_truncate_length(3); 736 render_text->set_truncate_length(3);
660 render_text->SetObscured(true); 737 render_text->SetObscured(true);
661 render_text->SetText(WideToUTF16(L"abcdef")); 738 render_text->SetText(WideToUTF16(L"abcdef"));
662 EXPECT_EQ(WideToUTF16(L"abcdef"), render_text->text()); 739 EXPECT_EQ(WideToUTF16(L"abcdef"), render_text->text());
663 EXPECT_EQ(WideToUTF16(L"**\x2026"), render_text->GetDisplayText()); 740 EXPECT_EQ(WideToUTF16(L"**\x2026"), render_text->GetDisplayText());
664 } 741 }
665 742
666 TEST_F(RenderTextTest, TruncatedCursorMovementLTR) { 743 TEST_F(RenderTextTest, TruncatedCursorMovementLTR) {
(...skipping 1918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2585 render_text->SetText(kString); 2662 render_text->SetText(kString);
2586 render_text->ApplyStyle(BOLD, true, Range(0, 3)); 2663 render_text->ApplyStyle(BOLD, true, Range(0, 3));
2587 render_text->SetElideBehavior(ELIDE_TAIL); 2664 render_text->SetElideBehavior(ELIDE_TAIL);
2588 2665
2589 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); 2666 render_text->SetDisplayRect(Rect(0, 0, 500, 100));
2590 EXPECT_EQ(kString, render_text->GetDisplayText()); 2667 EXPECT_EQ(kString, render_text->GetDisplayText());
2591 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100)); 2668 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100));
2592 EXPECT_EQ(kString, render_text->GetDisplayText()); 2669 EXPECT_EQ(kString, render_text->GetDisplayText());
2593 } 2670 }
2594 2671
2672 TEST_F(RenderTextTest, VerticalAlignement) {
2673 SCOPED_TRACE("VerticalAlignement");
2674 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
2675 const wchar_t* string = L"g Hello g";
2676 render_text->SetText(WideToUTF16(string));
2677 render_text->ApplyStyle(BOLD, true, Range(0, 3));
2678 const Size kCanvasSize(300, 50);
2679 const int kTestSize = 10;
2680 const Size string_size = render_text->GetStringSize();
2681 const int kCenterBegin = (kCanvasSize.width() - string_size.width()) / 2;
2682 const int kRightBegin = kCanvasSize.width() - string_size.width() - kTestSize;
2683 const int kMiddleBegin = (kCanvasSize.height() - string_size.height()) / 2;
2684 const int kBottomBegin =
2685 kCanvasSize.height() - string_size.height() - kTestSize;
2686
2687 struct Tests {
2688 HorizontalAlignment horizontal;
2689 VerticalAlignment vertical;
2690 int x;
2691 int y;
2692 } const kTests[] = {
2693 {ALIGN_LEFT, VALIGN_TOP, kTestSize, kTestSize},
2694 {ALIGN_LEFT, VALIGN_MIDDLE, kTestSize, kMiddleBegin},
2695 {ALIGN_LEFT, VALIGN_BOTTOM, kTestSize, kBottomBegin},
2696 {ALIGN_CENTER, VALIGN_TOP, kCenterBegin, kTestSize},
2697 {ALIGN_CENTER, VALIGN_MIDDLE, kCenterBegin, kMiddleBegin},
2698 {ALIGN_CENTER, VALIGN_BOTTOM, kCenterBegin, kBottomBegin},
2699 {ALIGN_RIGHT, VALIGN_TOP, kRightBegin, kTestSize},
2700 {ALIGN_RIGHT, VALIGN_MIDDLE, kRightBegin, kMiddleBegin},
2701 {ALIGN_RIGHT, VALIGN_BOTTOM, kRightBegin, kBottomBegin},
2702 };
2703
2704 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
2705 SkSurface::NewRasterN32Premul(kCanvasSize.width(), kCanvasSize.height()));
2706 scoped_ptr<Canvas> canvas(
2707 Canvas::CreateCanvasWithoutScaling(surface->getCanvas(), 1.0f));
2708 render_text->SetColor(SK_ColorBLACK);
2709 Rect bounds = Rect(kTestSize, kTestSize, kCanvasSize.width() - kTestSize * 2,
2710 kCanvasSize.height() - kTestSize * 2);
2711 render_text->SetDisplayRect(bounds);
2712 // Allow the RenderText to paint outside of its display rect.
2713 render_text->set_clip_to_display_rect(false);
2714 const uint32* buffer =
2715 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr));
2716 ASSERT_NE(nullptr, buffer);
2717 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(),
2718 kCanvasSize.height());
2719 ASSERT_LE(string_size.width() + kTestSize * 2, kCanvasSize.width());
2720 for (const auto& test : kTests) {
2721 surface->getCanvas()->clear(SK_ColorWHITE);
2722 render_text->SetHorizontalAlignment(test.horizontal);
2723 render_text->SetVerticalAlignment(test.vertical);
2724 Rect expected_rect(test.x, test.y, string_size.width(),
2725 string_size.height());
2726 // canvas->DrawRect(expected_rect, SK_ColorLTGRAY); //////////////////////
2727 expected_rect.Inset(-1, -1);
2728 render_text->Draw(canvas.get());
2729 // rect_buffer.Draw();
2730 rect_buffer.EnsureSolidBorder(SK_ColorWHITE, expected_rect);
2731 }
2732 }
2733
2595 // TODO(derat): Figure out why this fails on Windows: http://crbug.com/427184 2734 // TODO(derat): Figure out why this fails on Windows: http://crbug.com/427184
2596 #if !defined(OS_WIN) 2735 #if !defined(OS_WIN)
2597 // Ensure that RenderText examines all of the fonts in its FontList before 2736 // Ensure that RenderText examines all of the fonts in its FontList before
2598 // falling back to other fonts. 2737 // falling back to other fonts.
2599 TEST_F(RenderTextTest, HarfBuzz_FontListFallback) { 2738 TEST_F(RenderTextTest, HarfBuzz_FontListFallback) {
2600 // Double-check that the requested fonts are present. 2739 // Double-check that the requested fonts are present.
2601 FontList font_list("Arial, Symbol, 12px"); 2740 FontList font_list("Arial, Symbol, 12px");
2602 const std::vector<Font>& fonts = font_list.GetFonts(); 2741 const std::vector<Font>& fonts = font_list.GetFonts();
2603 ASSERT_EQ(2u, fonts.size()); 2742 ASSERT_EQ(2u, fonts.size());
2604 ASSERT_EQ("arial", 2743 ASSERT_EQ("arial",
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
2692 render_text->ApplyBaselineStyle(INFERIOR, Range(5, 6)); 2831 render_text->ApplyBaselineStyle(INFERIOR, Range(5, 6));
2693 render_text->ApplyBaselineStyle(SUBSCRIPT, Range(7, 8)); 2832 render_text->ApplyBaselineStyle(SUBSCRIPT, Range(7, 8));
2694 render_text->SetStyle(BOLD, true); 2833 render_text->SetStyle(BOLD, true);
2695 render_text->SetDisplayRect( 2834 render_text->SetDisplayRect(
2696 Rect(kTestSize, kTestSize, string_size.width(), string_size.height())); 2835 Rect(kTestSize, kTestSize, string_size.width(), string_size.height()));
2697 // Allow the RenderText to paint outside of its display rect. 2836 // Allow the RenderText to paint outside of its display rect.
2698 render_text->set_clip_to_display_rect(false); 2837 render_text->set_clip_to_display_rect(false);
2699 ASSERT_LE(string_size.width() + kTestSize * 2, kCanvasSize.width()); 2838 ASSERT_LE(string_size.width() + kTestSize * 2, kCanvasSize.width());
2700 2839
2701 render_text->Draw(canvas.get()); 2840 render_text->Draw(canvas.get());
2702 ASSERT_LT(string_size.width() + kTestSize, kCanvasSize.width());
2703 const uint32* buffer = 2841 const uint32* buffer =
2704 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr)); 2842 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr));
2705 ASSERT_NE(nullptr, buffer); 2843 ASSERT_NE(nullptr, buffer);
2706 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(), 2844 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(),
2707 kCanvasSize.height()); 2845 kCanvasSize.height());
2846 // TODO(dschuyler): After platform issued are resolved below, change to
2847 // using EnsureSolidBorder() rather than EnsureSolidRect().
2708 { 2848 {
2709 #if !defined(OS_CHROMEOS) 2849 #if !defined(OS_CHROMEOS)
2710 // TODO(dschuyler): On ChromeOS text draws above the GetStringSize rect. 2850 // TODO(dschuyler): On ChromeOS text draws above the GetStringSize rect.
2711 SCOPED_TRACE("TextDoesntClip Top Side"); 2851 SCOPED_TRACE("TextDoesntClip Top Side");
2712 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, 0, kCanvasSize.width(), 2852 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, 0, kCanvasSize.width(),
2713 kTestSize); 2853 kTestSize);
2714 #endif 2854 #endif
2715 } 2855 }
2716 { 2856 {
2717 SCOPED_TRACE("TextDoesntClip Bottom Side"); 2857 SCOPED_TRACE("TextDoesntClip Bottom Side");
(...skipping 29 matching lines...) Expand all
2747 kTestSize + string_size.width(), kTestSize, 2887 kTestSize + string_size.width(), kTestSize,
2748 kTestSize, string_size.height()); 2888 kTestSize, string_size.height());
2749 #endif 2889 #endif
2750 } 2890 }
2751 } 2891 }
2752 } 2892 }
2753 2893
2754 // Ensure that the text will clip to the display rect. Draws to a canvas and 2894 // Ensure that the text will clip to the display rect. Draws to a canvas and
2755 // checks whether any pixel beyond the bounding rectangle is colored. 2895 // checks whether any pixel beyond the bounding rectangle is colored.
2756 TEST_F(RenderTextTest, TextDoesClip) { 2896 TEST_F(RenderTextTest, TextDoesClip) {
2897 SCOPED_TRACE("TextDoesClip");
2757 const wchar_t* kTestStrings[] = {L"TEST", L"W", L"WWWW", L"gAXAXWWWW"}; 2898 const wchar_t* kTestStrings[] = {L"TEST", L"W", L"WWWW", L"gAXAXWWWW"};
2758 const Size kCanvasSize(300, 50); 2899 const Size kCanvasSize(300, 50);
2759 const int kTestSize = 10; 2900 const int kTestSize = 10;
2760 2901
2761 skia::RefPtr<SkSurface> surface = skia::AdoptRef( 2902 skia::RefPtr<SkSurface> surface = skia::AdoptRef(
2762 SkSurface::NewRasterN32Premul(kCanvasSize.width(), kCanvasSize.height())); 2903 SkSurface::NewRasterN32Premul(kCanvasSize.width(), kCanvasSize.height()));
2763 scoped_ptr<Canvas> canvas( 2904 scoped_ptr<Canvas> canvas(
2764 Canvas::CreateCanvasWithoutScaling(surface->getCanvas(), 1.0f)); 2905 Canvas::CreateCanvasWithoutScaling(surface->getCanvas(), 1.0f));
2765 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 2906 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
2766 render_text->SetHorizontalAlignment(ALIGN_LEFT); 2907 render_text->SetHorizontalAlignment(ALIGN_LEFT);
2767 render_text->SetColor(SK_ColorBLACK); 2908 render_text->SetColor(SK_ColorBLACK);
2768 2909
2769 for (auto string : kTestStrings) { 2910 for (auto string : kTestStrings) {
2770 surface->getCanvas()->clear(SK_ColorWHITE); 2911 surface->getCanvas()->clear(SK_ColorWHITE);
2771 render_text->SetText(WideToUTF16(string)); 2912 render_text->SetText(WideToUTF16(string));
2772 const Size string_size = render_text->GetStringSize(); 2913 const Size string_size = render_text->GetStringSize();
2773 int fake_width = string_size.width() / 2; 2914 int fake_width = string_size.width() / 2;
2774 int fake_height = string_size.height() / 2; 2915 int fake_height = string_size.height() / 2;
2775 render_text->SetDisplayRect( 2916 const Rect bounds(kTestSize, kTestSize, fake_width, fake_height);
2776 Rect(kTestSize, kTestSize, fake_width, fake_height)); 2917 render_text->SetDisplayRect(bounds);
2777 render_text->set_clip_to_display_rect(true); 2918 render_text->set_clip_to_display_rect(true);
2919 ASSERT_LE(string_size.width() + kTestSize * 2, kCanvasSize.width());
2778 render_text->Draw(canvas.get()); 2920 render_text->Draw(canvas.get());
2779 ASSERT_LT(string_size.width() + kTestSize, kCanvasSize.width());
2780 const uint32* buffer = 2921 const uint32* buffer =
2781 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr)); 2922 static_cast<const uint32*>(surface->peekPixels(nullptr, nullptr));
2782 ASSERT_NE(nullptr, buffer); 2923 ASSERT_NE(nullptr, buffer);
2783 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(), 2924 TestRectangleBuffer rect_buffer(string, buffer, kCanvasSize.width(),
2784 kCanvasSize.height()); 2925 kCanvasSize.height());
2785 { 2926 rect_buffer.EnsureSolidBorder(SK_ColorWHITE, bounds);
2786 SCOPED_TRACE("TextDoesClip Top Side");
2787 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, 0, kCanvasSize.width(),
2788 kTestSize);
2789 }
2790
2791 {
2792 SCOPED_TRACE("TextDoesClip Bottom Side");
2793 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, kTestSize + fake_height,
2794 kCanvasSize.width(), kTestSize);
2795 }
2796 {
2797 SCOPED_TRACE("TextDoesClip Left Side");
2798 rect_buffer.EnsureSolidRect(SK_ColorWHITE, 0, kTestSize, kTestSize,
2799 fake_height);
2800 }
2801 {
2802 SCOPED_TRACE("TextDoesClip Right Side");
2803 rect_buffer.EnsureSolidRect(SK_ColorWHITE, kTestSize + fake_width,
2804 kTestSize, kTestSize, fake_height);
2805 }
2806 } 2927 }
2807 } 2928 }
2808 2929
2809 #if defined(OS_MACOSX) 2930 #if defined(OS_MACOSX)
2810 TEST_F(RenderTextTest, Mac_ElidedText) { 2931 TEST_F(RenderTextTest, Mac_ElidedText) {
2811 RenderTextMac render_text; 2932 RenderTextMac render_text;
2812 base::string16 text(ASCIIToUTF16("This is an example.")); 2933 base::string16 text(ASCIIToUTF16("This is an example."));
2813 render_text.SetText(text); 2934 render_text.SetText(text);
2814 gfx::Size string_size = render_text.GetStringSize(); 2935 gfx::Size string_size = render_text.GetStringSize();
2815 render_text.SetDisplayRect(gfx::Rect(string_size)); 2936 render_text.SetDisplayRect(gfx::Rect(string_size));
2816 render_text.EnsureLayout(); 2937 render_text.EnsureLayout();
2817 // NOTE: Character and glyph counts are only comparable for simple text. 2938 // NOTE: Character and glyph counts are only comparable for simple text.
2818 EXPECT_EQ(text.size(), 2939 EXPECT_EQ(text.size(),
2819 static_cast<size_t>(CTLineGetGlyphCount(render_text.line_))); 2940 static_cast<size_t>(CTLineGetGlyphCount(render_text.line_)));
2820 2941
2821 render_text.SetElideBehavior(ELIDE_TAIL); 2942 render_text.SetElideBehavior(ELIDE_TAIL);
2822 string_size.set_width(string_size.width() / 2); 2943 string_size.set_width(string_size.width() / 2);
2823 render_text.SetDisplayRect(gfx::Rect(string_size)); 2944 render_text.SetDisplayRect(gfx::Rect(string_size));
2824 render_text.EnsureLayout(); 2945 render_text.EnsureLayout();
2825 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); 2946 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_);
2826 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); 2947 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count));
2827 EXPECT_NE(0, glyph_count); 2948 EXPECT_NE(0, glyph_count);
2828 } 2949 }
2829 #endif 2950 #endif
2830 2951
2831 } // namespace gfx 2952 } // namespace gfx
OLDNEW
« ui/gfx/render_text.h ('K') | « ui/gfx/render_text_mac.cc ('k') | ui/gfx/text_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698