Chromium Code Reviews| 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 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2570 EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5))); | 2570 EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5))); |
| 2571 EXPECT_EQ(Range(0, 0), | 2571 EXPECT_EQ(Range(0, 0), |
| 2572 internal::RoundRangeF(run.GetGraphemeBounds(iter.get(), 4))); | 2572 internal::RoundRangeF(run.GetGraphemeBounds(iter.get(), 4))); |
| 2573 Range chars; | 2573 Range chars; |
| 2574 Range glyphs; | 2574 Range glyphs; |
| 2575 run.GetClusterAt(4, &chars, &glyphs); | 2575 run.GetClusterAt(4, &chars, &glyphs); |
| 2576 EXPECT_EQ(Range(3, 8), chars); | 2576 EXPECT_EQ(Range(3, 8), chars); |
| 2577 EXPECT_EQ(Range(0, 0), glyphs); | 2577 EXPECT_EQ(Range(0, 0), glyphs); |
| 2578 } | 2578 } |
| 2579 | 2579 |
| 2580 TEST_F(RenderTextTest, HarfBuzz_InfiniteLoop) { | |
|
Daniel Erat
2015/03/17 23:26:00
nit: mind adding a comment pointing back at the bu
Jun Mukai
2015/03/18 01:32:05
added
| |
| 2581 RenderTextHarfBuzz render_text; | |
| 2582 render_text.SetObscured(true); | |
| 2583 render_text.SetText(UTF8ToUTF16("\xF0\x9F\x98\x81y")); | |
| 2584 render_text.ApplyStyle(BOLD, true, Range(1, 3)); | |
| 2585 gfx::Canvas canvas; | |
| 2586 render_text.Draw(&canvas); | |
| 2587 } | |
| 2588 | |
| 2580 // Ensure a string fits in a display rect with a width equal to the string's. | 2589 // Ensure a string fits in a display rect with a width equal to the string's. |
| 2581 TEST_F(RenderTextTest, StringFitsOwnWidth) { | 2590 TEST_F(RenderTextTest, StringFitsOwnWidth) { |
| 2582 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 2591 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
| 2583 const base::string16 kString = ASCIIToUTF16("www.example.com"); | 2592 const base::string16 kString = ASCIIToUTF16("www.example.com"); |
| 2584 | 2593 |
| 2585 render_text->SetText(kString); | 2594 render_text->SetText(kString); |
| 2586 render_text->ApplyStyle(BOLD, true, Range(0, 3)); | 2595 render_text->ApplyStyle(BOLD, true, Range(0, 3)); |
| 2587 render_text->SetElideBehavior(ELIDE_TAIL); | 2596 render_text->SetElideBehavior(ELIDE_TAIL); |
| 2588 | 2597 |
| 2589 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); | 2598 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2822 string_size.set_width(string_size.width() / 2); | 2831 string_size.set_width(string_size.width() / 2); |
| 2823 render_text.SetDisplayRect(gfx::Rect(string_size)); | 2832 render_text.SetDisplayRect(gfx::Rect(string_size)); |
| 2824 render_text.EnsureLayout(); | 2833 render_text.EnsureLayout(); |
| 2825 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); | 2834 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); |
| 2826 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); | 2835 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); |
| 2827 EXPECT_NE(0, glyph_count); | 2836 EXPECT_NE(0, glyph_count); |
| 2828 } | 2837 } |
| 2829 #endif | 2838 #endif |
| 2830 | 2839 |
| 2831 } // namespace gfx | 2840 } // namespace gfx |
| OLD | NEW |