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

Side by Side Diff: chrome/browser/cocoa/autocomplete_text_field_unittest.mm

Issue 222020: [Mac] Show the page info window after clicking the security icon in the URL bar (Closed)
Patch Set: Unit tests Created 11 years, 2 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 unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698