Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / autofill / autofill_details_container_unittest.mm
blob75829ac8975be80ce8946e5ca34dea0d4f317eb5
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 #import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h"
10 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/platform_test.h"
13 #import "ui/base/test/ui_cocoa_test_helper.h"
15 namespace {
17 class AutofillDetailsContainerTest : public ui::CocoaTest {
18  public:
19   AutofillDetailsContainerTest() {
20     container_.reset([[AutofillDetailsContainer alloc] initWithDelegate:
21                          &delegate_]);
22     [[test_window() contentView] addSubview:[container_ view]];
23   }
25  protected:
26   base::scoped_nsobject<AutofillDetailsContainer> container_;
27   testing::NiceMock<autofill::MockAutofillDialogViewDelegate> delegate_;
30 }  // namespace
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(_, _))
50       .Times(3)
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(_, _))
62       .Times(3)
63       .WillOnce(Return(validity))
64       .WillOnce(Return(validity))
65       .WillOnce(Return(invalid));
67   EXPECT_FALSE([container_ validate]);