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_TEST_H_
6 #define CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_TEST_H_
8 #include "base/metrics/histogram_samples.h"
9 #include "base/test/histogram_tester.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "components/autofill/core/common/password_form.h"
12 #include "components/password_manager/core/common/credential_manager_types.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 class ManagePasswordsUIController
;
17 class ManagePasswordsIcon
;
20 // Test class for the various password management view bits and pieces. Sets
21 // up a ManagePasswordsUIControllerMock, and provides some helper methods
22 // to poke at the bubble, icon, and controller's state.
23 class ManagePasswordsTest
: public InProcessBrowserTest
{
25 ManagePasswordsTest();
26 ~ManagePasswordsTest();
28 // InProcessBrowserTest:
29 void SetUpOnMainThread() override
;
31 // Get the icon view for the current WebContents.
32 virtual ManagePasswordsIcon
* view() = 0;
34 // Execute the browser command to open the manage passwords bubble.
35 void ExecuteManagePasswordsCommand();
37 // Put the controller, icon, and bubble into a managing-password state.
38 void SetupManagingPasswords();
40 // Put the controller, icon, and bubble into the confirmation state.
41 void SetupAutomaticPassword();
43 // Put the controller, icon, and bubble into a pending-password state.
44 void SetupPendingPassword();
46 // Put the controller, icon, and bubble into a blacklisted state.
47 void SetupBlackistedPassword();
49 // Put the controller, icon, and bubble into a choosing credential state.
50 void SetupChooseCredentials(
51 ScopedVector
<autofill::PasswordForm
> local_credentials
,
52 ScopedVector
<autofill::PasswordForm
> federated_credentials
,
55 // Put the controller, icon, and bubble into an auto sign-in state.
57 ScopedVector
<autofill::PasswordForm
> local_credentials
);
59 // Get samples for |histogram|.
60 base::HistogramSamples
* GetSamples(const char* histogram
);
62 autofill::PasswordForm
* test_form() { return &test_form_
; }
64 // Get the UI controller for the current WebContents.
65 ManagePasswordsUIController
* GetController();
67 MOCK_METHOD1(OnChooseCredential
,
68 void(const password_manager::CredentialInfo
&));
71 autofill::PasswordForm test_form_
;
72 base::HistogramTester histogram_tester_
;
74 DISALLOW_COPY_AND_ASSIGN(ManagePasswordsTest
);
77 #endif // CHROME_BROWSER_UI_PASSWORDS_MANAGE_PASSWORDS_TEST_H_