OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 5 #import "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
6 | 6 |
7 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete.h" | 10 #include "chrome/browser/autocomplete/autocomplete.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 longestEffectiveRange:&range inRange:fullRange]; | 79 longestEffectiveRange:&range inRange:fullRange]; |
80 NSFontManager* fontManager = [NSFontManager sharedFontManager]; | 80 NSFontManager* fontManager = [NSFontManager sharedFontManager]; |
81 if (runFont && (mask == ([fontManager traitsOfFont:runFont]&mask))) { | 81 if (runFont && (mask == ([fontManager traitsOfFont:runFont]&mask))) { |
82 return true; | 82 return true; |
83 } | 83 } |
84 return false; | 84 return false; |
85 } | 85 } |
86 | 86 |
87 // AutocompleteMatch doesn't really have the right constructor for our | 87 // AutocompleteMatch doesn't really have the right constructor for our |
88 // needs. Fake one for us to use. | 88 // needs. Fake one for us to use. |
89 static AutocompleteMatch MakeMatch(const std::wstring &contents, | 89 static AutocompleteMatch MakeMatch(const string16 &contents, |
90 const std::wstring &description) { | 90 const string16 &description) { |
91 AutocompleteMatch m(NULL, 1, true, AutocompleteMatch::URL_WHAT_YOU_TYPED); | 91 AutocompleteMatch m(NULL, 1, true, AutocompleteMatch::URL_WHAT_YOU_TYPED); |
92 m.contents = contents; | 92 m.contents = contents; |
93 m.description = description; | 93 m.description = description; |
94 return m; | 94 return m; |
95 } | 95 } |
96 | 96 |
97 NSColor* color_; // weak | 97 NSColor* color_; // weak |
98 NSColor* dimColor_; // weak | 98 NSColor* dimColor_; // weak |
99 gfx::Font font_; | 99 gfx::Font font_; |
100 }; | 100 }; |
101 | 101 |
102 // Simple inputs with no matches should result in styled output who's | 102 // Simple inputs with no matches should result in styled output who's |
103 // text matches the input string, with the passed-in color, and | 103 // text matches the input string, with the passed-in color, and |
104 // nothing bolded. | 104 // nothing bolded. |
105 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringNoMatch) { | 105 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringNoMatch) { |
106 NSString* const string = @"This is a test"; | 106 NSString* const string = @"This is a test"; |
107 AutocompleteMatch::ACMatchClassifications classifications; | 107 AutocompleteMatch::ACMatchClassifications classifications; |
108 | 108 |
109 NSAttributedString* decorated = | 109 NSAttributedString* decorated = |
110 AutocompletePopupViewMac::DecorateMatchedString( | 110 AutocompletePopupViewMac::DecorateMatchedString( |
111 base::SysNSStringToWide(string), classifications, | 111 base::SysNSStringToUTF16(string), classifications, |
112 color_, dimColor_, font_); | 112 color_, dimColor_, font_); |
113 | 113 |
114 // Result has same characters as the input. | 114 // Result has same characters as the input. |
115 EXPECT_EQ([decorated length], [string length]); | 115 EXPECT_EQ([decorated length], [string length]); |
116 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 116 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
117 | 117 |
118 // Our passed-in color for the entire string. | 118 // Our passed-in color for the entire string. |
119 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 119 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
120 NSForegroundColorAttributeName), | 120 NSForegroundColorAttributeName), |
121 [string length]); | 121 [string length]); |
122 EXPECT_TRUE(RunHasColor(decorated, 0U, color_)); | 122 EXPECT_TRUE(RunHasColor(decorated, 0U, color_)); |
123 | 123 |
124 // An unbolded font for the entire string. | 124 // An unbolded font for the entire string. |
125 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 125 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
126 NSFontAttributeName), [string length]); | 126 NSFontAttributeName), [string length]); |
127 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); | 127 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); |
128 } | 128 } |
129 | 129 |
130 // Identical to DecorateMatchedStringNoMatch, except test that URL | 130 // Identical to DecorateMatchedStringNoMatch, except test that URL |
131 // style gets a different color than we passed in. | 131 // style gets a different color than we passed in. |
132 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringURLNoMatch) { | 132 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringURLNoMatch) { |
133 NSString* const string = @"This is a test"; | 133 NSString* const string = @"This is a test"; |
134 AutocompleteMatch::ACMatchClassifications classifications; | 134 AutocompleteMatch::ACMatchClassifications classifications; |
135 | 135 |
136 classifications.push_back( | 136 classifications.push_back( |
137 ACMatchClassification(0, ACMatchClassification::URL)); | 137 ACMatchClassification(0, ACMatchClassification::URL)); |
138 | 138 |
139 NSAttributedString* decorated = | 139 NSAttributedString* decorated = |
140 AutocompletePopupViewMac::DecorateMatchedString( | 140 AutocompletePopupViewMac::DecorateMatchedString( |
141 base::SysNSStringToWide(string), classifications, | 141 base::SysNSStringToUTF16(string), classifications, |
142 color_, dimColor_, font_); | 142 color_, dimColor_, font_); |
143 | 143 |
144 // Result has same characters as the input. | 144 // Result has same characters as the input. |
145 EXPECT_EQ([decorated length], [string length]); | 145 EXPECT_EQ([decorated length], [string length]); |
146 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 146 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
147 | 147 |
148 // One color for the entire string, and it's not the one we passed in. | 148 // One color for the entire string, and it's not the one we passed in. |
149 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 149 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
150 NSForegroundColorAttributeName), | 150 NSForegroundColorAttributeName), |
151 [string length]); | 151 [string length]); |
(...skipping 18 matching lines...) Expand all Loading... |
170 classifications.push_back( | 170 classifications.push_back( |
171 ACMatchClassification(0, ACMatchClassification::NONE)); | 171 ACMatchClassification(0, ACMatchClassification::NONE)); |
172 classifications.push_back( | 172 classifications.push_back( |
173 ACMatchClassification(runLength1, ACMatchClassification::DIM)); | 173 ACMatchClassification(runLength1, ACMatchClassification::DIM)); |
174 classifications.push_back( | 174 classifications.push_back( |
175 ACMatchClassification(runLength1 + runLength2, | 175 ACMatchClassification(runLength1 + runLength2, |
176 ACMatchClassification::NONE)); | 176 ACMatchClassification::NONE)); |
177 | 177 |
178 NSAttributedString* decorated = | 178 NSAttributedString* decorated = |
179 AutocompletePopupViewMac::DecorateMatchedString( | 179 AutocompletePopupViewMac::DecorateMatchedString( |
180 base::SysNSStringToWide(string), classifications, | 180 base::SysNSStringToUTF16(string), classifications, |
181 color_, dimColor_, font_); | 181 color_, dimColor_, font_); |
182 | 182 |
183 // Result has same characters as the input. | 183 // Result has same characters as the input. |
184 EXPECT_EQ([decorated length], [string length]); | 184 EXPECT_EQ([decorated length], [string length]); |
185 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 185 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
186 | 186 |
187 // Should have three font runs, normal, dim, normal. | 187 // Should have three font runs, normal, dim, normal. |
188 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 188 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
189 NSForegroundColorAttributeName), | 189 NSForegroundColorAttributeName), |
190 runLength1); | 190 runLength1); |
(...skipping 29 matching lines...) Expand all Loading... |
220 classifications.push_back( | 220 classifications.push_back( |
221 ACMatchClassification(0, ACMatchClassification::NONE)); | 221 ACMatchClassification(0, ACMatchClassification::NONE)); |
222 classifications.push_back( | 222 classifications.push_back( |
223 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); | 223 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); |
224 classifications.push_back( | 224 classifications.push_back( |
225 ACMatchClassification(runLength1 + runLength2, | 225 ACMatchClassification(runLength1 + runLength2, |
226 ACMatchClassification::NONE)); | 226 ACMatchClassification::NONE)); |
227 | 227 |
228 NSAttributedString* decorated = | 228 NSAttributedString* decorated = |
229 AutocompletePopupViewMac::DecorateMatchedString( | 229 AutocompletePopupViewMac::DecorateMatchedString( |
230 base::SysNSStringToWide(string), classifications, | 230 base::SysNSStringToUTF16(string), classifications, |
231 color_, dimColor_, font_); | 231 color_, dimColor_, font_); |
232 | 232 |
233 // Result has same characters as the input. | 233 // Result has same characters as the input. |
234 EXPECT_EQ([decorated length], [string length]); | 234 EXPECT_EQ([decorated length], [string length]); |
235 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 235 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
236 | 236 |
237 // Our passed-in color for the entire string. | 237 // Our passed-in color for the entire string. |
238 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 238 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
239 NSForegroundColorAttributeName), | 239 NSForegroundColorAttributeName), |
240 [string length]); | 240 [string length]); |
(...skipping 27 matching lines...) Expand all Loading... |
268 classifications.push_back( | 268 classifications.push_back( |
269 ACMatchClassification(0, ACMatchClassification::URL)); | 269 ACMatchClassification(0, ACMatchClassification::URL)); |
270 const int kURLMatch = ACMatchClassification::URL|ACMatchClassification::MATCH; | 270 const int kURLMatch = ACMatchClassification::URL|ACMatchClassification::MATCH; |
271 classifications.push_back(ACMatchClassification(runLength1, kURLMatch)); | 271 classifications.push_back(ACMatchClassification(runLength1, kURLMatch)); |
272 classifications.push_back( | 272 classifications.push_back( |
273 ACMatchClassification(runLength1 + runLength2, | 273 ACMatchClassification(runLength1 + runLength2, |
274 ACMatchClassification::URL)); | 274 ACMatchClassification::URL)); |
275 | 275 |
276 NSAttributedString* decorated = | 276 NSAttributedString* decorated = |
277 AutocompletePopupViewMac::DecorateMatchedString( | 277 AutocompletePopupViewMac::DecorateMatchedString( |
278 base::SysNSStringToWide(string), classifications, | 278 base::SysNSStringToUTF16(string), classifications, |
279 color_, dimColor_, font_); | 279 color_, dimColor_, font_); |
280 | 280 |
281 // Result has same characters as the input. | 281 // Result has same characters as the input. |
282 EXPECT_EQ([decorated length], [string length]); | 282 EXPECT_EQ([decorated length], [string length]); |
283 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 283 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
284 | 284 |
285 // One color for the entire string, and it's not the one we passed in. | 285 // One color for the entire string, and it's not the one we passed in. |
286 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 286 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
287 NSForegroundColorAttributeName), | 287 NSForegroundColorAttributeName), |
288 [string length]); | 288 [string length]); |
(...skipping 14 matching lines...) Expand all Loading... |
303 NSBoldFontMask)); | 303 NSBoldFontMask)); |
304 } | 304 } |
305 | 305 |
306 // Check that matches with both contents and description come back | 306 // Check that matches with both contents and description come back |
307 // with contents at the beginning, description at the end, and | 307 // with contents at the beginning, description at the end, and |
308 // something separating them. Not being specific about the separator | 308 // something separating them. Not being specific about the separator |
309 // on purpose, in case it changes. | 309 // on purpose, in case it changes. |
310 TEST_F(AutocompletePopupViewMacTest, MatchText) { | 310 TEST_F(AutocompletePopupViewMacTest, MatchText) { |
311 NSString* const contents = @"contents"; | 311 NSString* const contents = @"contents"; |
312 NSString* const description = @"description"; | 312 NSString* const description = @"description"; |
313 AutocompleteMatch m = MakeMatch(base::SysNSStringToWide(contents), | 313 AutocompleteMatch m = MakeMatch(base::SysNSStringToUTF16(contents), |
314 base::SysNSStringToWide(description)); | 314 base::SysNSStringToUTF16(description)); |
315 | 315 |
316 NSAttributedString* decorated = | 316 NSAttributedString* decorated = |
317 AutocompletePopupViewMac::MatchText(m, font_, kLargeWidth); | 317 AutocompletePopupViewMac::MatchText(m, font_, kLargeWidth); |
318 | 318 |
319 // Result contains the characters of the input in the right places. | 319 // Result contains the characters of the input in the right places. |
320 EXPECT_GT([decorated length], [contents length] + [description length]); | 320 EXPECT_GT([decorated length], [contents length] + [description length]); |
321 EXPECT_TRUE([[decorated string] hasPrefix:contents]); | 321 EXPECT_TRUE([[decorated string] hasPrefix:contents]); |
322 EXPECT_TRUE([[decorated string] hasSuffix:description]); | 322 EXPECT_TRUE([[decorated string] hasSuffix:description]); |
323 | 323 |
324 // Check that the description is a different color from the | 324 // Check that the description is a different color from the |
(...skipping 14 matching lines...) Expand all Loading... |
339 } | 339 } |
340 | 340 |
341 // Check that MatchText() styles content matches as expected. | 341 // Check that MatchText() styles content matches as expected. |
342 TEST_F(AutocompletePopupViewMacTest, MatchTextContentsMatch) { | 342 TEST_F(AutocompletePopupViewMacTest, MatchTextContentsMatch) { |
343 NSString* const contents = @"This is a test"; | 343 NSString* const contents = @"This is a test"; |
344 // Match "is". | 344 // Match "is". |
345 const NSUInteger runLength1 = 5, runLength2 = 2, runLength3 = 7; | 345 const NSUInteger runLength1 = 5, runLength2 = 2, runLength3 = 7; |
346 // Make sure nobody messed up the inputs. | 346 // Make sure nobody messed up the inputs. |
347 EXPECT_EQ(runLength1 + runLength2 + runLength3, [contents length]); | 347 EXPECT_EQ(runLength1 + runLength2 + runLength3, [contents length]); |
348 | 348 |
349 AutocompleteMatch m = MakeMatch(base::SysNSStringToWide(contents), | 349 AutocompleteMatch m = MakeMatch(base::SysNSStringToUTF16(contents), |
350 std::wstring()); | 350 string16()); |
351 | 351 |
352 // Push each run onto contents classifications. | 352 // Push each run onto contents classifications. |
353 m.contents_class.push_back( | 353 m.contents_class.push_back( |
354 ACMatchClassification(0, ACMatchClassification::NONE)); | 354 ACMatchClassification(0, ACMatchClassification::NONE)); |
355 m.contents_class.push_back( | 355 m.contents_class.push_back( |
356 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); | 356 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); |
357 m.contents_class.push_back( | 357 m.contents_class.push_back( |
358 ACMatchClassification(runLength1 + runLength2, | 358 ACMatchClassification(runLength1 + runLength2, |
359 ACMatchClassification::NONE)); | 359 ACMatchClassification::NONE)); |
360 | 360 |
(...skipping 26 matching lines...) Expand all Loading... |
387 | 387 |
388 // Check that MatchText() styles description matches as expected. | 388 // Check that MatchText() styles description matches as expected. |
389 TEST_F(AutocompletePopupViewMacTest, MatchTextDescriptionMatch) { | 389 TEST_F(AutocompletePopupViewMacTest, MatchTextDescriptionMatch) { |
390 NSString* const contents = @"This is a test"; | 390 NSString* const contents = @"This is a test"; |
391 NSString* const description = @"That was a test"; | 391 NSString* const description = @"That was a test"; |
392 // Match "That was". | 392 // Match "That was". |
393 const NSUInteger runLength1 = 8, runLength2 = 7; | 393 const NSUInteger runLength1 = 8, runLength2 = 7; |
394 // Make sure nobody messed up the inputs. | 394 // Make sure nobody messed up the inputs. |
395 EXPECT_EQ(runLength1 + runLength2, [description length]); | 395 EXPECT_EQ(runLength1 + runLength2, [description length]); |
396 | 396 |
397 AutocompleteMatch m = MakeMatch(base::SysNSStringToWide(contents), | 397 AutocompleteMatch m = MakeMatch(base::SysNSStringToUTF16(contents), |
398 base::SysNSStringToWide(description)); | 398 base::SysNSStringToUTF16(description)); |
399 | 399 |
400 // Push each run onto contents classifications. | 400 // Push each run onto contents classifications. |
401 m.description_class.push_back( | 401 m.description_class.push_back( |
402 ACMatchClassification(0, ACMatchClassification::MATCH)); | 402 ACMatchClassification(0, ACMatchClassification::MATCH)); |
403 m.description_class.push_back( | 403 m.description_class.push_back( |
404 ACMatchClassification(runLength1, ACMatchClassification::NONE)); | 404 ACMatchClassification(runLength1, ACMatchClassification::NONE)); |
405 | 405 |
406 NSAttributedString* decorated = | 406 NSAttributedString* decorated = |
407 AutocompletePopupViewMac::MatchText(m, font_, kLargeWidth); | 407 AutocompletePopupViewMac::MatchText(m, font_, kLargeWidth); |
408 | 408 |
(...skipping 25 matching lines...) Expand all Loading... |
434 EXPECT_TRUE(RunHasFontTrait(decorated, descriptionLocation, NSBoldFontMask)); | 434 EXPECT_TRUE(RunHasFontTrait(decorated, descriptionLocation, NSBoldFontMask)); |
435 | 435 |
436 EXPECT_EQ(RunLengthForAttribute(decorated, descriptionLocation + runLength1, | 436 EXPECT_EQ(RunLengthForAttribute(decorated, descriptionLocation + runLength1, |
437 NSFontAttributeName), runLength2); | 437 NSFontAttributeName), runLength2); |
438 EXPECT_FALSE(RunHasFontTrait(decorated, descriptionLocation + runLength1, | 438 EXPECT_FALSE(RunHasFontTrait(decorated, descriptionLocation + runLength1, |
439 NSBoldFontMask)); | 439 NSBoldFontMask)); |
440 } | 440 } |
441 | 441 |
442 TEST_F(AutocompletePopupViewMacTest, ElideString) { | 442 TEST_F(AutocompletePopupViewMacTest, ElideString) { |
443 NSString* const contents = @"This is a test with long contents"; | 443 NSString* const contents = @"This is a test with long contents"; |
444 const std::wstring wideContents(base::SysNSStringToWide(contents)); | 444 const string16 contents16(base::SysNSStringToUTF16(contents)); |
445 | 445 |
446 const float kWide = 1000.0; | 446 const float kWide = 1000.0; |
447 const float kNarrow = 20.0; | 447 const float kNarrow = 20.0; |
448 | 448 |
449 NSDictionary* attributes = | 449 NSDictionary* attributes = |
450 [NSDictionary dictionaryWithObject:font_.GetNativeFont() | 450 [NSDictionary dictionaryWithObject:font_.GetNativeFont() |
451 forKey:NSFontAttributeName]; | 451 forKey:NSFontAttributeName]; |
452 scoped_nsobject<NSMutableAttributedString> as( | 452 scoped_nsobject<NSMutableAttributedString> as( |
453 [[NSMutableAttributedString alloc] initWithString:contents | 453 [[NSMutableAttributedString alloc] initWithString:contents |
454 attributes:attributes]); | 454 attributes:attributes]); |
455 | 455 |
456 // Nothing happens if the space is really wide. | 456 // Nothing happens if the space is really wide. |
457 NSMutableAttributedString* ret = | 457 NSMutableAttributedString* ret = |
458 AutocompletePopupViewMac::ElideString(as, wideContents, font_, kWide); | 458 AutocompletePopupViewMac::ElideString(as, contents16, font_, kWide); |
459 EXPECT_TRUE(ret == as); | 459 EXPECT_TRUE(ret == as); |
460 EXPECT_TRUE([[as string] isEqualToString:contents]); | 460 EXPECT_TRUE([[as string] isEqualToString:contents]); |
461 | 461 |
462 // When elided, result is the same as ElideText(). | 462 // When elided, result is the same as ElideText(). |
463 ret = AutocompletePopupViewMac::ElideString(as, wideContents, font_, kNarrow); | 463 ret = AutocompletePopupViewMac::ElideString(as, contents16, font_, kNarrow); |
464 std::wstring elided(UTF16ToWideHack(ui::ElideText(WideToUTF16Hack( | 464 string16 elided = ui::ElideText(contents16, font_, kNarrow, false); |
465 wideContents), font_, kNarrow, false))); | |
466 EXPECT_TRUE(ret == as); | 465 EXPECT_TRUE(ret == as); |
467 EXPECT_FALSE([[as string] isEqualToString:contents]); | 466 EXPECT_FALSE([[as string] isEqualToString:contents]); |
468 EXPECT_TRUE([[as string] isEqualToString:base::SysWideToNSString(elided)]); | 467 EXPECT_TRUE([[as string] isEqualToString:base::SysUTF16ToNSString(elided)]); |
469 | 468 |
470 // When elided, result is the same as ElideText(). | 469 // When elided, result is the same as ElideText(). |
471 ret = AutocompletePopupViewMac::ElideString(as, wideContents, font_, 0.0); | 470 ret = AutocompletePopupViewMac::ElideString(as, contents16, font_, 0.0); |
472 elided = UTF16ToWideHack(ui::ElideText(WideToUTF16Hack(wideContents), font_, | 471 elided = ui::ElideText(contents16, font_, 0.0, false); |
473 0.0, false)); | |
474 EXPECT_TRUE(ret == as); | 472 EXPECT_TRUE(ret == as); |
475 EXPECT_FALSE([[as string] isEqualToString:contents]); | 473 EXPECT_FALSE([[as string] isEqualToString:contents]); |
476 EXPECT_TRUE([[as string] isEqualToString:base::SysWideToNSString(elided)]); | 474 EXPECT_TRUE([[as string] isEqualToString:base::SysUTF16ToNSString(elided)]); |
477 } | 475 } |
478 | 476 |
479 TEST_F(AutocompletePopupViewMacTest, MatchTextElide) { | 477 TEST_F(AutocompletePopupViewMacTest, MatchTextElide) { |
480 NSString* const contents = @"This is a test with long contents"; | 478 NSString* const contents = @"This is a test with long contents"; |
481 NSString* const description = @"That was a test"; | 479 NSString* const description = @"That was a test"; |
482 // Match "long". | 480 // Match "long". |
483 const NSUInteger runLength1 = 20, runLength2 = 4, runLength3 = 9; | 481 const NSUInteger runLength1 = 20, runLength2 = 4, runLength3 = 9; |
484 // Make sure nobody messed up the inputs. | 482 // Make sure nobody messed up the inputs. |
485 EXPECT_EQ(runLength1 + runLength2 + runLength3, [contents length]); | 483 EXPECT_EQ(runLength1 + runLength2 + runLength3, [contents length]); |
486 | 484 |
487 AutocompleteMatch m = MakeMatch(base::SysNSStringToWide(contents), | 485 AutocompleteMatch m = MakeMatch(base::SysNSStringToUTF16(contents), |
488 base::SysNSStringToWide(description)); | 486 base::SysNSStringToUTF16(description)); |
489 | 487 |
490 // Push each run onto contents classifications. | 488 // Push each run onto contents classifications. |
491 m.contents_class.push_back( | 489 m.contents_class.push_back( |
492 ACMatchClassification(0, ACMatchClassification::NONE)); | 490 ACMatchClassification(0, ACMatchClassification::NONE)); |
493 m.contents_class.push_back( | 491 m.contents_class.push_back( |
494 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); | 492 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); |
495 m.contents_class.push_back( | 493 m.contents_class.push_back( |
496 ACMatchClassification(runLength1 + runLength2, | 494 ACMatchClassification(runLength1 + runLength2, |
497 ACMatchClassification::URL)); | 495 ACMatchClassification::URL)); |
498 | 496 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 // updates the model's selection from the matrix before returning. | 543 // updates the model's selection from the matrix before returning. |
546 // Could possibly test that via -select:. | 544 // Could possibly test that via -select:. |
547 | 545 |
548 // TODO(shess): Test that AutocompleteButtonCell returns the right | 546 // TODO(shess): Test that AutocompleteButtonCell returns the right |
549 // background colors for on, highlighted, and neither. | 547 // background colors for on, highlighted, and neither. |
550 | 548 |
551 // TODO(shess): Test that AutocompleteMatrixTarget can be initialized | 549 // TODO(shess): Test that AutocompleteMatrixTarget can be initialized |
552 // and then sends -select: to the view. | 550 // and then sends -select: to the view. |
553 | 551 |
554 } // namespace | 552 } // namespace |
OLD | NEW |