Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import "base/cocoa_protocols_mac.h" | 7 #import "base/cocoa_protocols_mac.h" |
| 8 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
| 9 #import "chrome/browser/cocoa/autocomplete_text_field.h" | 9 #import "chrome/browser/cocoa/autocomplete_text_field.h" |
| 10 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" | 10 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 [NSApp postEvent:upEvent3 atStart:YES]; | 510 [NSApp postEvent:upEvent3 atStart:YES]; |
| 511 [field_ mouseDown:downEvent3]; | 511 [field_ mouseDown:downEvent3]; |
| 512 EXPECT_TRUE([field_ currentEditor]); | 512 EXPECT_TRUE([field_ currentEditor]); |
| 513 | 513 |
| 514 // Selected the first word. | 514 // Selected the first word. |
| 515 const NSRange selectedRange([[field_ currentEditor] selectedRange]); | 515 const NSRange selectedRange([[field_ currentEditor] selectedRange]); |
| 516 EXPECT_EQ(selectedRange.location, 0U); | 516 EXPECT_EQ(selectedRange.location, 0U); |
| 517 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); | 517 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); |
| 518 } | 518 } |
| 519 | 519 |
| 520 TEST_F(AutocompleteTextFieldTest, SecurityIconMouseDown) { | |
| 521 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | |
| 522 scoped_nsobject<NSImage> hintIcon( | |
| 523 [[NSImage alloc] initWithSize:NSMakeSize(20, 20)]); | |
| 524 [cell setHintIcon:hintIcon.get()]; | |
| 525 NSRect iconFrame([cell hintImageFrameForFrame:[field_ bounds]]); | |
| 526 NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame))); | |
| 527 NSEvent* event(Event(field_, location, NSLeftMouseDown, 1)); | |
| 528 EXPECT_CALL(field_observer_, OnSecurityIconClicked()); | |
| 529 [field_ mouseDown:event]; | |
|
Scott Hess - ex-Googler
2009/10/06 20:30:54
So Awesome.
| |
| 530 } | |
| 531 | |
| 520 } // namespace | 532 } // namespace |
| 521 | 533 |
| 522 @implementation AutocompleteTextFieldTestDelegate | 534 @implementation AutocompleteTextFieldTestDelegate |
| 523 | 535 |
| 524 - init { | 536 - init { |
| 525 self = [super init]; | 537 self = [super init]; |
| 526 if (self) { | 538 if (self) { |
| 527 receivedControlTextDidBeginEditing_ = NO; | 539 receivedControlTextDidBeginEditing_ = NO; |
| 528 receivedControlTextShouldEndEditing_ = NO; | 540 receivedControlTextShouldEndEditing_ = NO; |
| 529 } | 541 } |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 541 - (void)controlTextDidBeginEditing:(NSNotification*)aNotification { | 553 - (void)controlTextDidBeginEditing:(NSNotification*)aNotification { |
| 542 receivedControlTextDidBeginEditing_ = YES; | 554 receivedControlTextDidBeginEditing_ = YES; |
| 543 } | 555 } |
| 544 | 556 |
| 545 - (BOOL)control:(NSControl*)control textShouldEndEditing:(NSText*)fieldEditor { | 557 - (BOOL)control:(NSControl*)control textShouldEndEditing:(NSText*)fieldEditor { |
| 546 receivedControlTextShouldEndEditing_ = YES; | 558 receivedControlTextShouldEndEditing_ = YES; |
| 547 return YES; | 559 return YES; |
| 548 } | 560 } |
| 549 | 561 |
| 550 @end | 562 @end |
| OLD | NEW |