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

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

Issue 993153003: Prevent infinite loop about itemizing text in RenderTextHarfBuzz. 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
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 2559 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 // Ensures RenderTextHarfBuzz::ItemizeTextToRuns() does not enter into an
2581 // infinite loop. See crbug.com/403892.
2582 TEST_F(RenderTextTest, HarfBuzz_InfiniteLoop) {
2583 RenderTextHarfBuzz render_text;
2584 render_text.SetObscured(true);
2585 render_text.SetText(UTF8ToUTF16("\xF0\x9F\x98\x81y"));
2586 gfx::Canvas canvas;
2587 render_text.Draw(&canvas);
2588 }
2589
2580 // Ensure a string fits in a display rect with a width equal to the string's. 2590 // Ensure a string fits in a display rect with a width equal to the string's.
2581 TEST_F(RenderTextTest, StringFitsOwnWidth) { 2591 TEST_F(RenderTextTest, StringFitsOwnWidth) {
2582 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 2592 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
2583 const base::string16 kString = ASCIIToUTF16("www.example.com"); 2593 const base::string16 kString = ASCIIToUTF16("www.example.com");
2584 2594
2585 render_text->SetText(kString); 2595 render_text->SetText(kString);
2586 render_text->ApplyStyle(BOLD, true, Range(0, 3)); 2596 render_text->ApplyStyle(BOLD, true, Range(0, 3));
2587 render_text->SetElideBehavior(ELIDE_TAIL); 2597 render_text->SetElideBehavior(ELIDE_TAIL);
2588 2598
2589 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); 2599 render_text->SetDisplayRect(Rect(0, 0, 500, 100));
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
2822 string_size.set_width(string_size.width() / 2); 2832 string_size.set_width(string_size.width() / 2);
2823 render_text.SetDisplayRect(gfx::Rect(string_size)); 2833 render_text.SetDisplayRect(gfx::Rect(string_size));
2824 render_text.EnsureLayout(); 2834 render_text.EnsureLayout();
2825 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); 2835 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_);
2826 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); 2836 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count));
2827 EXPECT_NE(0, glyph_count); 2837 EXPECT_NE(0, glyph_count);
2828 } 2838 }
2829 #endif 2839 #endif
2830 2840
2831 } // namespace gfx 2841 } // namespace gfx
OLDNEW
« ui/gfx/render_text_harfbuzz.cc ('K') | « ui/gfx/render_text_harfbuzz.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698