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

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

Issue 876873003: Add float version of gfx::Range (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments addressed 2 Created 5 years, 10 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
« no previous file with comments | « ui/gfx/render_text_harfbuzz.cc ('k') | no next file » | 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/i18n/break_iterator.h" 10 #include "base/i18n/break_iterator.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/skia/include/core/SkSurface.h" 16 #include "third_party/skia/include/core/SkSurface.h"
17 #include "ui/gfx/break_list.h" 17 #include "ui/gfx/break_list.h"
18 #include "ui/gfx/canvas.h" 18 #include "ui/gfx/canvas.h"
19 #include "ui/gfx/color_utils.h" 19 #include "ui/gfx/color_utils.h"
20 #include "ui/gfx/font.h" 20 #include "ui/gfx/font.h"
21 #include "ui/gfx/range/range.h"
22 #include "ui/gfx/range/range_f.h"
21 #include "ui/gfx/render_text_harfbuzz.h" 23 #include "ui/gfx/render_text_harfbuzz.h"
22 24
23 #if defined(OS_WIN) 25 #if defined(OS_WIN)
24 #include "base/win/windows_version.h" 26 #include "base/win/windows_version.h"
25 #include "ui/gfx/platform_font_win.h" 27 #include "ui/gfx/platform_font_win.h"
26 #endif 28 #endif
27 29
28 using base::ASCIIToUTF16; 30 using base::ASCIIToUTF16;
29 using base::UTF8ToUTF16; 31 using base::UTF8ToUTF16;
30 using base::WideToUTF16; 32 using base::WideToUTF16;
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 base::string16 text = WideToUTF16(cases[i]); 2099 base::string16 text = WideToUTF16(cases[i]);
2098 render_text.SetText(text); 2100 render_text.SetText(text);
2099 render_text.EnsureLayout(); 2101 render_text.EnsureLayout();
2100 ASSERT_EQ(1U, render_text.runs_.size()); 2102 ASSERT_EQ(1U, render_text.runs_.size());
2101 internal::TextRunHarfBuzz* run = render_text.runs_[0]; 2103 internal::TextRunHarfBuzz* run = render_text.runs_[0];
2102 2104
2103 base::i18n::BreakIterator* iter = render_text.grapheme_iterator_.get(); 2105 base::i18n::BreakIterator* iter = render_text.grapheme_iterator_.get();
2104 auto first_grapheme_bounds = run->GetGraphemeBounds(iter, 0); 2106 auto first_grapheme_bounds = run->GetGraphemeBounds(iter, 0);
2105 EXPECT_EQ(first_grapheme_bounds, run->GetGraphemeBounds(iter, 1)); 2107 EXPECT_EQ(first_grapheme_bounds, run->GetGraphemeBounds(iter, 1));
2106 auto second_grapheme_bounds = run->GetGraphemeBounds(iter, 2); 2108 auto second_grapheme_bounds = run->GetGraphemeBounds(iter, 2);
2107 EXPECT_EQ(first_grapheme_bounds.second, second_grapheme_bounds.first); 2109 EXPECT_EQ(first_grapheme_bounds.end(), second_grapheme_bounds.start());
2108 } 2110 }
2109 } 2111 }
2110 2112
2111 // Test the partition of a multi-grapheme cluster into grapheme ranges. 2113 // Test the partition of a multi-grapheme cluster into grapheme ranges.
2112 TEST_F(RenderTextTest, HarfBuzz_SubglyphGraphemePartition) { 2114 TEST_F(RenderTextTest, HarfBuzz_SubglyphGraphemePartition) {
2113 struct { 2115 struct {
2114 uint32 glyph_to_char[2]; 2116 uint32 glyph_to_char[2];
2115 Range bounds[4]; 2117 Range bounds[4];
2116 bool is_rtl; 2118 bool is_rtl;
2117 } cases[] = { 2119 } cases[] = {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting())); 2385 base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting()));
2384 2386
2385 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 2387 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
2386 render_text->SetDisplayRect(Rect(0, 0, 25, 25)); 2388 render_text->SetDisplayRect(Rect(0, 0, 25, 25));
2387 render_text->SetFontList(font_list); 2389 render_text->SetFontList(font_list);
2388 EXPECT_GT(render_text->GetBaseline(), font_list.GetBaseline()); 2390 EXPECT_GT(render_text->GetBaseline(), font_list.GetBaseline());
2389 } 2391 }
2390 #endif 2392 #endif
2391 2393
2392 } // namespace gfx 2394 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/render_text_harfbuzz.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698