| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_UI_COCOA_PASSWORDS_BASE_PASSWORDS_CONTROLLER_TEST_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_PASSWORDS_BASE_PASSWORDS_CONTROLLER_TEST_H_ |
| 6 #define CHROME_BROWSER_UI_COCOA_PASSWORDS_BASE_PASSWORDS_CONTROLLER_TEST_H_ | 6 #define CHROME_BROWSER_UI_COCOA_PASSWORDS_BASE_PASSWORDS_CONTROLLER_TEST_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 9 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 11 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 10 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 12 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 11 #import "chrome/browser/ui/cocoa/passwords/base_passwords_content_view_controlle
r.h" | 13 #import "chrome/browser/ui/cocoa/passwords/base_passwords_content_view_controlle
r.h" |
| 12 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" | 14 #include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
| 15 #include "chrome/browser/ui/passwords/passwords_model_delegate_mock.h" |
| 13 | 16 |
| 14 namespace content { | 17 namespace content { |
| 15 class WebContents; | 18 class WebContents; |
| 16 } // namespace content | 19 } // namespace content |
| 17 | 20 class PasswordsModelDelegateMock; |
| 18 class ManagePasswordsUIControllerMock; | |
| 19 class ManagePasswordsBubbleModel; | |
| 20 | 21 |
| 21 // Helper delegate for testing the views of the password management bubble. | 22 // Helper delegate for testing the views of the password management bubble. |
| 22 @interface ContentViewDelegateMock : NSObject<BasePasswordsContentViewDelegate> | 23 @interface ContentViewDelegateMock : NSObject<BasePasswordsContentViewDelegate> |
| 23 @property(nonatomic) ManagePasswordsBubbleModel* model; | 24 @property(nonatomic) ManagePasswordsBubbleModel* model; |
| 24 @property(readonly, nonatomic) BOOL dismissed; | 25 @property(readonly, nonatomic) BOOL dismissed; |
| 25 @end | 26 @end |
| 26 | 27 |
| 27 class ManagePasswordsControllerTest : public CocoaProfileTest { | 28 class ManagePasswordsControllerTest : public CocoaProfileTest { |
| 28 public: | 29 public: |
| 29 using VectorConstFormPtr = std::vector<const autofill::PasswordForm*>; | 30 using VectorConstFormPtr = std::vector<const autofill::PasswordForm*>; |
| 30 | 31 |
| 31 ManagePasswordsControllerTest(); | 32 ManagePasswordsControllerTest(); |
| 32 ~ManagePasswordsControllerTest() override; | 33 ~ManagePasswordsControllerTest() override; |
| 33 void SetUp() override; | 34 void SetUp() override; |
| 34 | 35 |
| 35 ManagePasswordsUIControllerMock* ui_controller() { return ui_controller_; } | 36 PasswordsModelDelegateMock* ui_controller() { |
| 37 return ui_controller_.get(); |
| 38 } |
| 36 ContentViewDelegateMock* delegate() { return delegate_.get(); } | 39 ContentViewDelegateMock* delegate() { return delegate_.get(); } |
| 37 ManagePasswordsBubbleModel* GetModelAndCreateIfNull(); | 40 ManagePasswordsBubbleModel* GetModelAndCreateIfNull(); |
| 38 | 41 |
| 39 // Sets the appropriate state for ManagePasswordsBubbleModel. | 42 // Sets the appropriate state for ManagePasswordsBubbleModel. |
| 40 void SetUpSavePendingState(bool empty_username); | 43 void SetUpSavePendingState(bool empty_username); |
| 41 void SetUpUpdatePendingState(bool multiple_forms); | 44 void SetUpUpdatePendingState(bool multiple_forms); |
| 42 void SetUpConfirmationState(); | 45 void SetUpConfirmationState(); |
| 43 void SetUpManageState(const VectorConstFormPtr& forms); | 46 void SetUpManageState(const VectorConstFormPtr& forms); |
| 44 | 47 |
| 45 // An opportunity for tests to override the constructor parameter of | 48 // An opportunity for tests to override the constructor parameter of |
| 46 // ManagePasswordsBubbleModel. | 49 // ManagePasswordsBubbleModel. |
| 47 virtual ManagePasswordsBubbleModel::DisplayReason GetDisplayReason() const; | 50 virtual ManagePasswordsBubbleModel::DisplayReason GetDisplayReason() const; |
| 48 | 51 |
| 49 private: | 52 private: |
| 50 ManagePasswordsUIControllerMock* ui_controller_; | 53 std::unique_ptr<PasswordsModelDelegateMock> ui_controller_; |
| 51 std::unique_ptr<content::WebContents> test_web_contents_; | 54 std::unique_ptr<content::WebContents> test_web_contents_; |
| 52 std::unique_ptr<ManagePasswordsBubbleModel> model_; | 55 std::unique_ptr<ManagePasswordsBubbleModel> model_; |
| 53 base::scoped_nsobject<ContentViewDelegateMock> delegate_; | 56 base::scoped_nsobject<ContentViewDelegateMock> delegate_; |
| 54 | 57 |
| 55 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsControllerTest); | 58 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsControllerTest); |
| 56 }; | 59 }; |
| 57 | 60 |
| 58 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_BASE_PASSWORDS_CONTROLLER_TEST_H_ | 61 #endif // CHROME_BROWSER_UI_COCOA_PASSWORDS_BASE_PASSWORDS_CONTROLLER_TEST_H_ |
| OLD | NEW |