OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ |
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 DISALLOW_COPY_AND_ASSIGN(NavigationObserver); | 58 DISALLOW_COPY_AND_ASSIGN(NavigationObserver); |
59 }; | 59 }; |
60 | 60 |
61 // Observes the save password prompt for a specified WebContents, keeps track of | 61 // Observes the save password prompt for a specified WebContents, keeps track of |
62 // whether or not it is currently shown, and allows accepting saving passwords | 62 // whether or not it is currently shown, and allows accepting saving passwords |
63 // through it. | 63 // through it. |
64 class BubbleObserver { | 64 class BubbleObserver { |
65 public: | 65 public: |
66 explicit BubbleObserver(content::WebContents* web_contents); | 66 explicit BubbleObserver(content::WebContents* web_contents); |
67 | 67 |
68 // Checks if the save prompt is being currently shown. | 68 // Checks if the save prompt is being currently available due to both manual |
69 bool IsShowingSavePrompt() const; | 69 // fallback or successful login. |
| 70 bool IsSavePromptAvailable() const; |
70 | 71 |
71 // Checks if the update prompt is being currently shown. | 72 // Checks if the update prompt is being currently available due to both manual |
72 bool IsShowingUpdatePrompt() const; | 73 // fallback or successful login. |
| 74 bool IsUpdatePromptAvailable() const; |
| 75 |
| 76 // Checks if the save prompt was shown automatically. |
| 77 // |web_contents| must be the custom one returned by |
| 78 // PasswordManagerBrowserTestBase. |
| 79 bool IsSavePromptShownAutomatically() const; |
| 80 |
| 81 // Checks if the update prompt was shown automatically. |
| 82 // |web_contents| must be the custom one returned by |
| 83 // PasswordManagerBrowserTestBase. |
| 84 bool IsUpdatePromptShownAutomatically() const; |
73 | 85 |
74 // Dismisses the prompt currently open and moves the controller to the | 86 // Dismisses the prompt currently open and moves the controller to the |
75 // inactive state. | 87 // inactive state. |
76 void Dismiss() const; | 88 void Dismiss() const; |
77 | 89 |
78 // Expecting that the prompt is shown, saves the password. Checks that the | 90 // Expecting that the prompt is available, saves the password. At the end, |
79 // prompt is no longer visible afterwards. | 91 // checks that the prompt is no longer available afterwards. |
80 void AcceptSavePrompt() const; | 92 void AcceptSavePrompt() const; |
81 | 93 |
82 // Expecting that the prompt is shown, update |form| with the password from | 94 // Expecting that the prompt is shown, update |form| with the password from |
83 // observed form. Checks that the prompt is no longer visible afterwards. | 95 // observed form. Checks that the prompt is no longer visible afterwards. |
84 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; | 96 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; |
85 | 97 |
86 // Returns once the account chooser pops up or it's already shown. | 98 // Returns once the account chooser pops up or it's already shown. |
87 // |web_contents| must be the custom one returned by | 99 // |web_contents| must be the custom one returned by |
88 // PasswordManagerBrowserTestBase. | 100 // PasswordManagerBrowserTestBase. |
89 void WaitForAccountChooser() const; | 101 void WaitForAccountChooser() const; |
90 | 102 |
91 // Returns once the UI controller is in the management state due to matching | 103 // Returns once the UI controller is in the management state due to matching |
92 // credentials autofilled. | 104 // credentials autofilled. |
93 // |web_contents| must be the custom one returned by | 105 // |web_contents| must be the custom one returned by |
94 // PasswordManagerBrowserTestBase. | 106 // PasswordManagerBrowserTestBase. |
95 void WaitForManagementState() const; | 107 void WaitForManagementState() const; |
96 | 108 |
97 // Returns once the save prompt pops up or it's already shown. | 109 // Returns once the save prompt pops up or it's already shown. |
98 // |web_contents| must be the custom one returned by | 110 // |web_contents| must be the custom one returned by |
99 // PasswordManagerBrowserTestBase. | 111 // PasswordManagerBrowserTestBase. |
100 void WaitForSavePrompt() const; | 112 void WaitForAutomaticSavePrompt() const; |
| 113 |
| 114 // Returns once the fallback for saving becomes available. |
| 115 // |web_contents| must be the custom one returned by |
| 116 // PasswordManagerBrowserTestBase. |
| 117 void WaitForFallbackForSaving() const; |
101 | 118 |
102 private: | 119 private: |
103 ManagePasswordsUIController* const passwords_ui_controller_; | 120 ManagePasswordsUIController* const passwords_ui_controller_; |
104 | 121 |
105 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); | 122 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); |
106 }; | 123 }; |
107 | 124 |
108 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { | 125 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { |
109 public: | 126 public: |
110 PasswordManagerBrowserTestBase(); | 127 PasswordManagerBrowserTestBase(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 void CheckElementValue(const std::string& element_id, | 172 void CheckElementValue(const std::string& element_id, |
156 const std::string& expected_value); | 173 const std::string& expected_value); |
157 // Same as above except the element |element_id| is in iframe |iframe_id| | 174 // Same as above except the element |element_id| is in iframe |iframe_id| |
158 void CheckElementValue(const std::string& iframe_id, | 175 void CheckElementValue(const std::string& iframe_id, |
159 const std::string& element_id, | 176 const std::string& element_id, |
160 const std::string& expected_value); | 177 const std::string& expected_value); |
161 | 178 |
162 // Synchronoulsy adds the given host to the list of valid HSTS hosts. | 179 // Synchronoulsy adds the given host to the list of valid HSTS hosts. |
163 void AddHSTSHost(const std::string& host); | 180 void AddHSTSHost(const std::string& host); |
164 | 181 |
| 182 // Checks that |password_store| stores only one credential with |username| and |
| 183 // |password|. |
| 184 void CheckThatCredentialsStored(const base::string16& username, |
| 185 const base::string16& password); |
| 186 |
165 // Accessors | 187 // Accessors |
166 // Return the first created tab with a custom ManagePasswordsUIController. | 188 // Return the first created tab with a custom ManagePasswordsUIController. |
167 content::WebContents* WebContents(); | 189 content::WebContents* WebContents(); |
168 content::RenderViewHost* RenderViewHost(); | 190 content::RenderViewHost* RenderViewHost(); |
169 content::RenderFrameHost* RenderFrameHost(); | 191 content::RenderFrameHost* RenderFrameHost(); |
170 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } | 192 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } |
171 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; } | 193 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; } |
172 | 194 |
173 private: | 195 private: |
174 net::EmbeddedTestServer https_test_server_; | 196 net::EmbeddedTestServer https_test_server_; |
175 net::MockCertVerifier mock_cert_verifier_; | 197 net::MockCertVerifier mock_cert_verifier_; |
176 // A tab with some hooks injected. | 198 // A tab with some hooks injected. |
177 content::WebContents* web_contents_; | 199 content::WebContents* web_contents_; |
178 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); | 200 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); |
179 }; | 201 }; |
180 | 202 |
181 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ | 203 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ |
OLD | NEW |