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 const base::string16 kString = ASCIIToUTF16("www.example.com"); |
| 2316 |
| 2317 render_text->SetText(kString); |
| 2318 render_text->ApplyStyle(BOLD, true, Range(0, 3)); |
| 2319 render_text->SetElideBehavior(ELIDE_TAIL); |
| 2320 |
| 2321 render_text->SetDisplayRect(Rect(0, 0, 500, 100)); |
| 2322 EXPECT_EQ(kString, render_text->GetLayoutText()); |
| 2323 render_text->SetDisplayRect(Rect(0, 0, render_text->GetContentWidth(), 100)); |
| 2324 EXPECT_EQ(kString, render_text->GetLayoutText()); |
| 2325 } |
| 2326 |
2312 } // namespace gfx | 2327 } // namespace gfx |
OLD | NEW |