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

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

Issue 652573002: RenderText: Add a test to ensure strings fit their own widths (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 6 years, 2 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.h ('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"
(...skipping 2291 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « ui/gfx/render_text.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698