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

Side by Side Diff: ios/chrome/browser/ui/first_run/first_run_util_unittest.mm

Issue 2888423002: [ObjC ARC] Converts ios/chrome/browser/ui/first_run:unit_tests to ARC. (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import <UIKit/UIKit.h> 5 #import <UIKit/UIKit.h>
6 6
7 #include "base/mac/scoped_nsobject.h"
8 #include "ios/chrome/browser/ui/first_run/first_run_util.h" 7 #include "ios/chrome/browser/ui/first_run/first_run_util.h"
9 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
10 9
10 #if !defined(__has_feature) || !__has_feature(objc_arc)
11 #error "This file requires ARC support."
12 #endif
13
11 namespace { 14 namespace {
12 15
13 TEST(UICommonTest, TestFixOrphanWord) { 16 TEST(UICommonTest, TestFixOrphanWord) {
14 NSString* englishString = 17 NSString* englishString =
15 @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tempus" 18 @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tempus"
16 " dignissim congue. Morbi pulvinar vitae purus at mollis. Sed laoreet " 19 " dignissim congue. Morbi pulvinar vitae purus at mollis. Sed laoreet "
17 "euismod neque, eget laoreet nisi porttitor sed."; 20 "euismod neque, eget laoreet nisi porttitor sed.";
18 NSString* englishStringWithOrphan = 21 NSString* englishStringWithOrphan =
19 @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tempus" 22 @"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec tempus"
20 " dignissim congue. Morbi pulvinar vitae purus at mollis. Sed laoreet " 23 " dignissim congue. Morbi pulvinar vitae purus at mollis. Sed laoreet "
21 "euismod neque, eget laoreet nisi."; 24 "euismod neque, eget laoreet nisi.";
22 // TODO(crbug.com/675342): clang_format does a poor job here. Remove when 25 // TODO(crbug.com/675342): clang_format does a poor job here. Remove when
23 // fixed in clang_format. 26 // fixed in clang_format.
24 // clang-format off 27 // clang-format off
25 NSString* chineseString = 28 NSString* chineseString =
26 @"那只敏捷的棕色狐狸跃过那只懒狗。那只敏捷的棕色狐狸跃过那只懒狗。" 29 @"那只敏捷的棕色狐狸跃过那只懒狗。那只敏捷的棕色狐狸跃过那只懒狗。"
27 "那只敏捷的棕色狐狸跃过那只懒狗。那只敏捷的棕色狐狸跃过那只懒狗。" 30 "那只敏捷的棕色狐狸跃过那只懒狗。那只敏捷的棕色狐狸跃过那只懒狗。"
28 "那只敏捷的棕色狐狸跃过那只懒狗。那只敏捷的棕色狐狸跃过那只懒狗。"; 31 "那只敏捷的棕色狐狸跃过那只懒狗。那只敏捷的棕色狐狸跃过那只懒狗。";
29 NSString* chineseStringWithOrphan = 32 NSString* chineseStringWithOrphan =
30 @"那只敏捷的棕色狐狸跃过那只懒狗。那只敏捷的棕色狐狸跃过那只懒狗。" 33 @"那只敏捷的棕色狐狸跃过那只懒狗。那只敏捷的棕色狐狸跃过那只懒狗。"
31 "那只敏捷的棕色狐狸跃过那只懒狗。快速狐狸"; 34 "那只敏捷的棕色狐狸跃过那只懒狗。快速狐狸";
32 // clang-format on 35 // clang-format on
33 36
34 base::scoped_nsobject<UILabel> label( 37 UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 500)];
35 [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 500)]);
36 [label setText:englishString]; 38 [label setText:englishString];
37 ios_internal::FixOrphanWord(label); 39 ios_internal::FixOrphanWord(label);
38 NSRange range = [[label text] rangeOfString:@"\n"]; 40 NSRange range = [[label text] rangeOfString:@"\n"];
39 // Check that the label's text does not contain a newline. 41 // Check that the label's text does not contain a newline.
40 EXPECT_EQ(NSNotFound, static_cast<NSInteger>(range.location)); 42 EXPECT_EQ(NSNotFound, static_cast<NSInteger>(range.location));
41 43
42 [label setText:englishStringWithOrphan]; 44 [label setText:englishStringWithOrphan];
43 ios_internal::FixOrphanWord(label); 45 ios_internal::FixOrphanWord(label);
44 range = [[label text] rangeOfString:@"\n"]; 46 range = [[label text] rangeOfString:@"\n"];
45 // Check that the label's text contains a newline. 47 // Check that the label's text contains a newline.
(...skipping 15 matching lines...) Expand all
61 range = [[label text] rangeOfString:@"\n"]; 63 range = [[label text] rangeOfString:@"\n"];
62 // Check that the label's text contains a newline. 64 // Check that the label's text contains a newline.
63 ASSERT_NE(NSNotFound, static_cast<NSInteger>(range.location)); 65 ASSERT_NE(NSNotFound, static_cast<NSInteger>(range.location));
64 66
65 // Check the words after the newline. 67 // Check the words after the newline.
66 wordsAfterNewline = 68 wordsAfterNewline =
67 [[label text] substringFromIndex:(range.location + range.length)]; 69 [[label text] substringFromIndex:(range.location + range.length)];
68 EXPECT_TRUE([@"快速狐狸" isEqualToString:wordsAfterNewline]); 70 EXPECT_TRUE([@"快速狐狸" isEqualToString:wordsAfterNewline]);
69 } 71 }
70 } 72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698