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

Unified Diff: ui/gfx/canvas_unittest.cc

Issue 24883002: Uses and returns the fractional width in text eliding (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Patch Created 7 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/canvas_unittest.cc
diff --git a/ui/gfx/canvas_unittest.cc b/ui/gfx/canvas_unittest.cc
index 21b9f51e57e8eee4e12e16d4390d83b4c5cbde64..7b0dc30cbb021e60390f91f35c989f1509f15520 100644
--- a/ui/gfx/canvas_unittest.cc
+++ b/ui/gfx/canvas_unittest.cc
@@ -17,13 +17,13 @@ class CanvasTest : public testing::Test {
return Canvas::GetStringWidth(UTF8ToUTF16(text), font_);
}
- gfx::Size SizeStringInt(const char *text, int width, int line_height) {
+ gfx::SizeF SizeStringInt(const char *text, float width, int line_height) {
base::string16 text16 = UTF8ToUTF16(text);
- int height = 0;
+ float height = 0;
int flags =
(text16.find('\n') != base::string16::npos) ? Canvas::MULTI_LINE : 0;
Canvas::SizeStringInt(text16, font_, &width, &height, line_height, flags);
- return gfx::Size(width, height);
+ return gfx::SizeF(width, height);
}
private:
@@ -39,7 +39,7 @@ TEST_F(CanvasTest, StringWidthEmptyString) {
}
TEST_F(CanvasTest, StringSizeEmptyString) {
- gfx::Size size = SizeStringInt("", 0, 0);
+ gfx::SizeF size = SizeStringInt("", 0, 0);
EXPECT_EQ(0, size.width());
EXPECT_GT(size.height(), 0);
}
@@ -52,8 +52,8 @@ TEST_F(CanvasTest, StringSizeEmptyString) {
#endif
TEST_F(CanvasTest, MAYBE_StringSizeWithLineHeight) {
- gfx::Size one_line_size = SizeStringInt("Q", 0, 0);
- gfx::Size four_line_size = SizeStringInt("Q\nQ\nQ\nQ", 1000000, 1000);
+ gfx::SizeF one_line_size = SizeStringInt("Q", 0, 0);
+ gfx::SizeF four_line_size = SizeStringInt("Q\nQ\nQ\nQ", 1000000, 1000);
EXPECT_EQ(one_line_size.width(), four_line_size.width());
EXPECT_EQ(3 * 1000 + one_line_size.height(), four_line_size.height());
}

Powered by Google App Engine
This is Rietveld 408576698