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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_
8 #include "base/basictypes.h"
9 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
10 #include "components/password_manager/core/common/password_manager_ui.h"
11 #include "content/public/browser/navigation_details.h"
15 } // namespace content
17 // This mock is used in tests to ensure that we're just testing the controller
18 // behavior, and not the behavior of the bits and pieces it relies upon (like
20 class ManagePasswordsUIControllerMock
21 : public ManagePasswordsUIController
{
23 explicit ManagePasswordsUIControllerMock(
24 content::WebContents
* contents
);
25 virtual ~ManagePasswordsUIControllerMock();
27 // Navigation, surprisingly, is platform-specific; Android's settings page
28 // is native UI and therefore isn't available in a tab for unit tests.
30 // TODO(mkwst): Determine how to reasonably test this on that platform.
31 virtual void NavigateToPasswordManagerSettingsPage() OVERRIDE
;
32 bool navigated_to_settings_page() const {
33 return navigated_to_settings_page_
;
36 virtual void NavigateToAccountCentralManagementPage() OVERRIDE
;
37 bool navigated_to_account_central_management_page() const {
38 return navigated_to_account_central_management_page_
;
41 // We don't have a FormManager in tests, so stub these out.
42 virtual void SavePasswordInternal() OVERRIDE
;
43 bool saved_password() const { return saved_password_
; }
45 virtual void NeverSavePasswordInternal() OVERRIDE
;
46 bool never_saved_password() const { return never_saved_password_
; }
48 virtual const autofill::PasswordForm
& PendingCredentials() const OVERRIDE
;
49 void SetPendingCredentials(autofill::PasswordForm pending_credentials
);
51 // Sneaky setters for testing.
52 void SetPasswordFormMap(const autofill::ConstPasswordFormMap
& map
) {
53 password_form_map_
= map
;
55 void SetState(password_manager::ui::State state
) { state_
= state
; }
57 void SetTimer(base::ElapsedTimer
* timer
) { timer_
.reset(timer
); }
59 // True if this controller is installed on |web_contents()|.
60 bool IsInstalled() const;
62 using ManagePasswordsUIController::DidNavigateMainFrame
;
65 bool navigated_to_settings_page_
;
66 bool navigated_to_account_central_management_page_
;
68 bool never_saved_password_
;
70 autofill::PasswordForm pending_credentials_
;
72 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIControllerMock
);
75 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_