OLD | NEW |
(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 |
OLD | NEW |