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. This can only be called | |
vasilii
2017/08/09 10:31:32
Just copy the sentence about PasswordManagerBrowse
kolos1
2017/08/09 11:37:22
Done.
| |
77 // on the custom tab. | |
78 bool IsSavePromptShownAutomatically() const; | |
79 | |
80 // Checks if the update prompt was shown automatically. This can only be | |
81 // called on the custom tab. | |
82 bool IsUpdatePromptShownAutomatically() const; | |
73 | 83 |
74 // Dismisses the prompt currently open and moves the controller to the | 84 // Dismisses the prompt currently open and moves the controller to the |
75 // inactive state. | 85 // inactive state. |
76 void Dismiss() const; | 86 void Dismiss() const; |
77 | 87 |
78 // Expecting that the prompt is shown, saves the password. Checks that the | 88 // Expecting that the prompt is available, saves the password. At the end, |
79 // prompt is no longer visible afterwards. | 89 // checks that the prompt is no longer available afterwards. |
80 void AcceptSavePrompt() const; | 90 void AcceptSavePrompt() const; |
81 | 91 |
82 // Expecting that the prompt is shown, update |form| with the password from | 92 // Expecting that the prompt is shown, update |form| with the password from |
83 // observed form. Checks that the prompt is no longer visible afterwards. | 93 // observed form. Checks that the prompt is no longer visible afterwards. |
84 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; | 94 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; |
85 | 95 |
86 // Returns once the account chooser pops up or it's already shown. | 96 // Returns once the account chooser pops up or it's already shown. |
87 // |web_contents| must be the custom one returned by | 97 // |web_contents| must be the custom one returned by |
88 // PasswordManagerBrowserTestBase. | 98 // PasswordManagerBrowserTestBase. |
89 void WaitForAccountChooser() const; | 99 void WaitForAccountChooser() const; |
90 | 100 |
91 // Returns once the UI controller is in the management state due to matching | 101 // Returns once the UI controller is in the management state due to matching |
92 // credentials autofilled. | 102 // credentials autofilled. |
93 // |web_contents| must be the custom one returned by | 103 // |web_contents| must be the custom one returned by |
94 // PasswordManagerBrowserTestBase. | 104 // PasswordManagerBrowserTestBase. |
95 void WaitForManagementState() const; | 105 void WaitForManagementState() const; |
96 | 106 |
97 // Returns once the save prompt pops up or it's already shown. | 107 // Returns once the save prompt pops up or it's already shown. |
98 // |web_contents| must be the custom one returned by | 108 // |web_contents| must be the custom one returned by |
99 // PasswordManagerBrowserTestBase. | 109 // PasswordManagerBrowserTestBase. |
100 void WaitForSavePrompt() const; | 110 void WaitForAutomaticSavePrompt() const; |
111 | |
112 // Returns once the fallback for saving becomes available. | |
113 // |web_contents| must be the custom one returned by | |
114 // PasswordManagerBrowserTestBase. | |
115 void WaitForFallbackForSaving() const; | |
101 | 116 |
102 private: | 117 private: |
103 ManagePasswordsUIController* const passwords_ui_controller_; | 118 ManagePasswordsUIController* const passwords_ui_controller_; |
104 | 119 |
105 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); | 120 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); |
106 }; | 121 }; |
107 | 122 |
108 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { | 123 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { |
109 public: | 124 public: |
110 PasswordManagerBrowserTestBase(); | 125 PasswordManagerBrowserTestBase(); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
155 void CheckElementValue(const std::string& element_id, | 170 void CheckElementValue(const std::string& element_id, |
156 const std::string& expected_value); | 171 const std::string& expected_value); |
157 // Same as above except the element |element_id| is in iframe |iframe_id| | 172 // Same as above except the element |element_id| is in iframe |iframe_id| |
158 void CheckElementValue(const std::string& iframe_id, | 173 void CheckElementValue(const std::string& iframe_id, |
159 const std::string& element_id, | 174 const std::string& element_id, |
160 const std::string& expected_value); | 175 const std::string& expected_value); |
161 | 176 |
162 // Synchronoulsy adds the given host to the list of valid HSTS hosts. | 177 // Synchronoulsy adds the given host to the list of valid HSTS hosts. |
163 void AddHSTSHost(const std::string& host); | 178 void AddHSTSHost(const std::string& host); |
164 | 179 |
180 // Checks that |password_store| stores only one credential with |username| and | |
181 // |password|. | |
182 void CheckThatCredentialsStored(const base::string16& username, | |
183 const base::string16& password); | |
184 | |
165 // Accessors | 185 // Accessors |
166 // Return the first created tab with a custom ManagePasswordsUIController. | 186 // Return the first created tab with a custom ManagePasswordsUIController. |
167 content::WebContents* WebContents(); | 187 content::WebContents* WebContents(); |
168 content::RenderViewHost* RenderViewHost(); | 188 content::RenderViewHost* RenderViewHost(); |
169 content::RenderFrameHost* RenderFrameHost(); | 189 content::RenderFrameHost* RenderFrameHost(); |
170 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } | 190 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } |
171 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; } | 191 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; } |
172 | 192 |
173 private: | 193 private: |
174 net::EmbeddedTestServer https_test_server_; | 194 net::EmbeddedTestServer https_test_server_; |
175 net::MockCertVerifier mock_cert_verifier_; | 195 net::MockCertVerifier mock_cert_verifier_; |
176 // A tab with some hooks injected. | 196 // A tab with some hooks injected. |
177 content::WebContents* web_contents_; | 197 content::WebContents* web_contents_; |
178 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); | 198 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); |
179 }; | 199 }; |
180 | 200 |
181 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ | 201 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ |
OLD | NEW |