- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / cocoa / autofill / autofill_textfield_unittest.mm
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.
4
5 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h"
6
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"
11
12 class AutofillTextFieldTest : public CocoaTest {
13  public:
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_];
20   }
21
22  protected:
23   base::scoped_nsobject<AutofillTextField> textfield_;
24
25   DISALLOW_COPY_AND_ASSIGN(AutofillTextFieldTest);
26 };
27
28 TEST_VIEW(AutofillTextFieldTest, textfield_)
29
30 // Test invalid, mostly to ensure nothing leaks or crashes.
31 TEST_F(AutofillTextFieldTest, DisplayWithInvalid) {
32   [[textfield_ cell] setInvalid:YES];
33   [textfield_ display];
34   [[textfield_ cell] setInvalid:NO];
35   [textfield_ display];
36 }
37
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];
43   [textfield_ display];
44   [[textfield_ cell] setIcon:nil];
45   [textfield_ sizeToFit];
46   [textfield_ display];
47 }