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.
5 #import "chrome/browser/ui/cocoa/autofill/autofill_notification_container.h"
7 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h"
10 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #import "ui/gfx/test/ui_cocoa_test_helper.h"
16 class AutofillNotificationContainerTest : public ui::CocoaTest {
18 virtual void SetUp() {
20 container_.reset([[AutofillNotificationContainer alloc] initWithDelegate:
22 [[test_window() contentView] addSubview:[container_ view]];
26 base::scoped_nsobject<AutofillNotificationContainer> container_;
27 testing::NiceMock<autofill::MockAutofillDialogViewDelegate> delegate_;
32 TEST_VIEW(AutofillNotificationContainerTest, [container_ view])
34 TEST_F(AutofillNotificationContainerTest, Subviews) {
35 // No subviews if there are no notifications.
36 EXPECT_EQ(0U, [[[container_ view] subviews] count]);
38 // Single notification adds one subview.
39 std::vector<autofill::DialogNotification> notifications;
40 notifications.push_back(
41 autofill::DialogNotification(
42 autofill::DialogNotification::REQUIRED_ACTION,
43 base::ASCIIToUTF16("test")));
44 ASSERT_FALSE(notifications[0].HasArrow());
45 [container_ setNotifications:notifications];
47 EXPECT_EQ(1U, [[[container_ view] subviews] count]);
49 // 2 notifications, one with arrow - 2 views.
50 notifications.push_back(
51 autofill::DialogNotification(
52 autofill::DialogNotification::REQUIRED_ACTION,
53 base::ASCIIToUTF16("test")));
54 ASSERT_FALSE(notifications[1].HasArrow());
55 [container_ setNotifications:notifications];
57 EXPECT_EQ(2U, [[[container_ view] subviews] count]);
59 // Just to exercise code path.
60 [container_ performLayout];