| OLD | NEW |
| 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/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #import "ios/chrome/browser/ui/util/core_text_util.h" | 9 #import "ios/chrome/browser/ui/util/core_text_util.h" |
| 10 #import "ios/chrome/browser/ui/util/text_frame.h" | 10 #import "ios/chrome/browser/ui/util/text_frame.h" |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 @"\u0644\u064e\u0639\u064e\u0644\u064e\u0643\u0650\u0020\u062a\u064e" | 191 @"\u0644\u064e\u0639\u064e\u0644\u064e\u0643\u0650\u0020\u062a\u064e" |
| 192 @"\u062a\u064e\u0639\u064e\u0644\u0651\u064e\u0645\u064e\u0020\u0627" | 192 @"\u062a\u064e\u0639\u064e\u0644\u0651\u064e\u0645\u064e\u0020\u0627" |
| 193 @"\u0644\u062d\u0650\u0631\u0652\u0635\u064e\u0020\u0639\u064e\u0644" | 193 @"\u0644\u062d\u0650\u0631\u0652\u0635\u064e\u0020\u0639\u064e\u0644" |
| 194 @"\u064e\u0649\u0020\u0627\u0644\u0648\u064e\u0642\u0652\u062a\u0650" | 194 @"\u064e\u0649\u0020\u0627\u0644\u0648\u064e\u0642\u0652\u062a\u0650" |
| 195 @"\u0020\u002e\u0020\u0641\u064e\u0627\u0644\u062d\u064e\u064a\u064e" | 195 @"\u0020\u002e\u0020\u0641\u064e\u0627\u0644\u062d\u064e\u064a\u064e" |
| 196 @"\u0627\u0629\u064f"); | 196 @"\u0627\u0629\u064f"); |
| 197 attributes()[NSFontAttributeName] = TypographyFontWithSize(14.0); | 197 attributes()[NSFontAttributeName] = TypographyFontWithSize(14.0); |
| 198 attributes()[NSParagraphStyleAttributeName] = CreateParagraphStyle( | 198 attributes()[NSParagraphStyleAttributeName] = CreateParagraphStyle( |
| 199 20.0, NSTextAlignmentNatural, NSLineBreakByWordWrapping); | 199 20.0, NSTextAlignmentNatural, NSLineBreakByWordWrapping); |
| 200 ApplyAttributesForRange(text_range()); | 200 ApplyAttributesForRange(text_range()); |
| 201 CGRect bounds = CGRectMake(0, 0, 100.0, 60.0); | 201 // The bounds width is chosen so that the RTL string above can be completely |
| 202 // laid out into three lines. |
| 203 CGRect bounds = CGRectMake(0, 0, 115.0, 60.0); |
| 202 FrameTextInBounds(bounds); | 204 FrameTextInBounds(bounds); |
| 203 CheckForLineCountAndFramedRange(3, text_range()); | 205 CheckForLineCountAndFramedRange(3, text_range()); |
| 204 for (FramedLine* line in text_frame().lines) { | 206 for (FramedLine* line in text_frame().lines) { |
| 205 ExpectNearPoint( | 207 ExpectNearPoint( |
| 206 CGRectGetMaxX(bounds), | 208 CGRectGetMaxX(bounds), |
| 207 line.origin.x + core_text_util::GetTrimmedLineWidth(line.line)); | 209 line.origin.x + core_text_util::GetTrimmedLineWidth(line.line)); |
| 208 } | 210 } |
| 209 } | 211 } |
| 210 | 212 |
| 211 TEST_F(ManualTextFramerTest, CJKLineBreakTest) { | 213 TEST_F(ManualTextFramerTest, CJKLineBreakTest) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 "\u062A\u0639\u0637\u064A\u0644\u0020\u0647\u0630\u0647\u0020\u0627" | 282 "\u062A\u0639\u0637\u064A\u0644\u0020\u0647\u0630\u0647\u0020\u0627" |
| 281 "\u0644\u062E\u062F\u0645\u0627\u062A\u002E"); | 283 "\u0644\u062E\u062F\u0645\u0627\u062A\u002E"); |
| 282 attributes()[NSFontAttributeName] = [UIFont systemFontOfSize:20.0]; | 284 attributes()[NSFontAttributeName] = [UIFont systemFontOfSize:20.0]; |
| 283 ApplyAttributesForRange(text_range()); | 285 ApplyAttributesForRange(text_range()); |
| 284 CGRect bounds = CGRectMake(0, 0, 500, 100); | 286 CGRect bounds = CGRectMake(0, 0, 500, 100); |
| 285 FrameTextInBounds(bounds); | 287 FrameTextInBounds(bounds); |
| 286 CheckForLineCountAndFramedRange(2, text_range()); | 288 CheckForLineCountAndFramedRange(2, text_range()); |
| 287 } | 289 } |
| 288 | 290 |
| 289 } // namespace | 291 } // namespace |
| OLD | NEW |