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

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

Issue 16051006: ui/gfx: Use base::string16 now that string16 was moved into base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 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/canvas_skia.cc ('k') | ui/gfx/font.h » ('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 <limits> 5 #include <limits>
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "ui/gfx/canvas.h" 9 #include "ui/gfx/canvas.h"
10 #include "ui/gfx/font.h" 10 #include "ui/gfx/font.h"
11 11
12 namespace gfx { 12 namespace gfx {
13 13
14 class CanvasTest : public testing::Test { 14 class CanvasTest : public testing::Test {
15 protected: 15 protected:
16 int GetStringWidth(const char *text) { 16 int GetStringWidth(const char *text) {
17 return Canvas::GetStringWidth(UTF8ToUTF16(text), font_); 17 return Canvas::GetStringWidth(UTF8ToUTF16(text), font_);
18 } 18 }
19 19
20 gfx::Size SizeStringInt(const char *text, int width, int line_height) { 20 gfx::Size SizeStringInt(const char *text, int width, int line_height) {
21 string16 text16 = UTF8ToUTF16(text); 21 base::string16 text16 = UTF8ToUTF16(text);
22 int height = 0; 22 int height = 0;
23 int flags = (text16.find('\n') != string16::npos) ? Canvas::MULTI_LINE : 0; 23 int flags =
24 (text16.find('\n') != base::string16::npos) ? Canvas::MULTI_LINE : 0;
24 Canvas::SizeStringInt(text16, font_, &width, &height, line_height, flags); 25 Canvas::SizeStringInt(text16, font_, &width, &height, line_height, flags);
25 return gfx::Size(width, height); 26 return gfx::Size(width, height);
26 } 27 }
27 28
28 private: 29 private:
29 gfx::Font font_; 30 gfx::Font font_;
30 }; 31 };
31 32
32 TEST_F(CanvasTest, StringWidth) { 33 TEST_F(CanvasTest, StringWidth) {
33 EXPECT_GT(GetStringWidth("Test"), 0); 34 EXPECT_GT(GetStringWidth("Test"), 0);
(...skipping 17 matching lines...) Expand all
51 #endif 52 #endif
52 53
53 TEST_F(CanvasTest, MAYBE_StringSizeWithLineHeight) { 54 TEST_F(CanvasTest, MAYBE_StringSizeWithLineHeight) {
54 gfx::Size one_line_size = SizeStringInt("Q", 0, 0); 55 gfx::Size one_line_size = SizeStringInt("Q", 0, 0);
55 gfx::Size four_line_size = SizeStringInt("Q\nQ\nQ\nQ", 1000000, 1000); 56 gfx::Size four_line_size = SizeStringInt("Q\nQ\nQ\nQ", 1000000, 1000);
56 EXPECT_EQ(one_line_size.width(), four_line_size.width()); 57 EXPECT_EQ(one_line_size.width(), four_line_size.width());
57 EXPECT_EQ(3 * 1000 + one_line_size.height(), four_line_size.height()); 58 EXPECT_EQ(3 * 1000 + one_line_size.height(), four_line_size.height());
58 } 59 }
59 60
60 } // namespace gfx 61 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/canvas_skia.cc ('k') | ui/gfx/font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698