| OLD | NEW |
| (Empty) |
| 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_notification_container.h" | |
| 6 | |
| 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" | |
| 13 | |
| 14 namespace { | |
| 15 | |
| 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 } | |
| 24 | |
| 25 protected: | |
| 26 base::scoped_nsobject<AutofillNotificationContainer> container_; | |
| 27 testing::NiceMock<autofill::MockAutofillDialogViewDelegate> delegate_; | |
| 28 }; | |
| 29 | |
| 30 } // namespace | |
| 31 | |
| 32 TEST_VIEW(AutofillNotificationContainerTest, [container_ view]) | |
| 33 | |
| 34 TEST_F(AutofillNotificationContainerTest, Subviews) { | |
| 35 // No subviews if there are no notifications. | |
| 36 EXPECT_EQ(0U, [[[container_ view] subviews] count]); | |
| 37 | |
| 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]; | |
| 46 | |
| 47 EXPECT_EQ(1U, [[[container_ view] subviews] count]); | |
| 48 | |
| 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]; | |
| 56 | |
| 57 EXPECT_EQ(2U, [[[container_ view] subviews] count]); | |
| 58 | |
| 59 // Just to exercise code path. | |
| 60 [container_ performLayout]; | |
| 61 } | |
| OLD | NEW |