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

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: TIL export_dependent_settings Created 6 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 | 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, testSizeWithFont) {
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_sizeWithFont:font].width) << fontTag;
34 EXPECT_EQ([@"" sizeWithFont:font].height,
35 [@"" cr_sizeWithFont:font].height) << fontTag;
36 EXPECT_EQ([@"Test" sizeWithFont:font].width,
37 [@"Test" cr_sizeWithFont:font].width) << fontTag;
38 EXPECT_EQ([@"Test" sizeWithFont:font].height,
39 [@"Test" cr_sizeWithFont:font].height) << fontTag;
40 EXPECT_EQ([@"你好" sizeWithFont:font].width,
41 [@"你好" cr_sizeWithFont:font].width) << fontTag;
42 EXPECT_EQ([@"你好" sizeWithFont:font].height,
43 [@"你好" cr_sizeWithFont:font].height) << fontTag;
44 EXPECT_EQ(
45 [@"★ This is a test string that is very long."
46 sizeWithFont:font].width,
47 [@"★ This is a test string that is very long."
48 cr_sizeWithFont:font].width) << fontTag;
49 EXPECT_EQ(
50 [@"★ This is a test string that is very long."
51 sizeWithFont:font].height,
52 [@"★ This is a test string that is very long."
53 cr_sizeWithFont:font].height) << fontTag;
54 }
55 }
56
57 #pragma clang diagnostic pop // ignored "-Wdeprecated-declarations"
58
59 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698