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