Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1036)

Unified Diff: chrome/browser/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm

Issue 2868058: [Mac] Re-enable decoration tooltips in omnibox. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698