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

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

Issue 2935723002: Fix ManualTextFramerTest.OriginRTLTest on iOS 11 (Closed)
Patch Set: Add comment 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
« base/ios/ios_util.h ('K') | « base/ios/ios_util.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "ios/chrome/browser/ui/util/manual_text_framer.h" 5 #include "ios/chrome/browser/ui/util/manual_text_framer.h"
6 6
7 #include "base/ios/ios_util.h"
7 #include "base/mac/foundation_util.h" 8 #include "base/mac/foundation_util.h"
8 #include "base/time/time.h" 9 #include "base/time/time.h"
9 #import "ios/chrome/browser/ui/util/core_text_util.h" 10 #import "ios/chrome/browser/ui/util/core_text_util.h"
10 #import "ios/chrome/browser/ui/util/text_frame.h" 11 #import "ios/chrome/browser/ui/util/text_frame.h"
11 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h" 12 #import "ios/third_party/material_components_ios/src/components/Typography/src/M aterialTypography.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/gtest_mac.h" 14 #include "testing/gtest_mac.h"
14 #include "testing/platform_test.h" 15 #include "testing/platform_test.h"
15 #include "url/gurl.h" 16 #include "url/gurl.h"
16 17
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 @"\u0644\u064e\u0639\u064e\u0644\u064e\u0643\u0650\u0020\u062a\u064e" 192 @"\u0644\u064e\u0639\u064e\u0644\u064e\u0643\u0650\u0020\u062a\u064e"
192 @"\u062a\u064e\u0639\u064e\u0644\u0651\u064e\u0645\u064e\u0020\u0627" 193 @"\u062a\u064e\u0639\u064e\u0644\u0651\u064e\u0645\u064e\u0020\u0627"
193 @"\u0644\u062d\u0650\u0631\u0652\u0635\u064e\u0020\u0639\u064e\u0644" 194 @"\u0644\u062d\u0650\u0631\u0652\u0635\u064e\u0020\u0639\u064e\u0644"
194 @"\u064e\u0649\u0020\u0627\u0644\u0648\u064e\u0642\u0652\u062a\u0650" 195 @"\u064e\u0649\u0020\u0627\u0644\u0648\u064e\u0642\u0652\u062a\u0650"
195 @"\u0020\u002e\u0020\u0641\u064e\u0627\u0644\u062d\u064e\u064a\u064e" 196 @"\u0020\u002e\u0020\u0641\u064e\u0627\u0644\u062d\u064e\u064a\u064e"
196 @"\u0627\u0629\u064f"); 197 @"\u0627\u0629\u064f");
197 attributes()[NSFontAttributeName] = TypographyFontWithSize(14.0); 198 attributes()[NSFontAttributeName] = TypographyFontWithSize(14.0);
198 attributes()[NSParagraphStyleAttributeName] = CreateParagraphStyle( 199 attributes()[NSParagraphStyleAttributeName] = CreateParagraphStyle(
199 20.0, NSTextAlignmentNatural, NSLineBreakByWordWrapping); 200 20.0, NSTextAlignmentNatural, NSLineBreakByWordWrapping);
200 ApplyAttributesForRange(text_range()); 201 ApplyAttributesForRange(text_range());
201 CGRect bounds = CGRectMake(0, 0, 100.0, 60.0); 202 // The bounds width is chosen so that the RTL string above is laid out into 3
203 // lines. The font that iOS 11 uses for Arabic strings takes more horizontal
204 // space, so the bounds width is increased accordingly.
205 CGFloat width = base::ios::IsRunningOnIOS11OrLater() ? 130.0 : 100.0;
rohitrao (ping after 24h) 2017/06/14 11:58:03 This test is very dependent on the exact sizes of
lpromero 2017/06/15 08:26:51 Dividing by 3 is not sufficient, I need to come up
206 CGRect bounds = CGRectMake(0, 0, width, 60.0);
202 FrameTextInBounds(bounds); 207 FrameTextInBounds(bounds);
203 CheckForLineCountAndFramedRange(3, text_range()); 208 CheckForLineCountAndFramedRange(3, text_range());
204 for (FramedLine* line in text_frame().lines) { 209 for (FramedLine* line in text_frame().lines) {
205 ExpectNearPoint( 210 ExpectNearPoint(
206 CGRectGetMaxX(bounds), 211 CGRectGetMaxX(bounds),
207 line.origin.x + core_text_util::GetTrimmedLineWidth(line.line)); 212 line.origin.x + core_text_util::GetTrimmedLineWidth(line.line));
208 } 213 }
209 } 214 }
210 215
211 TEST_F(ManualTextFramerTest, CJKLineBreakTest) { 216 TEST_F(ManualTextFramerTest, CJKLineBreakTest) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 "\u062A\u0639\u0637\u064A\u0644\u0020\u0647\u0630\u0647\u0020\u0627" 285 "\u062A\u0639\u0637\u064A\u0644\u0020\u0647\u0630\u0647\u0020\u0627"
281 "\u0644\u062E\u062F\u0645\u0627\u062A\u002E"); 286 "\u0644\u062E\u062F\u0645\u0627\u062A\u002E");
282 attributes()[NSFontAttributeName] = [UIFont systemFontOfSize:20.0]; 287 attributes()[NSFontAttributeName] = [UIFont systemFontOfSize:20.0];
283 ApplyAttributesForRange(text_range()); 288 ApplyAttributesForRange(text_range());
284 CGRect bounds = CGRectMake(0, 0, 500, 100); 289 CGRect bounds = CGRectMake(0, 0, 500, 100);
285 FrameTextInBounds(bounds); 290 FrameTextInBounds(bounds);
286 CheckForLineCountAndFramedRange(2, text_range()); 291 CheckForLineCountAndFramedRange(2, text_range());
287 } 292 }
288 293
289 } // namespace 294 } // namespace
OLDNEW
« base/ios/ios_util.h ('K') | « base/ios/ios_util.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698