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
3 // found in the LICENSE file.
5 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h"
7 #import "base/mac/scoped_nsobject.h"
8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "testing/platform_test.h"
12 class AutofillTextFieldTest : public CocoaTest {
14 AutofillTextFieldTest() {
15 NSRect frame = NSMakeRect(0, 0, 50, 30);
16 textfield_.reset([[AutofillTextField alloc] initWithFrame:frame]);
17 [textfield_ setStringValue:@"Abcdefg"];
18 [textfield_ sizeToFit];
19 [[test_window() contentView] addSubview:textfield_];
23 base::scoped_nsobject<AutofillTextField> textfield_;
25 DISALLOW_COPY_AND_ASSIGN(AutofillTextFieldTest);
28 TEST_VIEW(AutofillTextFieldTest, textfield_)
30 // Test invalid, mostly to ensure nothing leaks or crashes.
31 TEST_F(AutofillTextFieldTest, DisplayWithInvalid) {
32 [[textfield_ cell] setInvalid:YES];
34 [[textfield_ cell] setInvalid:NO];
38 // Test with icon, mostly to ensure nothing leaks or crashes.
39 TEST_F(AutofillTextFieldTest, DisplayWithIcon) {
40 NSImage* image = [NSImage imageNamed:NSImageNameStatusAvailable];
41 [[textfield_ cell] setIcon:image];
42 [textfield_ sizeToFit];
44 [[textfield_ cell] setIcon:nil];
45 [textfield_ sizeToFit];