Chromium Code Reviews| 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" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
| 13 #include "components/password_manager/core/browser/password_store_consumer.h" | 13 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | 14 #include "content/public/browser/web_contents_observer.h" |
| 15 #include "net/cert/mock_cert_verifier.h" | 15 #include "net/cert/mock_cert_verifier.h" |
| 16 #include "net/test/embedded_test_server/embedded_test_server.h" | 16 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 17 | 17 |
| 18 namespace autofill { | 18 namespace autofill { |
| 19 struct PasswordForm; | 19 struct PasswordForm; |
| 20 } | 20 } |
| 21 namespace password_manager { | |
| 22 class TestPasswordStore; | |
| 23 } | |
| 21 | 24 |
| 22 class ManagePasswordsUIController; | 25 class ManagePasswordsUIController; |
| 23 | 26 |
| 24 class NavigationObserver : public content::WebContentsObserver { | 27 class NavigationObserver : public content::WebContentsObserver { |
| 25 public: | 28 public: |
| 26 explicit NavigationObserver(content::WebContents* web_contents); | 29 explicit NavigationObserver(content::WebContents* web_contents); |
| 27 ~NavigationObserver() override; | 30 ~NavigationObserver() override; |
| 28 | 31 |
| 29 // Normally Wait() will not return until a main frame navigation occurs. | 32 // Normally Wait() will not return until a main frame navigation occurs. |
| 30 // If a path is set, Wait() will return after this path has been seen, | 33 // If a path is set, Wait() will return after this path has been seen, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 58 DISALLOW_COPY_AND_ASSIGN(NavigationObserver); | 61 DISALLOW_COPY_AND_ASSIGN(NavigationObserver); |
| 59 }; | 62 }; |
| 60 | 63 |
| 61 // Observes the save password prompt for a specified WebContents, keeps track of | 64 // 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 | 65 // whether or not it is currently shown, and allows accepting saving passwords |
| 63 // through it. | 66 // through it. |
| 64 class BubbleObserver { | 67 class BubbleObserver { |
| 65 public: | 68 public: |
| 66 explicit BubbleObserver(content::WebContents* web_contents); | 69 explicit BubbleObserver(content::WebContents* web_contents); |
| 67 | 70 |
| 68 // Checks if the save prompt is being currently shown. | 71 // Checks if the save prompt is being currently available. |
| 69 bool IsShowingSavePrompt() const; | 72 bool IsSavePromptAvailable() const; |
| 70 | 73 |
| 71 // Checks if the update prompt is being currently shown. | 74 // Checks if the update prompt is being currently available. |
| 72 bool IsShowingUpdatePrompt() const; | 75 bool IsUpdatePromptAvailable() const; |
| 76 | |
| 77 // Checks if the save prompt was shown. | |
| 78 bool WasSavePromptShown() const; | |
| 79 | |
| 80 // Checks if the update prompt was shown. | |
| 81 bool WasUpdatePromptShown() const; | |
| 73 | 82 |
| 74 // Dismisses the prompt currently open and moves the controller to the | 83 // Dismisses the prompt currently open and moves the controller to the |
| 75 // inactive state. | 84 // inactive state. |
| 76 void Dismiss() const; | 85 void Dismiss() const; |
| 77 | 86 |
| 78 // Expecting that the prompt is shown, saves the password. Checks that the | 87 // Expecting that the prompt is shown, saves the password. Checks that the |
| 79 // prompt is no longer visible afterwards. | 88 // prompt is no longer available. |
| 80 void AcceptSavePrompt() const; | 89 void AcceptSavePrompt() const; |
| 81 | 90 |
| 91 // Expecting that the prompt is available, opens the prompt and saves the | |
| 92 // password. Checks that the prompt is no longer available. | |
| 93 void OpenAndAcceptSavePrompt() const; | |
| 94 | |
| 82 // Expecting that the prompt is shown, update |form| with the password from | 95 // Expecting that the prompt is shown, update |form| with the password from |
| 83 // observed form. Checks that the prompt is no longer visible afterwards. | 96 // observed form. Checks that the prompt is no longer visible afterwards. |
| 84 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; | 97 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; |
| 85 | 98 |
| 86 // Returns once the account chooser pops up or it's already shown. | 99 // Returns once the account chooser pops up or it's already shown. |
| 87 // |web_contents| must be the custom one returned by | 100 // |web_contents| must be the custom one returned by |
| 88 // PasswordManagerBrowserTestBase. | 101 // PasswordManagerBrowserTestBase. |
| 89 void WaitForAccountChooser() const; | 102 void WaitForAccountChooser() const; |
| 90 | 103 |
| 91 // Returns once the UI controller is in the management state due to matching | 104 // Returns once the UI controller is in the management state due to matching |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 void CheckElementValue(const std::string& element_id, | 168 void CheckElementValue(const std::string& element_id, |
| 156 const std::string& expected_value); | 169 const std::string& expected_value); |
| 157 // Same as above except the element |element_id| is in iframe |iframe_id| | 170 // Same as above except the element |element_id| is in iframe |iframe_id| |
| 158 void CheckElementValue(const std::string& iframe_id, | 171 void CheckElementValue(const std::string& iframe_id, |
| 159 const std::string& element_id, | 172 const std::string& element_id, |
| 160 const std::string& expected_value); | 173 const std::string& expected_value); |
| 161 | 174 |
| 162 // Synchronoulsy adds the given host to the list of valid HSTS hosts. | 175 // Synchronoulsy adds the given host to the list of valid HSTS hosts. |
| 163 void AddHSTSHost(const std::string& host); | 176 void AddHSTSHost(const std::string& host); |
| 164 | 177 |
| 178 // Checks that new credential is stored. For simplicity we assume that | |
| 179 // password store contains only 1 credential. | |
|
vasilii
2017/08/02 17:41:11
I don't get from the comment if the method check t
kolos1
2017/08/03 07:58:01
Changed the comment.
| |
| 180 void CheckThatCredentialsStored( | |
| 181 password_manager::TestPasswordStore* password_store, | |
|
vasilii
2017/08/02 17:41:11
What's the point to pass the store if it's essenti
kolos1
2017/08/03 07:58:01
I just copied the function from https://cs.chromiu
vasilii
2017/08/03 08:59:15
It wasn't a method of a class.
kolos1
2017/08/03 09:08:03
No, it wasn't. But in PasswordManagerBrowserTestBa
vasilii
2017/08/03 09:55:38
From the point of view of the caller, obviously 2
kolos1
2017/08/04 16:36:16
Done.
| |
| 182 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 |