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

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm

Issue 2478673002: [Mac] Hover/Pressed background for the Omnibox decorations (Closed)
Patch Set: Popup padding Created 4 years, 1 month 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
Index: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm
index 0d304d8e6d700b08d9ab8254cdc68b476fb16ee3..75da281d05eee8d178f28f620788a725153039ca 100644
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest.mm
@@ -574,6 +574,8 @@ TEST_F(AutocompleteTextFieldTest, LeftDecorationMouseDown) {
.WillRepeatedly(Return(true));
AutocompleteTextFieldCell* cell = [field_ cell];
+ [cell updateMouseTrackingAndToolTipsInRect:[field_ frame] ofView:field_];
+
const NSRect iconFrame =
[cell frameForDecoration:&mock_left_decoration_ inFrame:[field_ bounds]];
const NSPoint location = NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame));
@@ -621,6 +623,8 @@ TEST_F(AutocompleteTextFieldTest, RightDecorationMouseDown) {
.WillRepeatedly(Return(true));
AutocompleteTextFieldCell* cell = [field_ cell];
+ [cell updateMouseTrackingAndToolTipsInRect:[field_ frame] ofView:field_];
+
const NSRect bounds = [field_ bounds];
const NSRect iconFrame =
[cell frameForDecoration:&mock_right_decoration_ inFrame:bounds];
@@ -797,6 +801,35 @@ TEST_F(AutocompleteTextFieldTest, HideFocusState) {
EXPECT_TRUE([FieldEditor() shouldDrawInsertionPoint]);
}
+// Verify that the tracking areas are added properly.
+TEST_F(AutocompleteTextFieldTest, UpdateTrackingAreas) {
+ AutocompleteTextFieldCell* cell =
+ static_cast<AutocompleteTextFieldCell*>([field_ cell]);
Robert Sesek 2016/11/11 19:35:07 Is this cast needed? Line 837 doesn't do it.
spqchan 2016/11/12 00:36:20 Done.
+
+ mock_left_decoration_.SetVisible(true);
+ mock_right_decoration_.SetVisible(true);
+
+ EXPECT_CALL(mock_left_decoration_, AcceptsMousePress())
+ .WillOnce(Return(true))
+ .WillRepeatedly(Return(true));
+ EXPECT_CALL(mock_right_decoration_, AcceptsMousePress())
+ .WillOnce(Return(false))
+ .WillRepeatedly(Return(false));
+ [cell updateMouseTrackingAndToolTipsInRect:[field_ bounds] ofView:field_];
+
+ EXPECT_EQ([cell mouseTrackingDecorations].size(), 1.0);
+
+ [cell clearTrackingArea];
+ EXPECT_TRUE([cell mouseTrackingDecorations].empty());
+
+ EXPECT_CALL(mock_right_decoration_, AcceptsMousePress())
+ .WillOnce(Return(true))
+ .WillRepeatedly(Return(true));
+
+ [cell updateMouseTrackingAndToolTipsInRect:[field_ bounds] ofView:field_];
+ EXPECT_EQ([cell mouseTrackingDecorations].size(), 2.0);
+}
+
// Verify that clicking a decoration that accepts mouse clicks does not focus
// the Omnibox.
TEST_F(AutocompleteTextFieldObserverTest,
@@ -816,6 +849,7 @@ TEST_F(AutocompleteTextFieldObserverTest,
.WillRepeatedly(testing::Return(true));
interactive_decoration.SetVisible(true);
[cell addLeftDecoration:&interactive_decoration];
+ [cell updateMouseTrackingAndToolTipsInRect:[field_ frame] ofView:field_];
EXPECT_CALL(interactive_decoration, OnMousePressed(_, _))
.WillRepeatedly(testing::Return(true));

Powered by Google App Engine
This is Rietveld 408576698