Chromium Code Reviews| Index: chrome/browser/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm |
| diff --git a/chrome/browser/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm b/chrome/browser/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm |
| index d3a4bfd569bd3735a3c1eda35bce3eaf109071bf..8d756e6b05e0cff5910bcd8d6c4f720a61d768b0 100644 |
| --- a/chrome/browser/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm |
| +++ b/chrome/browser/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm |
| @@ -17,7 +17,9 @@ |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "testing/platform_test.h" |
| +#import "third_party/ocmock/OCMock/OCMock.h" |
| +using ::testing::Return; |
| using ::testing::StrictMock; |
| using ::testing::_; |
| @@ -33,12 +35,9 @@ const CGFloat kNarrowWidth(5.0); |
| class MockDecoration : public LocationBarDecoration { |
| public: |
| virtual CGFloat GetWidthForSpace(CGFloat width) { return 20.0; } |
| - virtual bool IsVisible() const { return visible_; } |
| - void SetVisible(bool visible) { visible_ = visible; } |
| MOCK_METHOD2(DrawInFrame, void(NSRect frame, NSView* control_view)); |
| - |
| - bool visible_; |
| + MOCK_METHOD0(GetToolTip, NSString*()); |
| }; |
| class AutocompleteTextFieldCellTest : public CocoaTest { |
| @@ -343,8 +342,6 @@ TEST_F(AutocompleteTextFieldCellTest, RightDecorationFrame) { |
| EXPECT_LT(NSMinX(textFrame), NSMinX(decoration1Rect)); |
| } |
| - NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; |
|
Scott Hess - ex-Googler
2010/07/17 00:35:10
I, too, am confused by this. I'll try to figure o
|
| - |
| // Test that the cell drops the search hint if there is no room for |
| // it. |
| TEST_F(AutocompleteTextFieldCellTest, OmitsSearchHintIfNarrow) { |
| @@ -387,4 +384,37 @@ TEST_F(AutocompleteTextFieldCellTest, TrimsKeywordHintIfNarrow) { |
| EXPECT_EQ([[cell hintString] length], 1U); |
| } |
| +// Verify -[AutocompleteTextFieldCell updateToolTipsInRect:ofView:]. |
| +TEST_F(AutocompleteTextFieldCellTest, UpdateToolTips) { |
| + NSString* tooltip = @"tooltip"; |
| + |
| + // Left decoration returns a tooltip, make sure it is called at |
| + // least once. |
| + mock_left_decoration_.SetVisible(true); |
| + EXPECT_CALL(mock_left_decoration_, GetToolTip()) |
| + .WillOnce(Return(tooltip)) |
| + .WillRepeatedly(Return(tooltip)); |
| + |
| + // Right decoration returns no tooltip, make sure it is called at |
| + // least once. |
| + mock_right_decoration0_.SetVisible(true); |
| + EXPECT_CALL(mock_right_decoration0_, GetToolTip()) |
| + .WillOnce(Return((NSString*)nil)) |
| + .WillRepeatedly(Return((NSString*)nil)); |
| + |
| + AutocompleteTextFieldCell* cell = |
| + static_cast<AutocompleteTextFieldCell*>([view_ cell]); |
| + const NSRect bounds = [view_ bounds]; |
| + const NSRect leftDecorationRect = |
| + [cell frameForDecoration:&mock_left_decoration_ inFrame:bounds]; |
| + |
| + // |controlView| gets the tooltip for the left decoration. |
| + id controlView = [OCMockObject mockForClass:[AutocompleteTextField class]]; |
| + [[controlView expect] addToolTip:tooltip forRect:leftDecorationRect]; |
| + |
| + [cell updateToolTipsInRect:bounds ofView:controlView]; |
| + |
| + [controlView verify]; |
| +} |
| + |
| } // namespace |