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

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

Issue 1011943002: Mac: Clicking an omnibox decoration should not highlight the omnibox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit test. Created 5 years, 7 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/ui/cocoa/location_bar/autocomplete_text_field.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6d138011b2687a550b13f28c65cb701d7d1a5b86..c094189b582c4f4d847fbca85512655af44f9395 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
@@ -789,10 +789,7 @@ TEST_F(AutocompleteTextFieldTest, HideFocusState) {
EXPECT_TRUE([FieldEditor() shouldDrawInsertionPoint]);
}
-// Verify that OnSetFocus for button decorations is only sent after the
-// decoration is picked as the target for the subsequent -mouseDown:. Otherwise
-// hiding a ButtonDecoration in OnSetFocus will prevent a call to
-// OnMousePressed, since it is already hidden at the time of mouseDown.
+// Verify that clicking on a button decoration does not focus the omnibox.
TEST_F(AutocompleteTextFieldObserverTest, ButtonDecorationFocus) {
erikchen 2015/05/07 19:33:51 This test was written for Omnitheatre, and is no l
Scott Hess - ex-Googler 2015/05/07 20:07:42 Would it make sense to further revise this to not
erikchen 2015/05/08 01:51:46 Good suggestion. I updated the test, and discovere
// Add the mock button.
MockButtonDecoration mock_button;
@@ -800,16 +797,12 @@ TEST_F(AutocompleteTextFieldObserverTest, ButtonDecorationFocus) {
AutocompleteTextFieldCell* cell = [field_ cell];
[cell addLeftDecoration:&mock_button];
- // Ensure button is hidden when OnSetFocus() is called.
- EXPECT_CALL(field_observer_, OnSetFocus(false)).WillOnce(
- testing::InvokeWithoutArgs(&mock_button, &MockButtonDecoration::Hide));
-
// Ignore incidental calls.
EXPECT_CALL(field_observer_, SelectionRangeForProposedRange(_))
.WillRepeatedly(testing::Return(NSMakeRange(0, 0)));
EXPECT_CALL(field_observer_, OnMouseDown(_));
- // Still expect an OnMousePressed on the button.
+ // Expect an OnMousePressed on the button.
EXPECT_CALL(mock_button, OnMousePressed(_, _))
.WillOnce(testing::Return(true));
@@ -822,7 +815,8 @@ TEST_F(AutocompleteTextFieldObserverTest, ButtonDecorationFocus) {
// Ensure the field is currently not first responder.
[test_window() makePretendKeyWindowAndSetFirstResponder:nil];
- EXPECT_NSNE([[field_ window] firstResponder], field_);
+ EXPECT_FALSE([base::mac::ObjCCast<NSView>(
+ [[field_ window] firstResponder]) isDescendantOf:field_]);
Scott Hess - ex-Googler 2015/05/07 20:07:42 At this point is there any first responder at all
erikchen 2015/05/08 01:51:46 The first responder is CocoaTestHelperWindow. I'd
// Execute button click event sequence.
NSEvent* downEvent = Event(field_, click_location, NSLeftMouseDown);
@@ -837,12 +831,12 @@ TEST_F(AutocompleteTextFieldObserverTest, ButtonDecorationFocus) {
dequeue:YES];
[NSApp sendEvent:next_event];
- // Expectations check that both OnSetFocus and OnMouseDown were called.
- // Additionally, ensure button is hidden and field is firstResponder.
- EXPECT_FALSE(mock_button.IsVisible());
- EXPECT_TRUE(NSIsEmptyRect([cell frameForDecoration:&mock_left_decoration_
+ // Expectations check that OnMouseDown was called. Additionally, ensure
+ // button is visible and field is not firstResponder.
+ EXPECT_TRUE(mock_button.IsVisible());
+ EXPECT_FALSE(NSIsEmptyRect([cell frameForDecoration:&mock_button
inFrame:[field_ bounds]]));
Scott Hess - ex-Googler 2015/05/07 20:07:42 Alignment.
erikchen 2015/05/08 01:51:46 I clang-format-ed the entire CL.
Scott Hess - ex-Googler 2015/05/08 19:38:28 And the offending code is no longer present anyhow
erikchen 2015/05/08 20:02:20 The previous code was not. I should have been more
- EXPECT_TRUE([base::mac::ObjCCastStrict<NSView>(
+ EXPECT_FALSE([base::mac::ObjCCast<NSView>(
[[field_ window] firstResponder]) isDescendantOf:field_]);
Scott Hess - ex-Googler 2015/05/07 20:07:42 Here also.
erikchen 2015/05/08 01:51:46 ditto.
}
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698