OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/cocoa/autofill/autofill_textfield.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h" |
6 | 6 |
7 #import "base/memory/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "testing/platform_test.h" | 10 #include "testing/platform_test.h" |
11 | 11 |
12 class AutofillTextFieldTest : public CocoaTest { | 12 class AutofillTextFieldTest : public CocoaTest { |
13 public: | 13 public: |
14 AutofillTextFieldTest() { | 14 AutofillTextFieldTest() { |
15 NSRect frame = NSMakeRect(0, 0, 50, 30); | 15 NSRect frame = NSMakeRect(0, 0, 50, 30); |
16 textfield_.reset([[AutofillTextField alloc] initWithFrame:frame]); | 16 textfield_.reset([[AutofillTextField alloc] initWithFrame:frame]); |
17 [textfield_ setStringValue:@"Abcdefg"]; | 17 [textfield_ setStringValue:@"Abcdefg"]; |
18 [textfield_ sizeToFit]; | 18 [textfield_ sizeToFit]; |
19 [[test_window() contentView] addSubview:textfield_]; | 19 [[test_window() contentView] addSubview:textfield_]; |
20 } | 20 } |
21 | 21 |
22 protected: | 22 protected: |
23 scoped_nsobject<AutofillTextField> textfield_; | 23 base::scoped_nsobject<AutofillTextField> textfield_; |
24 | 24 |
25 DISALLOW_COPY_AND_ASSIGN(AutofillTextFieldTest); | 25 DISALLOW_COPY_AND_ASSIGN(AutofillTextFieldTest); |
26 }; | 26 }; |
27 | 27 |
28 TEST_VIEW(AutofillTextFieldTest, textfield_) | 28 TEST_VIEW(AutofillTextFieldTest, textfield_) |
29 | 29 |
30 // Test invalid, mostly to ensure nothing leaks or crashes. | 30 // Test invalid, mostly to ensure nothing leaks or crashes. |
31 TEST_F(AutofillTextFieldTest, DisplayWithInvalid) { | 31 TEST_F(AutofillTextFieldTest, DisplayWithInvalid) { |
32 [[textfield_ cell] setInvalid:YES]; | 32 [[textfield_ cell] setInvalid:YES]; |
33 [textfield_ display]; | 33 [textfield_ display]; |
34 [[textfield_ cell] setInvalid:NO]; | 34 [[textfield_ cell] setInvalid:NO]; |
35 [textfield_ display]; | 35 [textfield_ display]; |
36 } | 36 } |
37 | 37 |
38 // Test with icon, mostly to ensure nothing leaks or crashes. | 38 // Test with icon, mostly to ensure nothing leaks or crashes. |
39 TEST_F(AutofillTextFieldTest, DisplayWithIcon) { | 39 TEST_F(AutofillTextFieldTest, DisplayWithIcon) { |
40 NSImage* image = [NSImage imageNamed:NSImageNameStatusAvailable]; | 40 NSImage* image = [NSImage imageNamed:NSImageNameStatusAvailable]; |
41 [[textfield_ cell] setIcon:image]; | 41 [[textfield_ cell] setIcon:image]; |
42 [textfield_ sizeToFit]; | 42 [textfield_ sizeToFit]; |
43 [textfield_ display]; | 43 [textfield_ display]; |
44 [[textfield_ cell] setIcon:nil]; | 44 [[textfield_ cell] setIcon:nil]; |
45 [textfield_ sizeToFit]; | 45 [textfield_ sizeToFit]; |
46 [textfield_ display]; | 46 [textfield_ display]; |
47 } | 47 } |
OLD | NEW |