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

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

Issue 1274123003: Update SplitString calls to new form (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: no media changes Created 5 years, 4 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/font_list.cc ('k') | ui/gl/gl_gl_api_implementation.cc » ('j') | 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 2295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 for (size_t i = 0; i < arraysize(kTestStrings); ++i) { 2306 for (size_t i = 0; i < arraysize(kTestStrings); ++i) {
2307 SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "] %ls", i, 2307 SCOPED_TRACE(base::StringPrintf("kTestStrings[%" PRIuS "] %ls", i,
2308 kTestStrings[i].text)); 2308 kTestStrings[i].text));
2309 render_text.SetText(WideToUTF16(kTestStrings[i].text)); 2309 render_text.SetText(WideToUTF16(kTestStrings[i].text));
2310 render_text.Draw(&canvas); 2310 render_text.Draw(&canvas);
2311 ASSERT_LE(2u, render_text.lines().size()); 2311 ASSERT_LE(2u, render_text.lines().size());
2312 if (kTestStrings[i].alignment == gfx::ALIGN_LEFT) { 2312 if (kTestStrings[i].alignment == gfx::ALIGN_LEFT) {
2313 EXPECT_EQ(0, render_text.GetAlignmentOffset(0).x()); 2313 EXPECT_EQ(0, render_text.GetAlignmentOffset(0).x());
2314 EXPECT_EQ(0, render_text.GetAlignmentOffset(1).x()); 2314 EXPECT_EQ(0, render_text.GetAlignmentOffset(1).x());
2315 } else { 2315 } else {
2316 std::vector<base::string16> lines; 2316 std::vector<base::string16> lines = base::SplitString(
2317 base::SplitString(base::WideToUTF16(kTestStrings[i].text), '\n', &lines); 2317 base::WideToUTF16(kTestStrings[i].text),
2318 base::string16(1, '\n'), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
2318 ASSERT_EQ(2u, lines.size()); 2319 ASSERT_EQ(2u, lines.size());
2319 int difference = (lines[0].length() - lines[1].length()) * kGlyphSize; 2320 int difference = (lines[0].length() - lines[1].length()) * kGlyphSize;
2320 EXPECT_EQ(render_text.GetAlignmentOffset(0).x() + difference, 2321 EXPECT_EQ(render_text.GetAlignmentOffset(0).x() + difference,
2321 render_text.GetAlignmentOffset(1).x()); 2322 render_text.GetAlignmentOffset(1).x());
2322 } 2323 }
2323 } 2324 }
2324 } 2325 }
2325 2326
2326 TEST_F(RenderTextTest, Multiline_WordWrapBehavior) { 2327 TEST_F(RenderTextTest, Multiline_WordWrapBehavior) {
2327 const int kGlyphSize = 5; 2328 const int kGlyphSize = 5;
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
3115 string_size.set_width(string_size.width() / 2); 3116 string_size.set_width(string_size.width() / 2);
3116 render_text.SetDisplayRect(gfx::Rect(string_size)); 3117 render_text.SetDisplayRect(gfx::Rect(string_size));
3117 render_text.EnsureLayout(); 3118 render_text.EnsureLayout();
3118 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_); 3119 CFIndex glyph_count = CTLineGetGlyphCount(render_text.line_);
3119 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count)); 3120 EXPECT_GT(text.size(), static_cast<size_t>(glyph_count));
3120 EXPECT_NE(0, glyph_count); 3121 EXPECT_NE(0, glyph_count);
3121 } 3122 }
3122 #endif 3123 #endif
3123 3124
3124 } // namespace gfx 3125 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_list.cc ('k') | ui/gl/gl_gl_api_implementation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698