Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / autofill / autofill_notification_container_unittest.mm
blobb5c62ceaeba9dc4580349f2b07b66e7f6ba80e06
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"
14 namespace {
16 class AutofillNotificationContainerTest : public ui::CocoaTest {
17  public:
18   virtual void SetUp() {
19     CocoaTest::SetUp();
20     container_.reset([[AutofillNotificationContainer alloc] initWithDelegate:
21                          &delegate_]);
22     [[test_window() contentView] addSubview:[container_ view]];
23   }
25  protected:
26   base::scoped_nsobject<AutofillNotificationContainer> container_;
27   testing::NiceMock<autofill::MockAutofillDialogViewDelegate> delegate_;
30 }  // namespace
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];