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 1596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 }; | 1607 }; |
1608 | 1608 |
1609 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(large_content_cases); i++) { | 1609 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(large_content_cases); i++) { |
1610 render_text->SetHorizontalAlignment(large_content_cases[i].alignment); | 1610 render_text->SetHorizontalAlignment(large_content_cases[i].alignment); |
1611 render_text->SetDisplayOffset(large_content_cases[i].offset); | 1611 render_text->SetDisplayOffset(large_content_cases[i].offset); |
1612 EXPECT_EQ(large_content_cases[i].expected_offset, | 1612 EXPECT_EQ(large_content_cases[i].expected_offset, |
1613 render_text->GetUpdatedDisplayOffset().x()); | 1613 render_text->GetUpdatedDisplayOffset().x()); |
1614 } | 1614 } |
1615 } | 1615 } |
1616 | 1616 |
1617 // TODO(ckocagil): Enable for RenderTextHarfBuzz. http://crbug.com/396776 | |
1618 TEST_F(RenderTextTest, SameFontForParentheses) { | 1617 TEST_F(RenderTextTest, SameFontForParentheses) { |
1619 struct { | 1618 struct { |
1620 const base::char16 left_char; | 1619 const base::char16 left_char; |
1621 const base::char16 right_char; | 1620 const base::char16 right_char; |
1622 } punctuation_pairs[] = { | 1621 } punctuation_pairs[] = { |
1623 { '(', ')' }, | 1622 { '(', ')' }, |
1624 { '{', '}' }, | 1623 { '{', '}' }, |
1625 { '<', '>' }, | 1624 { '<', '>' }, |
1626 }; | 1625 }; |
1627 struct { | 1626 struct { |
(...skipping 19 matching lines...) Expand all Loading... |
1647 { WideToUTF16(L"Hello World(\x0915\x093f)Hello World") }, | 1646 { WideToUTF16(L"Hello World(\x0915\x093f)Hello World") }, |
1648 | 1647 |
1649 // Hebrew(English) | 1648 // Hebrew(English) |
1650 { WideToUTF16(L"\x05e0\x05b8(a)") }, | 1649 { WideToUTF16(L"\x05e0\x05b8(a)") }, |
1651 // Hebrew(English)Hebrew | 1650 // Hebrew(English)Hebrew |
1652 { WideToUTF16(L"\x05e0\x05b8(a)\x05e0\x05b8") }, | 1651 { WideToUTF16(L"\x05e0\x05b8(a)\x05e0\x05b8") }, |
1653 // English(Hebrew)English | 1652 // English(Hebrew)English |
1654 { WideToUTF16(L"Hello World(\x05e0\x05b8)Hello World") }, | 1653 { WideToUTF16(L"Hello World(\x05e0\x05b8)Hello World") }, |
1655 }; | 1654 }; |
1656 | 1655 |
1657 scoped_ptr<RenderText> render_text(RenderText::CreateNativeInstance()); | 1656 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
1658 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { | 1657 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { |
1659 base::string16 text = cases[i].text; | 1658 base::string16 text = cases[i].text; |
1660 const size_t start_paren_char_index = text.find('('); | 1659 const size_t start_paren_char_index = text.find('('); |
1661 ASSERT_NE(base::string16::npos, start_paren_char_index); | 1660 ASSERT_NE(base::string16::npos, start_paren_char_index); |
1662 const size_t end_paren_char_index = text.find(')'); | 1661 const size_t end_paren_char_index = text.find(')'); |
1663 ASSERT_NE(base::string16::npos, end_paren_char_index); | 1662 ASSERT_NE(base::string16::npos, end_paren_char_index); |
1664 | 1663 |
1665 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(punctuation_pairs); ++j) { | 1664 for (size_t j = 0; j < ARRAYSIZE_UNSAFE(punctuation_pairs); ++j) { |
1666 text[start_paren_char_index] = punctuation_pairs[j].left_char; | 1665 text[start_paren_char_index] = punctuation_pairs[j].left_char; |
1667 text[end_paren_char_index] = punctuation_pairs[j].right_char; | 1666 text[end_paren_char_index] = punctuation_pairs[j].right_char; |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5))); | 2285 EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5))); |
2287 EXPECT_EQ(Range(0, 0), run.GetGraphemeBounds(iter.get(), 4)); | 2286 EXPECT_EQ(Range(0, 0), run.GetGraphemeBounds(iter.get(), 4)); |
2288 Range chars; | 2287 Range chars; |
2289 Range glyphs; | 2288 Range glyphs; |
2290 run.GetClusterAt(4, &chars, &glyphs); | 2289 run.GetClusterAt(4, &chars, &glyphs); |
2291 EXPECT_EQ(Range(3, 8), chars); | 2290 EXPECT_EQ(Range(3, 8), chars); |
2292 EXPECT_EQ(Range(0, 0), glyphs); | 2291 EXPECT_EQ(Range(0, 0), glyphs); |
2293 } | 2292 } |
2294 | 2293 |
2295 } // namespace gfx | 2294 } // namespace gfx |
OLD | NEW |