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