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 2244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2255 | 2255 |
| 2256 for (size_t i = 0; i < arraysize(kTestStrings); ++i) { | 2256 for (size_t i = 0; i < arraysize(kTestStrings); ++i) { |
| 2257 render_text->SetText(WideToUTF16(kTestStrings[i])); | 2257 render_text->SetText(WideToUTF16(kTestStrings[i])); |
| 2258 render_text->EnsureLayout(); | 2258 render_text->EnsureLayout(); |
| 2259 | 2259 |
| 2260 for (size_t j = 0; j < render_text->text().length(); ++j) | 2260 for (size_t j = 0; j < render_text->text().length(); ++j) |
| 2261 EXPECT_FALSE(render_text->GetGlyphBounds(j).is_empty()); | 2261 EXPECT_FALSE(render_text->GetGlyphBounds(j).is_empty()); |
| 2262 } | 2262 } |
| 2263 } | 2263 } |
| 2264 | 2264 |
| 2265 // Try shaping with fonts that don't exist on the system. | |
|
msw
2014/08/02 18:05:33
Consider: "// Ensure that shaping with a non-exist
ckocagil
2014/08/03 03:36:55
Done.
| |
| 2266 TEST_F(RenderTextTest, HarfBuzz_NonExistentFont) { | |
| 2267 RenderTextHarfBuzz render_text; | |
| 2268 | |
|
msw
2014/08/02 18:05:33
nit: remove blank line
ckocagil
2014/08/03 03:36:55
Done.
| |
| 2269 render_text.SetText(ASCIIToUTF16("test")); | |
| 2270 render_text.EnsureLayout(); | |
| 2271 ASSERT_EQ(1U, render_text.runs_.size()); | |
| 2272 internal::TextRunHarfBuzz* run = render_text.runs_[0]; | |
| 2273 render_text.ShapeRunWithFont(run, "TheFontThatDoesntExist"); | |
| 2274 } | |
| 2275 | |
| 2276 // Ensure an empty run returns sane values to queries. | |
| 2277 TEST_F(RenderTextTest, HarfBuzz_EmptyRun) { | |
| 2278 internal::TextRunHarfBuzz run; | |
| 2279 const base::string16 kString = ASCIIToUTF16("abcdefgh"); | |
| 2280 scoped_ptr<base::i18n::BreakIterator> iter(new base::i18n::BreakIterator( | |
| 2281 kString, base::i18n::BreakIterator::BREAK_CHARACTER)); | |
| 2282 ASSERT_TRUE(iter->Init()); | |
| 2283 | |
| 2284 run.range = Range(3, 8); | |
| 2285 run.glyph_count = 0; | |
| 2286 EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5))); | |
| 2287 EXPECT_EQ(Range(0, 0), run.GetGraphemeBounds(iter.get(), 4)); | |
| 2288 Range chars; | |
| 2289 Range glyphs; | |
| 2290 run.GetClusterAt(4, &chars, &glyphs); | |
| 2291 EXPECT_EQ(Range(3, 8), chars); | |
| 2292 EXPECT_EQ(Range(0, 0), glyphs); | |
| 2293 | |
|
msw
2014/08/02 18:05:33
nit: remove blank line
ckocagil
2014/08/03 03:36:55
Done.
| |
| 2294 } | |
| 2295 | |
| 2265 } // namespace gfx | 2296 } // namespace gfx |
| OLD | NEW |