Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / passwords / manage_passwords_ui_controller_mock.h
bloba112de1b70ab34c6a9a7cc9e01475da63038bbca
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/browser/stub_password_manager_client.h"
11 #include "components/password_manager/core/common/password_manager_ui.h"
12 #include "content/public/browser/navigation_details.h"
14 namespace content {
15 class WebContents;
16 } // namespace content
18 namespace password_manager {
19 enum class CredentialType;
22 // This mock is used in tests to ensure that we're just testing the controller
23 // behavior, and not the behavior of the bits and pieces it relies upon (like
24 // FormManager).
25 class ManagePasswordsUIControllerMock
26 : public ManagePasswordsUIController {
27 public:
28 explicit ManagePasswordsUIControllerMock(
29 content::WebContents* contents);
30 ~ManagePasswordsUIControllerMock() override;
32 // Navigation, surprisingly, is platform-specific; Android's settings page
33 // is native UI and therefore isn't available in a tab for unit tests.
35 // TODO(mkwst): Determine how to reasonably test this on that platform.
36 void NavigateToPasswordManagerSettingsPage() override;
37 bool navigated_to_settings_page() const {
38 return navigated_to_settings_page_;
41 // We don't have a FormManager in tests, so stub these out.
42 void SavePassword() override;
43 bool saved_password() const { return saved_password_; }
45 void UpdatePassword(const autofill::PasswordForm& password_form) override;
46 bool updated_password() const { return updated_password_; }
48 void NeverSavePassword() override;
49 bool never_saved_password() const { return never_saved_password_; }
51 void ChooseCredential(const autofill::PasswordForm& form,
52 password_manager::CredentialType form_type) override;
53 bool choose_credential() const { return choose_credential_; }
54 autofill::PasswordForm chosen_credential() { return chosen_credential_; }
56 const autofill::PasswordForm& PendingPassword() const override;
57 void SetPendingPassword(autofill::PasswordForm pending_password);
59 void ManageAccounts() override;
60 bool manage_accounts() const { return manage_accounts_; }
62 void UpdateBubbleAndIconVisibility() override;
64 void UpdateAndroidAccountChooserInfoBarVisibility() override;
66 // Simulate the pending password state. |best_matches| can't be empty.
67 void PretendSubmittedPassword(
68 ScopedVector<autofill::PasswordForm> best_matches);
70 static scoped_ptr<password_manager::PasswordFormManager> CreateFormManager(
71 password_manager::PasswordManagerClient* client,
72 const autofill::PasswordForm& observed_form,
73 ScopedVector<autofill::PasswordForm> best_matches);
75 private:
76 bool navigated_to_settings_page_;
77 bool saved_password_;
78 bool updated_password_;
79 bool never_saved_password_;
80 bool choose_credential_;
81 bool manage_accounts_;
82 base::TimeDelta elapsed_;
84 autofill::PasswordForm chosen_credential_;
85 autofill::PasswordForm pending_password_;
87 password_manager::StubPasswordManagerClient client_;
89 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsUIControllerMock);
92 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_UI_CONTROLLER_MOCK_H_