| 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 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
| 8 #import "chrome/browser/cocoa/autocomplete_text_field.h" | 8 #import "chrome/browser/cocoa/autocomplete_text_field.h" |
| 9 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" | 9 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" |
| 10 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" | 10 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" |
| 11 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 #include "testing/platform_test.h" |
| 13 | 14 |
| 14 @interface AutocompleteTextFieldTestDelegate : NSObject { | 15 @interface AutocompleteTextFieldTestDelegate : NSObject { |
| 15 BOOL textShouldPaste_; | 16 BOOL textShouldPaste_; |
| 16 BOOL receivedTextShouldPaste_; | 17 BOOL receivedTextShouldPaste_; |
| 17 BOOL receivedFlagsChanged_; | 18 BOOL receivedFlagsChanged_; |
| 18 BOOL receivedControlTextDidBeginEditing_; | 19 BOOL receivedControlTextDidBeginEditing_; |
| 19 BOOL receivedControlTextShouldEndEditing_; | 20 BOOL receivedControlTextShouldEndEditing_; |
| 20 } | 21 } |
| 21 - initWithTextShouldPaste:(BOOL)flag; | 22 - initWithTextShouldPaste:(BOOL)flag; |
| 22 - (BOOL)receivedTextShouldPaste; | 23 - (BOOL)receivedTextShouldPaste; |
| 23 - (BOOL)receivedFlagsChanged; | 24 - (BOOL)receivedFlagsChanged; |
| 24 - (BOOL)receivedControlTextDidBeginEditing; | 25 - (BOOL)receivedControlTextDidBeginEditing; |
| 25 - (BOOL)receivedControlTextShouldEndEditing; | 26 - (BOOL)receivedControlTextShouldEndEditing; |
| 26 @end | 27 @end |
| 27 | 28 |
| 28 @interface AutocompleteTextFieldWindowTestDelegate : NSObject { | 29 @interface AutocompleteTextFieldWindowTestDelegate : NSObject { |
| 29 scoped_nsobject<AutocompleteTextFieldEditor> editor_; | 30 scoped_nsobject<AutocompleteTextFieldEditor> editor_; |
| 30 } | 31 } |
| 31 - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject; | 32 - (id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)anObject; |
| 32 @end | 33 @end |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 class AutocompleteTextFieldTest : public testing::Test { | 37 class AutocompleteTextFieldTest : public PlatformTest { |
| 37 public: | 38 public: |
| 38 AutocompleteTextFieldTest() { | 39 AutocompleteTextFieldTest() { |
| 39 // Make sure this is wide enough to play games with the cell | 40 // Make sure this is wide enough to play games with the cell |
| 40 // decorations. | 41 // decorations. |
| 41 NSRect frame = NSMakeRect(0, 0, 300, 30); | 42 NSRect frame = NSMakeRect(0, 0, 300, 30); |
| 42 field_.reset([[AutocompleteTextField alloc] initWithFrame:frame]); | 43 field_.reset([[AutocompleteTextField alloc] initWithFrame:frame]); |
| 43 [field_ setStringValue:@"Testing"]; | 44 [field_ setStringValue:@"Testing"]; |
| 44 [cocoa_helper_.contentView() addSubview:field_.get()]; | 45 [cocoa_helper_.contentView() addSubview:field_.get()]; |
| 45 | 46 |
| 46 window_delegate_.reset( | 47 window_delegate_.reset( |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 } | 352 } |
| 352 EXPECT_TRUE(editor_ != nil); | 353 EXPECT_TRUE(editor_ != nil); |
| 353 | 354 |
| 354 // This needs to be called every time, otherwise notifications | 355 // This needs to be called every time, otherwise notifications |
| 355 // aren't sent correctly. | 356 // aren't sent correctly. |
| 356 [editor_ setFieldEditor:YES]; | 357 [editor_ setFieldEditor:YES]; |
| 357 return editor_; | 358 return editor_; |
| 358 } | 359 } |
| 359 | 360 |
| 360 @end | 361 @end |
| OLD | NEW |