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