OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "chrome/browser/autocomplete/autocomplete.h" | 8 #include "chrome/browser/autocomplete/autocomplete.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/platform_test.h" |
10 | 10 |
11 namespace { | 11 namespace { |
12 | 12 |
13 class AutocompletePopupViewMacTest : public testing::Test { | 13 class AutocompletePopupViewMacTest : public PlatformTest { |
14 public: | 14 public: |
15 AutocompletePopupViewMacTest() { | 15 AutocompletePopupViewMacTest() {} |
| 16 |
| 17 virtual void SetUp() { |
| 18 PlatformTest::SetUp(); |
| 19 |
| 20 // These are here because there is no autorelease pool for the |
| 21 // constructor. |
| 22 color_ = [NSColor blackColor]; |
| 23 font_ = [NSFont userFontOfSize:12]; |
16 } | 24 } |
17 | 25 |
18 // Returns the length of the run starting at |location| for which | 26 // Returns the length of the run starting at |location| for which |
19 // |attributeName| remains the same. | 27 // |attributeName| remains the same. |
20 static NSUInteger RunLengthForAttribute(NSAttributedString* string, | 28 static NSUInteger RunLengthForAttribute(NSAttributedString* string, |
21 NSUInteger location, | 29 NSUInteger location, |
22 NSString* attributeName) { | 30 NSString* attributeName) { |
23 const NSRange fullRange = NSMakeRange(0, [string length]); | 31 const NSRange fullRange = NSMakeRange(0, [string length]); |
24 NSRange range; | 32 NSRange range; |
25 [string attribute:attributeName | 33 [string attribute:attributeName |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // AutocompleteMatch doesn't really have the right constructor for our | 80 // AutocompleteMatch doesn't really have the right constructor for our |
73 // needs. Fake one for us to use. | 81 // needs. Fake one for us to use. |
74 static AutocompleteMatch MakeMatch(const std::wstring &contents, | 82 static AutocompleteMatch MakeMatch(const std::wstring &contents, |
75 const std::wstring &description) { | 83 const std::wstring &description) { |
76 AutocompleteMatch m(NULL, 1, true, AutocompleteMatch::URL_WHAT_YOU_TYPED); | 84 AutocompleteMatch m(NULL, 1, true, AutocompleteMatch::URL_WHAT_YOU_TYPED); |
77 m.contents = contents; | 85 m.contents = contents; |
78 m.description = description; | 86 m.description = description; |
79 return m; | 87 return m; |
80 } | 88 } |
81 | 89 |
| 90 NSColor* color_; // weak |
| 91 NSFont* font_; // weak |
82 }; | 92 }; |
83 | 93 |
84 // Simple inputs with no matches should result in styled output who's | 94 // Simple inputs with no matches should result in styled output who's |
85 // text matches the input string, with the passed-in color, and | 95 // text matches the input string, with the passed-in color, and |
86 // nothing bolded. | 96 // nothing bolded. |
87 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringNoMatch) { | 97 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringNoMatch) { |
88 const NSString* string = @"This is a test"; | 98 const NSString* string = @"This is a test"; |
89 AutocompleteMatch::ACMatchClassifications classifications; | 99 AutocompleteMatch::ACMatchClassifications classifications; |
90 | 100 |
91 NSAttributedString* decorated = | 101 NSAttributedString* decorated = |
92 AutocompletePopupViewMac::DecorateMatchedString( | 102 AutocompletePopupViewMac::DecorateMatchedString( |
93 base::SysNSStringToWide(string), classifications, | 103 base::SysNSStringToWide(string), classifications, |
94 [NSColor blackColor]); | 104 color_, font_); |
95 | 105 |
96 // Result has same characters as the input. | 106 // Result has same characters as the input. |
97 EXPECT_EQ([decorated length], [string length]); | 107 EXPECT_EQ([decorated length], [string length]); |
98 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 108 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
99 | 109 |
100 // Our passed-in color for the entire string. | 110 // Our passed-in color for the entire string. |
101 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 111 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
102 NSForegroundColorAttributeName), | 112 NSForegroundColorAttributeName), |
103 [string length]); | 113 [string length]); |
104 EXPECT_TRUE(RunHasColor(decorated, 0U, [NSColor blackColor])); | 114 EXPECT_TRUE(RunHasColor(decorated, 0U, color_)); |
105 | 115 |
106 // An unbolded font for the entire string. | 116 // An unbolded font for the entire string. |
107 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 117 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
108 NSFontAttributeName), [string length]); | 118 NSFontAttributeName), [string length]); |
109 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); | 119 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); |
110 } | 120 } |
111 | 121 |
112 // Identical to DecorateMatchedStringNoMatch, except test that URL | 122 // Identical to DecorateMatchedStringNoMatch, except test that URL |
113 // style gets a different color than we passed in. | 123 // style gets a different color than we passed in. |
114 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringURLNoMatch) { | 124 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringURLNoMatch) { |
115 const NSString* string = @"This is a test"; | 125 const NSString* string = @"This is a test"; |
116 AutocompleteMatch::ACMatchClassifications classifications; | 126 AutocompleteMatch::ACMatchClassifications classifications; |
117 | 127 |
118 classifications.push_back( | 128 classifications.push_back( |
119 ACMatchClassification(0, ACMatchClassification::URL)); | 129 ACMatchClassification(0, ACMatchClassification::URL)); |
120 | 130 |
121 NSAttributedString* decorated = | 131 NSAttributedString* decorated = |
122 AutocompletePopupViewMac::DecorateMatchedString( | 132 AutocompletePopupViewMac::DecorateMatchedString( |
123 base::SysNSStringToWide(string), classifications, | 133 base::SysNSStringToWide(string), classifications, |
124 [NSColor blackColor]); | 134 color_, font_); |
125 | 135 |
126 // Result has same characters as the input. | 136 // Result has same characters as the input. |
127 EXPECT_EQ([decorated length], [string length]); | 137 EXPECT_EQ([decorated length], [string length]); |
128 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 138 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
129 | 139 |
130 // One color for the entire string, and it's not the one we passed in. | 140 // One color for the entire string, and it's not the one we passed in. |
131 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 141 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
132 NSForegroundColorAttributeName), | 142 NSForegroundColorAttributeName), |
133 [string length]); | 143 [string length]); |
134 EXPECT_FALSE(RunHasColor(decorated, 0U, [NSColor blackColor])); | 144 EXPECT_FALSE(RunHasColor(decorated, 0U, color_)); |
135 | 145 |
136 // An unbolded font for the entire string. | 146 // An unbolded font for the entire string. |
137 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 147 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
138 NSFontAttributeName), [string length]); | 148 NSFontAttributeName), [string length]); |
139 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); | 149 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); |
140 } | 150 } |
141 | 151 |
142 // Test that DIM doesn't have any impact - true at this time. | 152 // Test that DIM doesn't have any impact - true at this time. |
143 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringDimNoMatch) { | 153 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringDimNoMatch) { |
144 const NSString* string = @"This is a test"; | 154 const NSString* string = @"This is a test"; |
145 | 155 |
146 // Switch to DIM halfway through. | 156 // Switch to DIM halfway through. |
147 AutocompleteMatch::ACMatchClassifications classifications; | 157 AutocompleteMatch::ACMatchClassifications classifications; |
148 classifications.push_back( | 158 classifications.push_back( |
149 ACMatchClassification(0, ACMatchClassification::NONE)); | 159 ACMatchClassification(0, ACMatchClassification::NONE)); |
150 classifications.push_back( | 160 classifications.push_back( |
151 ACMatchClassification([string length] / 2, ACMatchClassification::DIM)); | 161 ACMatchClassification([string length] / 2, ACMatchClassification::DIM)); |
152 | 162 |
153 NSAttributedString* decorated = | 163 NSAttributedString* decorated = |
154 AutocompletePopupViewMac::DecorateMatchedString( | 164 AutocompletePopupViewMac::DecorateMatchedString( |
155 base::SysNSStringToWide(string), classifications, | 165 base::SysNSStringToWide(string), classifications, |
156 [NSColor blackColor]); | 166 color_, font_); |
157 | 167 |
158 // Result has same characters as the input. | 168 // Result has same characters as the input. |
159 EXPECT_EQ([decorated length], [string length]); | 169 EXPECT_EQ([decorated length], [string length]); |
160 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 170 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
161 | 171 |
162 // Our passed-in color for the entire string. | 172 // Our passed-in color for the entire string. |
163 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 173 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
164 NSForegroundColorAttributeName), | 174 NSForegroundColorAttributeName), |
165 [string length]); | 175 [string length]); |
166 EXPECT_TRUE(RunHasColor(decorated, 0U, [NSColor blackColor])); | 176 EXPECT_TRUE(RunHasColor(decorated, 0U, color_)); |
167 | 177 |
168 // An unbolded font for the entire string. | 178 // An unbolded font for the entire string. |
169 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 179 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
170 NSFontAttributeName), [string length]); | 180 NSFontAttributeName), [string length]); |
171 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); | 181 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); |
172 } | 182 } |
173 | 183 |
174 // Test that the matched run gets bold-faced, but keeps the same | 184 // Test that the matched run gets bold-faced, but keeps the same |
175 // color. | 185 // color. |
176 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringMatch) { | 186 TEST_F(AutocompletePopupViewMacTest, DecorateMatchedStringMatch) { |
177 const NSString* string = @"This is a test"; | 187 const NSString* string = @"This is a test"; |
178 // Match "is". | 188 // Match "is". |
179 const NSUInteger runLength1 = 5, runLength2 = 2, runLength3 = 7; | 189 const NSUInteger runLength1 = 5, runLength2 = 2, runLength3 = 7; |
180 // Make sure nobody messed up the inputs. | 190 // Make sure nobody messed up the inputs. |
181 EXPECT_EQ(runLength1 + runLength2 + runLength3, [string length]); | 191 EXPECT_EQ(runLength1 + runLength2 + runLength3, [string length]); |
182 | 192 |
183 // Push each run onto classifications. | 193 // Push each run onto classifications. |
184 AutocompleteMatch::ACMatchClassifications classifications; | 194 AutocompleteMatch::ACMatchClassifications classifications; |
185 classifications.push_back( | 195 classifications.push_back( |
186 ACMatchClassification(0, ACMatchClassification::NONE)); | 196 ACMatchClassification(0, ACMatchClassification::NONE)); |
187 classifications.push_back( | 197 classifications.push_back( |
188 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); | 198 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); |
189 classifications.push_back( | 199 classifications.push_back( |
190 ACMatchClassification(runLength1 + runLength2, | 200 ACMatchClassification(runLength1 + runLength2, |
191 ACMatchClassification::NONE)); | 201 ACMatchClassification::NONE)); |
192 | 202 |
193 NSAttributedString* decorated = | 203 NSAttributedString* decorated = |
194 AutocompletePopupViewMac::DecorateMatchedString( | 204 AutocompletePopupViewMac::DecorateMatchedString( |
195 base::SysNSStringToWide(string), classifications, | 205 base::SysNSStringToWide(string), classifications, |
196 [NSColor blackColor]); | 206 color_, font_); |
197 | 207 |
198 // Result has same characters as the input. | 208 // Result has same characters as the input. |
199 EXPECT_EQ([decorated length], [string length]); | 209 EXPECT_EQ([decorated length], [string length]); |
200 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 210 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
201 | 211 |
202 // Our passed-in color for the entire string. | 212 // Our passed-in color for the entire string. |
203 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 213 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
204 NSForegroundColorAttributeName), | 214 NSForegroundColorAttributeName), |
205 [string length]); | 215 [string length]); |
206 EXPECT_TRUE(RunHasColor(decorated, 0U, [NSColor blackColor])); | 216 EXPECT_TRUE(RunHasColor(decorated, 0U, color_)); |
207 | 217 |
208 // Should have three font runs, not bold, bold, then not bold again. | 218 // Should have three font runs, not bold, bold, then not bold again. |
209 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 219 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
210 NSFontAttributeName), runLength1); | 220 NSFontAttributeName), runLength1); |
211 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); | 221 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); |
212 | 222 |
213 EXPECT_EQ(RunLengthForAttribute(decorated, runLength1, | 223 EXPECT_EQ(RunLengthForAttribute(decorated, runLength1, |
214 NSFontAttributeName), runLength2); | 224 NSFontAttributeName), runLength2); |
215 EXPECT_TRUE(RunHasFontTrait(decorated, runLength1, NSBoldFontMask)); | 225 EXPECT_TRUE(RunHasFontTrait(decorated, runLength1, NSBoldFontMask)); |
216 | 226 |
(...skipping 17 matching lines...) Expand all Loading... |
234 ACMatchClassification(0, ACMatchClassification::URL)); | 244 ACMatchClassification(0, ACMatchClassification::URL)); |
235 const int kURLMatch = ACMatchClassification::URL|ACMatchClassification::MATCH; | 245 const int kURLMatch = ACMatchClassification::URL|ACMatchClassification::MATCH; |
236 classifications.push_back(ACMatchClassification(runLength1, kURLMatch)); | 246 classifications.push_back(ACMatchClassification(runLength1, kURLMatch)); |
237 classifications.push_back( | 247 classifications.push_back( |
238 ACMatchClassification(runLength1 + runLength2, | 248 ACMatchClassification(runLength1 + runLength2, |
239 ACMatchClassification::URL)); | 249 ACMatchClassification::URL)); |
240 | 250 |
241 NSAttributedString* decorated = | 251 NSAttributedString* decorated = |
242 AutocompletePopupViewMac::DecorateMatchedString( | 252 AutocompletePopupViewMac::DecorateMatchedString( |
243 base::SysNSStringToWide(string), classifications, | 253 base::SysNSStringToWide(string), classifications, |
244 [NSColor blackColor]); | 254 color_, font_); |
245 | 255 |
246 // Result has same characters as the input. | 256 // Result has same characters as the input. |
247 EXPECT_EQ([decorated length], [string length]); | 257 EXPECT_EQ([decorated length], [string length]); |
248 EXPECT_TRUE([[decorated string] isEqualToString:string]); | 258 EXPECT_TRUE([[decorated string] isEqualToString:string]); |
249 | 259 |
250 // One color for the entire string, and it's not the one we passed in. | 260 // One color for the entire string, and it's not the one we passed in. |
251 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 261 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
252 NSForegroundColorAttributeName), | 262 NSForegroundColorAttributeName), |
253 [string length]); | 263 [string length]); |
254 EXPECT_FALSE(RunHasColor(decorated, 0U, [NSColor blackColor])); | 264 EXPECT_FALSE(RunHasColor(decorated, 0U, color_)); |
255 | 265 |
256 // Should have three font runs, not bold, bold, then not bold again. | 266 // Should have three font runs, not bold, bold, then not bold again. |
257 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 267 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
258 NSFontAttributeName), runLength1); | 268 NSFontAttributeName), runLength1); |
259 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); | 269 EXPECT_FALSE(RunHasFontTrait(decorated, 0U, NSBoldFontMask)); |
260 | 270 |
261 EXPECT_EQ(RunLengthForAttribute(decorated, runLength1, | 271 EXPECT_EQ(RunLengthForAttribute(decorated, runLength1, |
262 NSFontAttributeName), runLength2); | 272 NSFontAttributeName), runLength2); |
263 EXPECT_TRUE(RunHasFontTrait(decorated, runLength1, NSBoldFontMask)); | 273 EXPECT_TRUE(RunHasFontTrait(decorated, runLength1, NSBoldFontMask)); |
264 | 274 |
265 EXPECT_EQ(RunLengthForAttribute(decorated, runLength1 + runLength2, | 275 EXPECT_EQ(RunLengthForAttribute(decorated, runLength1 + runLength2, |
266 NSFontAttributeName), runLength3); | 276 NSFontAttributeName), runLength3); |
267 EXPECT_FALSE(RunHasFontTrait(decorated, runLength1 + runLength2, | 277 EXPECT_FALSE(RunHasFontTrait(decorated, runLength1 + runLength2, |
268 NSBoldFontMask)); | 278 NSBoldFontMask)); |
269 } | 279 } |
270 | 280 |
271 // Check that matches with both contents and description come back | 281 // Check that matches with both contents and description come back |
272 // with contents at the beginning, description at the end, and | 282 // with contents at the beginning, description at the end, and |
273 // something separating them. Not being specific about the separator | 283 // something separating them. Not being specific about the separator |
274 // on purpose, in case it changes. | 284 // on purpose, in case it changes. |
275 TEST_F(AutocompletePopupViewMacTest, MatchText) { | 285 TEST_F(AutocompletePopupViewMacTest, MatchText) { |
276 const NSString* contents = @"contents"; | 286 const NSString* contents = @"contents"; |
277 const NSString* description = @"description"; | 287 const NSString* description = @"description"; |
278 AutocompleteMatch m = MakeMatch(base::SysNSStringToWide(contents), | 288 AutocompleteMatch m = MakeMatch(base::SysNSStringToWide(contents), |
279 base::SysNSStringToWide(description)); | 289 base::SysNSStringToWide(description)); |
280 | 290 |
281 NSAttributedString* decorated = AutocompletePopupViewMac::MatchText(m); | 291 NSAttributedString* decorated = AutocompletePopupViewMac::MatchText(m, font_); |
282 | 292 |
283 // Result contains the characters of the input in the right places. | 293 // Result contains the characters of the input in the right places. |
284 EXPECT_GT([decorated length], [contents length] + [description length]); | 294 EXPECT_GT([decorated length], [contents length] + [description length]); |
285 EXPECT_TRUE([[decorated string] hasPrefix:contents]); | 295 EXPECT_TRUE([[decorated string] hasPrefix:contents]); |
286 EXPECT_TRUE([[decorated string] hasSuffix:description]); | 296 EXPECT_TRUE([[decorated string] hasSuffix:description]); |
287 | 297 |
288 // Check that the description is a different color from the | 298 // Check that the description is a different color from the |
289 // contents. | 299 // contents. |
290 const NSUInteger descriptionLocation = | 300 const NSUInteger descriptionLocation = |
291 [decorated length] - [description length]; | 301 [decorated length] - [description length]; |
(...skipping 23 matching lines...) Expand all Loading... |
315 | 325 |
316 // Push each run onto contents classifications. | 326 // Push each run onto contents classifications. |
317 m.contents_class.push_back( | 327 m.contents_class.push_back( |
318 ACMatchClassification(0, ACMatchClassification::NONE)); | 328 ACMatchClassification(0, ACMatchClassification::NONE)); |
319 m.contents_class.push_back( | 329 m.contents_class.push_back( |
320 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); | 330 ACMatchClassification(runLength1, ACMatchClassification::MATCH)); |
321 m.contents_class.push_back( | 331 m.contents_class.push_back( |
322 ACMatchClassification(runLength1 + runLength2, | 332 ACMatchClassification(runLength1 + runLength2, |
323 ACMatchClassification::NONE)); | 333 ACMatchClassification::NONE)); |
324 | 334 |
325 NSAttributedString* decorated = AutocompletePopupViewMac::MatchText(m); | 335 NSAttributedString* decorated = AutocompletePopupViewMac::MatchText(m, font_); |
326 | 336 |
327 // Result has same characters as the input. | 337 // Result has same characters as the input. |
328 EXPECT_EQ([decorated length], [contents length]); | 338 EXPECT_EQ([decorated length], [contents length]); |
329 EXPECT_TRUE([[decorated string] isEqualToString:contents]); | 339 EXPECT_TRUE([[decorated string] isEqualToString:contents]); |
330 | 340 |
331 // Result is all one color. | 341 // Result is all one color. |
332 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, | 342 EXPECT_EQ(RunLengthForAttribute(decorated, 0U, |
333 NSForegroundColorAttributeName), | 343 NSForegroundColorAttributeName), |
334 [contents length]); | 344 [contents length]); |
335 | 345 |
(...skipping 23 matching lines...) Expand all Loading... |
359 | 369 |
360 AutocompleteMatch m = MakeMatch(base::SysNSStringToWide(contents), | 370 AutocompleteMatch m = MakeMatch(base::SysNSStringToWide(contents), |
361 base::SysNSStringToWide(description)); | 371 base::SysNSStringToWide(description)); |
362 | 372 |
363 // Push each run onto contents classifications. | 373 // Push each run onto contents classifications. |
364 m.description_class.push_back( | 374 m.description_class.push_back( |
365 ACMatchClassification(0, ACMatchClassification::MATCH)); | 375 ACMatchClassification(0, ACMatchClassification::MATCH)); |
366 m.description_class.push_back( | 376 m.description_class.push_back( |
367 ACMatchClassification(runLength1, ACMatchClassification::NONE)); | 377 ACMatchClassification(runLength1, ACMatchClassification::NONE)); |
368 | 378 |
369 NSAttributedString* decorated = AutocompletePopupViewMac::MatchText(m); | 379 NSAttributedString* decorated = AutocompletePopupViewMac::MatchText(m, font_); |
370 | 380 |
371 // Result contains the characters of the input. | 381 // Result contains the characters of the input. |
372 EXPECT_GT([decorated length], [contents length] + [description length]); | 382 EXPECT_GT([decorated length], [contents length] + [description length]); |
373 EXPECT_TRUE([[decorated string] hasPrefix:contents]); | 383 EXPECT_TRUE([[decorated string] hasPrefix:contents]); |
374 EXPECT_TRUE([[decorated string] hasSuffix:description]); | 384 EXPECT_TRUE([[decorated string] hasSuffix:description]); |
375 | 385 |
376 // Check that the description is a different color from the | 386 // Check that the description is a different color from the |
377 // contents. | 387 // contents. |
378 const NSUInteger descriptionLocation = | 388 const NSUInteger descriptionLocation = |
379 [decorated length] - [description length]; | 389 [decorated length] - [description length]; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 // updates the model's selection from the matrix before returning. | 425 // updates the model's selection from the matrix before returning. |
416 // Could possibly test that via -select:. | 426 // Could possibly test that via -select:. |
417 | 427 |
418 // TODO(shess): Test that AutocompleteButtonCell returns the right | 428 // TODO(shess): Test that AutocompleteButtonCell returns the right |
419 // background colors for on, highlighted, and neither. | 429 // background colors for on, highlighted, and neither. |
420 | 430 |
421 // TODO(shess): Test that AutocompleteMatrixTarget can be initialized | 431 // TODO(shess): Test that AutocompleteMatrixTarget can be initialized |
422 // and then sends -select: to the view. | 432 // and then sends -select: to the view. |
423 | 433 |
424 } // namespace | 434 } // namespace |
OLD | NEW |