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 2291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2302 run.glyph_count = 0; | 2302 run.glyph_count = 0; |
2303 EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5))); | 2303 EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5))); |
2304 EXPECT_EQ(Range(0, 0), run.GetGraphemeBounds(iter.get(), 4)); | 2304 EXPECT_EQ(Range(0, 0), run.GetGraphemeBounds(iter.get(), 4)); |
2305 Range chars; | 2305 Range chars; |
2306 Range glyphs; | 2306 Range glyphs; |
2307 run.GetClusterAt(4, &chars, &glyphs); | 2307 run.GetClusterAt(4, &chars, &glyphs); |
2308 EXPECT_EQ(Range(3, 8), chars); | 2308 EXPECT_EQ(Range(3, 8), chars); |
2309 EXPECT_EQ(Range(0, 0), glyphs); | 2309 EXPECT_EQ(Range(0, 0), glyphs); |
2310 } | 2310 } |
2311 | 2311 |
2312 // Ensure a string fits in a display rect with a width equal to the string's. | |
2313 TEST_F(RenderTextTest, StringFitsOwnWidth) { | |
2314 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | |
2315 | |
2316 render_text->SetText(ASCIIToUTF16("www.example.com")); | |
2317 render_text->ApplyStyle(BOLD, true, Range(0, 3)); | |
2318 render_text->SetElideBehavior(ELIDE_TAIL); | |
2319 | |
2320 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); | |
2321 EXPECT_EQ(base::char16('m'), *(render_text->GetLayoutText().end() - 1)); | |
msw
2014/10/16 20:32:21
nit: Just compare the whole string (avoid accident
ckocagil
2014/10/16 20:40:20
Done.
| |
2322 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100)); | |
2323 EXPECT_EQ(base::char16('m'), *(render_text->GetLayoutText().end() - 1)); | |
2324 } | |
2325 | |
2312 } // namespace gfx | 2326 } // namespace gfx |
OLD | NEW |