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

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

Issue 324983002: Move unusual character block logic to a helper function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/gfx/render_text_harfbuzz.cc ('k') | ui/gfx/render_text_win.cc » ('j') | 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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 1896
1897 const Range second_expected_range = kTestStrings[i].second_line_char_range; 1897 const Range second_expected_range = kTestStrings[i].second_line_char_range;
1898 ASSERT_EQ(second_expected_range.IsValid() ? 1U : 0U, 1898 ASSERT_EQ(second_expected_range.IsValid() ? 1U : 0U,
1899 render_text->lines_[1].segments.size()); 1899 render_text->lines_[1].segments.size());
1900 if (second_expected_range.IsValid()) 1900 if (second_expected_range.IsValid())
1901 EXPECT_EQ(second_expected_range, 1901 EXPECT_EQ(second_expected_range,
1902 render_text->lines_[1].segments[0].char_range); 1902 render_text->lines_[1].segments[0].char_range);
1903 } 1903 }
1904 } 1904 }
1905 1905
1906
1907 TEST_F(RenderTextTest, Win_BreakRunsByUnicodeBlocks) { 1906 TEST_F(RenderTextTest, Win_BreakRunsByUnicodeBlocks) {
1908 scoped_ptr<RenderTextWin> render_text( 1907 scoped_ptr<RenderTextWin> render_text(
1909 static_cast<RenderTextWin*>(RenderText::CreateInstance())); 1908 static_cast<RenderTextWin*>(RenderText::CreateInstance()));
1910 1909
1911 // The '\x25B6' "play character" should break runs. http://crbug.com/278913 1910 // The '\x25B6' "play character" should break runs. http://crbug.com/278913
1912 render_text->SetText(WideToUTF16(L"x\x25B6y")); 1911 render_text->SetText(WideToUTF16(L"x\x25B6y"));
1913 render_text->EnsureLayout(); 1912 render_text->EnsureLayout();
1914 ASSERT_EQ(3U, render_text->runs_.size()); 1913 ASSERT_EQ(3U, render_text->runs_.size());
1915 EXPECT_EQ(Range(0, 1), render_text->runs_[0]->range); 1914 EXPECT_EQ(Range(0, 1), render_text->runs_[0]->range);
1916 EXPECT_EQ(Range(1, 2), render_text->runs_[1]->range); 1915 EXPECT_EQ(Range(1, 2), render_text->runs_[1]->range);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1967 std::copy(cases[i].glyph_to_char, cases[i].glyph_to_char + 4, 1966 std::copy(cases[i].glyph_to_char, cases[i].glyph_to_char + 4,
1968 run.glyph_to_char.get()); 1967 run.glyph_to_char.get());
1969 run.is_rtl = cases[i].is_rtl; 1968 run.is_rtl = cases[i].is_rtl;
1970 for (size_t j = 0; j < 4; ++j) { 1969 for (size_t j = 0; j < 4; ++j) {
1971 SCOPED_TRACE(base::StringPrintf("Case %" PRIuS ", char %" PRIuS, i, j)); 1970 SCOPED_TRACE(base::StringPrintf("Case %" PRIuS ", char %" PRIuS, i, j));
1972 EXPECT_EQ(cases[i].char_to_glyph_expected[j], run.CharToGlyph(j)); 1971 EXPECT_EQ(cases[i].char_to_glyph_expected[j], run.CharToGlyph(j));
1973 EXPECT_EQ(cases[i].char_range_to_glyph_range_expected[j], 1972 EXPECT_EQ(cases[i].char_range_to_glyph_range_expected[j],
1974 run.CharRangeToGlyphRange(Range(j, j + 1))); 1973 run.CharRangeToGlyphRange(Range(j, j + 1)));
1975 } 1974 }
1976 } 1975 }
1977
1978 } 1976 }
1979 1977
1980 TEST_F(RenderTextTest, HarfBuzz_RunDirection) { 1978 TEST_F(RenderTextTest, HarfBuzz_RunDirection) {
1981 RenderTextHarfBuzz render_text; 1979 RenderTextHarfBuzz render_text;
1982 const base::string16 mixed = 1980 const base::string16 mixed =
1983 WideToUTF16(L"\x05D0\x05D1" L"1234" L"\x05D2\x05D3"); 1981 WideToUTF16(L"\x05D0\x05D1" L"1234" L"\x05D2\x05D3");
1984 render_text.SetText(mixed); 1982 render_text.SetText(mixed);
1985 render_text.EnsureLayout(); 1983 render_text.EnsureLayout();
1986 ASSERT_EQ(3U, render_text.runs_.size()); 1984 ASSERT_EQ(3U, render_text.runs_.size());
1987 EXPECT_TRUE(render_text.runs_[0]->is_rtl); 1985 EXPECT_TRUE(render_text.runs_[0]->is_rtl);
1988 EXPECT_FALSE(render_text.runs_[1]->is_rtl); 1986 EXPECT_FALSE(render_text.runs_[1]->is_rtl);
1989 EXPECT_TRUE(render_text.runs_[2]->is_rtl); 1987 EXPECT_TRUE(render_text.runs_[2]->is_rtl);
1990 } 1988 }
1991 1989
1990 TEST_F(RenderTextTest, HarfBuzz_BreakRunsByUnicodeBlocks) {
1991 RenderTextHarfBuzz render_text;
1992
1993 // The '\x25B6' "play character" should break runs. http://crbug.com/278913
1994 render_text.SetText(WideToUTF16(L"x\x25B6y"));
1995 render_text.EnsureLayout();
1996 ASSERT_EQ(3U, render_text.runs_.size());
1997 EXPECT_EQ(Range(0, 1), render_text.runs_[0]->range);
1998 EXPECT_EQ(Range(1, 2), render_text.runs_[1]->range);
1999 EXPECT_EQ(Range(2, 3), render_text.runs_[2]->range);
2000
2001 render_text.SetText(WideToUTF16(L"x \x25B6 y"));
2002 render_text.EnsureLayout();
2003 ASSERT_EQ(3U, render_text.runs_.size());
2004 EXPECT_EQ(Range(0, 2), render_text.runs_[0]->range);
2005 EXPECT_EQ(Range(2, 3), render_text.runs_[1]->range);
2006 EXPECT_EQ(Range(3, 5), render_text.runs_[2]->range);
2007 }
2008
1992 } // namespace gfx 2009 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text_harfbuzz.cc ('k') | ui/gfx/render_text_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698