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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
8 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
9 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 9 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
10 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.h" | 10 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 171 } |
172 | 172 |
173 TEST_F(AutocompleteTextFieldCellTest, TextFrame) { | 173 TEST_F(AutocompleteTextFieldCellTest, TextFrame) { |
174 AutocompleteTextFieldCell* cell = | 174 AutocompleteTextFieldCell* cell = |
175 static_cast<AutocompleteTextFieldCell*>([view_ cell]); | 175 static_cast<AutocompleteTextFieldCell*>([view_ cell]); |
176 const NSRect bounds([view_ bounds]); | 176 const NSRect bounds([view_ bounds]); |
177 NSRect textFrame; | 177 NSRect textFrame; |
178 | 178 |
179 // The cursor frame should stay the same throughout. | 179 // The cursor frame should stay the same throughout. |
180 const NSRect cursorFrame([cell textCursorFrameForFrame:bounds]); | 180 const NSRect cursorFrame([cell textCursorFrameForFrame:bounds]); |
| 181 EXPECT_TRUE(NSEqualRects(cursorFrame, bounds)); |
181 | 182 |
182 // At default settings, everything goes to the text area. | 183 // At default settings, everything goes to the text area. |
183 textFrame = [cell textFrameForFrame:bounds]; | 184 textFrame = [cell textFrameForFrame:bounds]; |
184 EXPECT_FALSE(NSIsEmptyRect(textFrame)); | 185 EXPECT_FALSE(NSIsEmptyRect(textFrame)); |
185 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); | 186 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); |
186 EXPECT_EQ(NSMinX(bounds), NSMinX(textFrame)); | 187 EXPECT_EQ(NSMinX(bounds), NSMinX(textFrame)); |
187 EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame)); | 188 EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame)); |
188 EXPECT_TRUE(NSEqualRects(cursorFrame, textFrame)); | 189 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); |
189 | 190 |
190 // Small search hint leaves text frame to left. | 191 // Small search hint leaves text frame to left. |
191 [cell setSearchHintString:@"Search hint" availableWidth:kWidth]; | 192 [cell setSearchHintString:@"Search hint" availableWidth:kWidth]; |
192 textFrame = [cell textFrameForFrame:bounds]; | 193 textFrame = [cell textFrameForFrame:bounds]; |
193 EXPECT_FALSE(NSIsEmptyRect(textFrame)); | 194 EXPECT_FALSE(NSIsEmptyRect(textFrame)); |
194 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); | 195 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); |
195 EXPECT_LT(NSMaxX(textFrame), NSMaxX(bounds)); | 196 EXPECT_LT(NSMaxX(textFrame), NSMaxX(bounds)); |
196 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); | 197 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); |
197 | 198 |
198 // Save search-hint's frame for future reference. | 199 // Save search-hint's frame for future reference. |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]); | 382 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]); |
382 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]); | 383 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]); |
383 | 384 |
384 // Narrow width suppresses everything but the image. | 385 // Narrow width suppresses everything but the image. |
385 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix | 386 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix |
386 availableWidth:kNarrowWidth]; | 387 availableWidth:kNarrowWidth]; |
387 EXPECT_EQ([[cell hintString] length], 1U); | 388 EXPECT_EQ([[cell hintString] length], 1U); |
388 } | 389 } |
389 | 390 |
390 } // namespace | 391 } // namespace |
OLD | NEW |