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

Side by Side Diff: ui/ios/NSString+CrStringDrawing_unittest.mm

Issue 497503004: Add NSString category for providing iOS6-style string drawing APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: split into two methods Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 #import "ui/ios/NSString+CrStringDrawing.h"
5
6 #include "base/mac/scoped_nsobject.h"
7 #include "base/strings/sys_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/platform_test.h"
10
11 namespace {
12
13 typedef PlatformTest NSStringCrStringDrawing;
14
15 // These tests verify that the category methods return the same values as the
16 // deprecated methods, so ignore warnings about using deprecated methods.
17 #pragma clang diagnostic push
18 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
19
20 TEST_F(NSStringCrStringDrawing, testIntegralSizeWithFont) {
stuartmorgan 2014/08/28 15:18:14 Remove "test" from the name.
lliabraa 2014/08/28 19:25:06 Done.
21 NSArray* fonts = @[
22 [NSNull null],
23 [UIFont systemFontOfSize:16],
24 [UIFont boldSystemFontOfSize:10],
25 [UIFont fontWithName:@"Helvetica" size:12.0],
26 ];
27 for (UIFont* font in fonts) {
28 if ([font isEqual:[NSNull null]])
29 font = nil;
30 std::string fontTag = "with font ";
31 fontTag.append(base::SysNSStringToUTF8(font ? [font description] : @"nil"));
32 EXPECT_EQ([@"" sizeWithFont:font].width,
33 [@"" cr_integralSizeWithFont:font].width) << fontTag;
34 EXPECT_EQ([@"" sizeWithFont:font].height,
35 [@"" cr_integralSizeWithFont:font].height) << fontTag;
36 EXPECT_EQ([@"Test" sizeWithFont:font].width,
37 [@"Test" cr_integralSizeWithFont:font].width) << fontTag;
38 EXPECT_EQ([@"Test" sizeWithFont:font].height,
39 [@"Test" cr_integralSizeWithFont:font].height) << fontTag;
40 EXPECT_EQ([@"你好" sizeWithFont:font].width,
41 [@"你好" cr_integralSizeWithFont:font].width) << fontTag;
42 EXPECT_EQ([@"你好" sizeWithFont:font].height,
43 [@"你好" cr_integralSizeWithFont:font].height) << fontTag;
44 NSString* longString = @"★ This is a test string that is very long.";
45 EXPECT_EQ([longString sizeWithFont:font].width,
46 [longString cr_integralSizeWithFont:font].width) << fontTag;
47 EXPECT_EQ([longString sizeWithFont:font].height,
48 [longString cr_integralSizeWithFont:font].height) << fontTag;
49 }
50 }
51
52 #pragma clang diagnostic pop // ignored "-Wdeprecated-declarations"
53
54 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698