| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" | 5 #import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "chrome/browser/ui/autofill/mock_autofill_dialog_controller.h" | 8 #include "chrome/browser/ui/autofill/mock_autofill_dialog_view_delegate.h" |
| 9 #import "chrome/browser/ui/cocoa/autofill/autofill_section_view.h" | 9 #import "chrome/browser/ui/cocoa/autofill/autofill_section_view.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
| 12 #import "ui/base/test/ui_cocoa_test_helper.h" | 12 #import "ui/base/test/ui_cocoa_test_helper.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class AutofillMainContainerTest : public ui::CocoaTest { | 16 class AutofillMainContainerTest : public ui::CocoaTest { |
| 17 public: | 17 public: |
| 18 virtual void SetUp() { | 18 virtual void SetUp() { |
| 19 CocoaTest::SetUp(); | 19 CocoaTest::SetUp(); |
| 20 container_.reset([[AutofillMainContainer alloc] initWithController: | 20 container_.reset([[AutofillMainContainer alloc] initWithDelegate: |
| 21 &controller_]); | 21 &delegate_]); |
| 22 [[test_window() contentView] addSubview:[container_ view]]; | 22 [[test_window() contentView] addSubview:[container_ view]]; |
| 23 } | 23 } |
| 24 | 24 |
| 25 protected: | 25 protected: |
| 26 base::scoped_nsobject<AutofillMainContainer> container_; | 26 base::scoped_nsobject<AutofillMainContainer> container_; |
| 27 testing::NiceMock<autofill::MockAutofillDialogController> controller_; | 27 testing::NiceMock<autofill::MockAutofillDialogViewDelegate> delegate_; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 } // namespace | 30 } // namespace |
| 31 | 31 |
| 32 TEST_VIEW(AutofillMainContainerTest, [container_ view]) | 32 TEST_VIEW(AutofillMainContainerTest, [container_ view]) |
| 33 | 33 |
| 34 TEST_F(AutofillMainContainerTest, SubViews) { | 34 TEST_F(AutofillMainContainerTest, SubViews) { |
| 35 bool hasButtons = false; | 35 bool hasButtons = false; |
| 36 bool hasTextView = false; | 36 bool hasTextView = false; |
| 37 bool hasDetailsContainer = false; | 37 bool hasDetailsContainer = false; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 EXPECT_TRUE(hasCheckbox); | 69 EXPECT_TRUE(hasCheckbox); |
| 70 } | 70 } |
| 71 | 71 |
| 72 TEST_F(AutofillMainContainerTest, SaveDetailsLocallyDefaultsToTrue) { | 72 TEST_F(AutofillMainContainerTest, SaveDetailsLocallyDefaultsToTrue) { |
| 73 EXPECT_TRUE([container_ saveDetailsLocally]); | 73 EXPECT_TRUE([container_ saveDetailsLocally]); |
| 74 } | 74 } |
| 75 | 75 |
| 76 TEST_F(AutofillMainContainerTest, SaveInChromeCheckboxVisibility) { | 76 TEST_F(AutofillMainContainerTest, SaveInChromeCheckboxVisibility) { |
| 77 using namespace testing; | 77 using namespace testing; |
| 78 | 78 |
| 79 // Tests that the checkbox is only visible if the controller allows it. | 79 // Tests that the checkbox is only visible if the delegate allows it. |
| 80 EXPECT_CALL(controller_, ShouldOfferToSaveInChrome()).Times(2) | 80 EXPECT_CALL(delegate_, ShouldOfferToSaveInChrome()).Times(2) |
| 81 .WillOnce(Return(false)) | 81 .WillOnce(Return(false)) |
| 82 .WillOnce(Return(true)); | 82 .WillOnce(Return(true)); |
| 83 | 83 |
| 84 NSButton* checkbox = [container_ saveInChromeCheckboxForTesting]; | 84 NSButton* checkbox = [container_ saveInChromeCheckboxForTesting]; |
| 85 ASSERT_TRUE(checkbox); | 85 ASSERT_TRUE(checkbox); |
| 86 | 86 |
| 87 EXPECT_FALSE([checkbox isHidden]); | 87 EXPECT_FALSE([checkbox isHidden]); |
| 88 [container_ modelChanged]; | 88 [container_ modelChanged]; |
| 89 EXPECT_TRUE([checkbox isHidden]); | 89 EXPECT_TRUE([checkbox isHidden]); |
| 90 [container_ modelChanged]; | 90 [container_ modelChanged]; |
| 91 EXPECT_FALSE([checkbox isHidden]); | 91 EXPECT_FALSE([checkbox isHidden]); |
| 92 } | 92 } |
| OLD | NEW |