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

Side by Side Diff: ios/chrome/browser/ui/util/text_region_mapper_unittest.mm

Issue 2912863005: Use MDCTypography instead of MDFRobotoFontLoader directly. (Closed)
Patch Set: Tentative fix for ManualTextFramerTest Created 3 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/foundation_util.h" 7 #include "base/mac/foundation_util.h"
8 #include "ios/chrome/browser/ui/util/text_region_mapper.h" 8 #include "ios/chrome/browser/ui/util/text_region_mapper.h"
9 #import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoF ontLoader.h" 9 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "testing/gtest_mac.h" 11 #include "testing/gtest_mac.h"
12 #include "testing/platform_test.h" 12 #include "testing/platform_test.h"
13 13
14 #if !defined(__has_feature) || !__has_feature(objc_arc) 14 #if !defined(__has_feature) || !__has_feature(objc_arc)
15 #error "This file requires ARC support." 15 #error "This file requires ARC support."
16 #endif 16 #endif
17 17
18 namespace { 18 namespace {
19 class TextRegionMapperTest : public PlatformTest { 19 class TextRegionMapperTest : public PlatformTest {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 TEST_F(TextRegionMapperTest, CJKTest) { 113 TEST_F(TextRegionMapperTest, CJKTest) {
114 CGRect bounds = CGRectMake(0, 0, 345, 65); 114 CGRect bounds = CGRectMake(0, 0, 345, 65);
115 // clang-format off 115 // clang-format off
116 NSString* CJKString = 116 NSString* CJKString =
117 @"“触摸搜索”会将所选字词和当前页面(作为上下文)一起发送给 Google 搜索。" 117 @"“触摸搜索”会将所选字词和当前页面(作为上下文)一起发送给 Google 搜索。"
118 @"您可以在设置中停用此功能。"; 118 @"您可以在设置中停用此功能。";
119 // clang-format on 119 // clang-format on
120 NSMutableDictionary* attributes = [NSMutableDictionary 120 NSMutableDictionary* attributes = [NSMutableDictionary
121 dictionaryWithDictionary:AttributesForTextAlignment(NSTextAlignmentLeft)]; 121 dictionaryWithDictionary:AttributesForTextAlignment(NSTextAlignmentLeft)];
122 attributes[NSFontAttributeName] = 122 attributes[NSFontAttributeName] =
123 [[MDFRobotoFontLoader sharedInstance] regularFontOfSize:16]; 123 [[MDCTypography fontLoader] regularFontOfSize:16];
124 NSAttributedString* string = 124 NSAttributedString* string =
125 [[NSAttributedString alloc] initWithString:CJKString 125 [[NSAttributedString alloc] initWithString:CJKString
126 attributes:attributes]; 126 attributes:attributes];
127 InitMapper(string, bounds); 127 InitMapper(string, bounds);
128 128
129 NSRange range = NSMakeRange(0, 6); // "“触摸搜索”". 129 NSRange range = NSMakeRange(0, 6); // "“触摸搜索”".
130 NSArray* rects = [_textMapper rectsForRange:range]; 130 NSArray* rects = [_textMapper rectsForRange:range];
131 ASSERT_EQ(1UL, [rects count]); 131 ASSERT_EQ(1UL, [rects count]);
132 } 132 }
133 133
134 /* 134 /*
135 Further unit tests should cover additional cases: 135 Further unit tests should cover additional cases:
136 - In several languages. 136 - In several languages.
137 - Range split across line break == two rects 137 - Range split across line break == two rects
138 - Bidi text with text range across scripts gets two rects. 138 - Bidi text with text range across scripts gets two rects.
139 - Various string attributions. 139 - Various string attributions.
140 - Isolate buggy CoreText case. 140 - Isolate buggy CoreText case.
141 */ 141 */
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/util/manual_text_framer_unittest.mm ('k') | ios/showcase/core/app_delegate.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698