OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_suggestion_container.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_suggestion_container.h" |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h" | 7 #import "chrome/browser/ui/cocoa/autofill/autofill_textfield.h" |
8 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" | 8 #import "chrome/browser/ui/cocoa/hyperlink_button_cell.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #import "ui/base/test/ui_cocoa_test_helper.h" | 10 #import "ui/base/test/ui_cocoa_test_helper.h" |
11 | 11 |
12 namespace { | 12 namespace { |
13 | 13 |
14 class AutofillSuggestionContainerTest : public ui::CocoaTest { | 14 class AutofillSuggestionContainerTest : public ui::CocoaTest { |
15 public: | 15 public: |
16 virtual void SetUp() { | 16 virtual void SetUp() { |
17 CocoaTest::SetUp(); | 17 CocoaTest::SetUp(); |
18 container_.reset([[AutofillSuggestionContainer alloc] init]); | 18 container_.reset([[AutofillSuggestionContainer alloc] init]); |
19 [[test_window() contentView] addSubview:[container_ view]]; | 19 [[test_window() contentView] addSubview:[container_ view]]; |
20 } | 20 } |
21 | 21 |
22 protected: | 22 protected: |
23 scoped_nsobject<AutofillSuggestionContainer> container_; | 23 base::scoped_nsobject<AutofillSuggestionContainer> container_; |
24 }; | 24 }; |
25 | 25 |
26 } // namespace | 26 } // namespace |
27 | 27 |
28 TEST_VIEW(AutofillSuggestionContainerTest, [container_ view]) | 28 TEST_VIEW(AutofillSuggestionContainerTest, [container_ view]) |
29 | 29 |
30 TEST_F(AutofillSuggestionContainerTest, HasSubviews) { | 30 TEST_F(AutofillSuggestionContainerTest, HasSubviews) { |
31 ASSERT_EQ(4U, [[[container_ view] subviews] count]); | 31 ASSERT_EQ(4U, [[[container_ view] subviews] count]); |
32 | 32 |
33 int num_text_fields = 0; | 33 int num_text_fields = 0; |
34 bool has_edit_field = false; | 34 bool has_edit_field = false; |
35 bool has_icon = false; | 35 bool has_icon = false; |
36 | 36 |
37 for (id view in [[container_ view] subviews]) { | 37 for (id view in [[container_ view] subviews]) { |
38 if ([view isKindOfClass:[NSImageView class]]) { | 38 if ([view isKindOfClass:[NSImageView class]]) { |
39 has_icon = true; | 39 has_icon = true; |
40 } else if ([view isKindOfClass:[AutofillTextField class]]) { | 40 } else if ([view isKindOfClass:[AutofillTextField class]]) { |
41 has_edit_field = true; | 41 has_edit_field = true; |
42 } else if ([view isKindOfClass:[NSTextField class]]) { | 42 } else if ([view isKindOfClass:[NSTextField class]]) { |
43 num_text_fields++; | 43 num_text_fields++; |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
47 EXPECT_EQ(2, num_text_fields); | 47 EXPECT_EQ(2, num_text_fields); |
48 EXPECT_TRUE(has_edit_field); | 48 EXPECT_TRUE(has_edit_field); |
49 EXPECT_TRUE(has_icon); | 49 EXPECT_TRUE(has_icon); |
50 } | 50 } |
OLD | NEW |