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

Unified Diff: ui/gfx/canvas_unittest_mac.mm

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_mac.mm
diff --git a/ui/gfx/canvas_unittest_mac.mm b/ui/gfx/canvas_unittest_mac.mm
index d607218c64fe432969faf70f02858dc14f4c3115..62544b20a3c2c6091b6c9015dcb590ac366d3dfe 100644
--- a/ui/gfx/canvas_unittest_mac.mm
+++ b/ui/gfx/canvas_unittest_mac.mm
@@ -4,8 +4,6 @@
#include "ui/gfx/canvas.h"
-#include <cmath>
-
#import <Cocoa/Cocoa.h>
#include "base/strings/utf_string_conversions.h"
@@ -22,7 +20,7 @@ namespace {
// of the old implementation that used to be in canvas_mac.mm.
void CanvasMac_SizeStringInt(const base::string16& text,
msw 2013/09/27 21:54:48 Is updating this important? Is it even worth keepi
jianli 2013/10/01 00:32:58 I do not know if it is worth to keep this test. I
const FontList& font_list,
- int* width,
+ float* width,
int* height,
int line_height,
int flags) {
@@ -35,7 +33,7 @@ void CanvasMac_SizeStringInt(const base::string16& text,
[NSDictionary dictionaryWithObject:native_font
forKey:NSFontAttributeName];
NSSize string_size = [ns_string sizeWithAttributes:attributes];
- *width = std::ceil(string_size.width);
+ *width = string_size.width;
*height = font_list.GetHeight();
}
@@ -49,23 +47,25 @@ class CanvasTestMac : public testing::Test {
// without specified line height, since that is all the platform
// implementation supports.
void CompareSizes(const char* text) {
- const int kReallyLargeNumber = 12345678;
+ const float kReallyLargeNumber = 12345678;
FontList font_list(font_);
base::string16 text16 = base::UTF8ToUTF16(text);
- int mac_width = kReallyLargeNumber;
+ float mac_width = kReallyLargeNumber;
int mac_height = kReallyLargeNumber;
CanvasMac_SizeStringInt(text16, font_list, &mac_width, &mac_height, 0, 0);
- int canvas_width = kReallyLargeNumber;
- int canvas_height = kReallyLargeNumber;
+ float canvas_width = kReallyLargeNumber;
+ float canvas_height = kReallyLargeNumber;
Canvas::SizeStringInt(
text16, font_list, &canvas_width, &canvas_height, 0, 0);
EXPECT_NE(kReallyLargeNumber, mac_width) << "no width for " << text;
EXPECT_NE(kReallyLargeNumber, mac_height) << "no height for " << text;
EXPECT_EQ(mac_width, canvas_width) << " width for " << text;
- EXPECT_EQ(mac_height, canvas_height) << " height for " << text;
+ // mac_height is the truncated height.
msw 2013/09/27 21:54:48 nit: Consider "CanvasMac_SizeStringInt returns a t
jianli 2013/10/01 00:32:58 Done.
+ EXPECT_EQ(mac_height,
+ static_cast<int>(canvas_height)) << " height for " << text;
}
private:

Powered by Google App Engine
This is Rietveld 408576698