1 // Copyright (c) 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_details_container.h"
7 #include "base/mac/scoped_nsobject.h"
8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h"
10 #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/platform_test.h"
13 #import "ui/gfx/test/ui_cocoa_test_helper.h"
17 class AutofillDetailsContainerTest : public ui::CocoaTest {
19 AutofillDetailsContainerTest() {
20 container_.reset([[AutofillDetailsContainer alloc] initWithDelegate:
22 [[test_window() contentView] addSubview:[container_ view]];
26 base::scoped_nsobject<AutofillDetailsContainer> container_;
27 testing::NiceMock<autofill::MockAutofillDialogViewDelegate> delegate_;
32 TEST_VIEW(AutofillDetailsContainerTest, [container_ view])
34 TEST_F(AutofillDetailsContainerTest, BasicProperties) {
35 EXPECT_TRUE([[container_ view] isKindOfClass:[NSScrollView class]]);
36 EXPECT_GT([[[container_ view] subviews] count], 0U);
38 [[container_ view] setFrameSize:[container_ preferredSize]];
39 EXPECT_GT(NSHeight([[container_ view] frame]), 0);
40 EXPECT_GT(NSWidth([[container_ view] frame]), 0);
43 TEST_F(AutofillDetailsContainerTest, ValidateAllSections) {
44 using namespace autofill;
45 using namespace testing;
47 ValidityMessages validity;
49 EXPECT_CALL(delegate_, InputsAreValid(_, _))
51 .WillOnce(Return(validity))
52 .WillOnce(Return(validity))
53 .WillOnce(Return(validity));
55 EXPECT_TRUE([container_ validate]);
57 ValidityMessages invalid;
58 invalid.Set(ADDRESS_HOME_ZIP,
59 ValidityMessage(base::ASCIIToUTF16("Some error message"), false));
61 EXPECT_CALL(delegate_, InputsAreValid(_, _))
63 .WillOnce(Return(validity))
64 .WillOnce(Return(validity))
65 .WillOnce(Return(invalid));
67 EXPECT_FALSE([container_ validate]);