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

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

Issue 354963003: Move gfx::ElideText functionality to RenderText. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the initial width of OmniboxResultView's elided RenderTexts. Created 6 years, 5 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 | Annotate | Revision Log
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/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 #endif // defined(OS_WIN) 1260 #endif // defined(OS_WIN)
1261 1261
1262 TEST_F(RenderTextTest, StringSizeSanity) { 1262 TEST_F(RenderTextTest, StringSizeSanity) {
1263 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 1263 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
1264 render_text->SetText(UTF8ToUTF16("Hello World")); 1264 render_text->SetText(UTF8ToUTF16("Hello World"));
1265 const Size string_size = render_text->GetStringSize(); 1265 const Size string_size = render_text->GetStringSize();
1266 EXPECT_GT(string_size.width(), 0); 1266 EXPECT_GT(string_size.width(), 0);
1267 EXPECT_GT(string_size.height(), 0); 1267 EXPECT_GT(string_size.height(), 0);
1268 } 1268 }
1269 1269
1270 TEST_F(RenderTextTest, StringSizeLongStrings) {
1271 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
1272 Size previous_string_size;
1273 for (size_t length = 10; length < 1000000; length *= 10) {
1274 render_text->SetText(base::string16(length, 'a'));
1275 const Size string_size = render_text->GetStringSize();
1276 EXPECT_GT(string_size.width(), previous_string_size.width());
1277 EXPECT_GT(string_size.height(), 0);
1278 previous_string_size = string_size;
1279 }
1280 }
1281
1270 // TODO(asvitkine): This test fails because PlatformFontMac uses point font 1282 // TODO(asvitkine): This test fails because PlatformFontMac uses point font
1271 // sizes instead of pixel sizes like other implementations. 1283 // sizes instead of pixel sizes like other implementations.
1272 #if !defined(OS_MACOSX) 1284 #if !defined(OS_MACOSX)
1273 TEST_F(RenderTextTest, StringSizeEmptyString) { 1285 TEST_F(RenderTextTest, StringSizeEmptyString) {
1274 // Ascent and descent of Arial and Symbol are different on most platforms. 1286 // Ascent and descent of Arial and Symbol are different on most platforms.
1275 const FontList font_list("Arial,Symbol, 16px"); 1287 const FontList font_list("Arial,Symbol, 16px");
1276 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); 1288 scoped_ptr<RenderText> render_text(RenderText::CreateInstance());
1277 render_text->SetFontList(font_list); 1289 render_text->SetFontList(font_list);
1278 render_text->SetDisplayRect(Rect(0, 0, 0, font_list.GetHeight())); 1290 render_text->SetDisplayRect(Rect(0, 0, 0, font_list.GetHeight()));
1279 1291
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 for (size_t i = 0; i < arraysize(kTestStrings); ++i) { 2046 for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
2035 render_text->SetText(WideToUTF16(kTestStrings[i])); 2047 render_text->SetText(WideToUTF16(kTestStrings[i]));
2036 render_text->EnsureLayout(); 2048 render_text->EnsureLayout();
2037 2049
2038 for (size_t j = 0; j < render_text->text().length(); ++j) 2050 for (size_t j = 0; j < render_text->text().length(); ++j)
2039 EXPECT_FALSE(render_text->GetGlyphBounds(j).is_empty()); 2051 EXPECT_FALSE(render_text->GetGlyphBounds(j).is_empty());
2040 } 2052 }
2041 } 2053 }
2042 2054
2043 } // namespace gfx 2055 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698