Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/password_manager/password_manager_test_base.h

Issue 2915763003: [Password Manager] Show omnibox icon and anchored prompt once user start typing password (Closed)
Patch Set: Changes addressed to reveiwer comments Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 bool IsSavePromptShownAutomatically() const;
78
79 // Checks if the update prompt was shown automatically.
80 bool IsUpdatePromptShownAutomatically() const;
73 81
74 // Dismisses the prompt currently open and moves the controller to the 82 // Dismisses the prompt currently open and moves the controller to the
75 // inactive state. 83 // inactive state.
76 void Dismiss() const; 84 void Dismiss() const;
77 85
78 // Expecting that the prompt is shown, saves the password. Checks that the 86 // Saves the password. If |expected_automatic_prompt|, expecting that the
79 // prompt is no longer visible afterwards. 87 // prompt is automatically shown. At the end, checks that the prompt is no
80 void AcceptSavePrompt() const; 88 // longer available.
89 void AcceptSavePrompt(bool expected_automatic_prompt) const;
vasilii 2017/08/07 17:13:24 No, I don't like this interface. This method isn't
kolos1 2017/08/08 12:37:16 Ok, reverted to the old version, but edited the co
81 90
82 // Expecting that the prompt is shown, update |form| with the password from 91 // Expecting that the prompt is shown, update |form| with the password from
83 // observed form. Checks that the prompt is no longer visible afterwards. 92 // observed form. Checks that the prompt is no longer visible afterwards.
84 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const; 93 void AcceptUpdatePrompt(const autofill::PasswordForm& form) const;
85 94
86 // Returns once the account chooser pops up or it's already shown. 95 // Returns once the account chooser pops up or it's already shown.
87 // |web_contents| must be the custom one returned by
88 // PasswordManagerBrowserTestBase.
vasilii 2017/08/07 17:13:24 Any reason why you don't like this comment? It's v
kolos1 2017/08/08 12:37:17 Can we mention here something except the parameter
vasilii 2017/08/08 13:26:31 Why is it outdated? Everything will crash if you c
kolos1 2017/08/08 13:41:57 I mean that it is unclear what |web_contents| is.
vasilii 2017/08/08 13:57:42 |web_contents| is a parameter to the constructor.
kolos1 2017/08/08 16:20:06 The comment is back :)
89 void WaitForAccountChooser() const; 96 void WaitForAccountChooser() const;
90 97
91 // Returns once the UI controller is in the management state due to matching 98 // Returns once the UI controller is in the management state due to matching
92 // credentials autofilled. 99 // credentials autofilled.
93 // |web_contents| must be the custom one returned by
94 // PasswordManagerBrowserTestBase.
95 void WaitForManagementState() const; 100 void WaitForManagementState() const;
96 101
97 // Returns once the save prompt pops up or it's already shown. 102 // Returns once the save prompt pops up or it's already shown.
98 // |web_contents| must be the custom one returned by 103 void WaitForAutomaticSavePrompt() const;
99 // PasswordManagerBrowserTestBase. 104
100 void WaitForSavePrompt() const; 105 // Returns once the fallback for saving becomes available.
106 void WaitForFallbackForSaving() const;
101 107
102 private: 108 private:
103 ManagePasswordsUIController* const passwords_ui_controller_; 109 ManagePasswordsUIController* const passwords_ui_controller_;
104 110
105 DISALLOW_COPY_AND_ASSIGN(BubbleObserver); 111 DISALLOW_COPY_AND_ASSIGN(BubbleObserver);
106 }; 112 };
107 113
108 class PasswordManagerBrowserTestBase : public InProcessBrowserTest { 114 class PasswordManagerBrowserTestBase : public InProcessBrowserTest {
109 public: 115 public:
110 PasswordManagerBrowserTestBase(); 116 PasswordManagerBrowserTestBase();
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 void CheckElementValue(const std::string& element_id, 161 void CheckElementValue(const std::string& element_id,
156 const std::string& expected_value); 162 const std::string& expected_value);
157 // Same as above except the element |element_id| is in iframe |iframe_id| 163 // Same as above except the element |element_id| is in iframe |iframe_id|
158 void CheckElementValue(const std::string& iframe_id, 164 void CheckElementValue(const std::string& iframe_id,
159 const std::string& element_id, 165 const std::string& element_id,
160 const std::string& expected_value); 166 const std::string& expected_value);
161 167
162 // Synchronoulsy adds the given host to the list of valid HSTS hosts. 168 // Synchronoulsy adds the given host to the list of valid HSTS hosts.
163 void AddHSTSHost(const std::string& host); 169 void AddHSTSHost(const std::string& host);
164 170
171 // Checks that |password_store| stores only one credential with |username| and
172 // |password|.
173 void CheckThatCredentialsStored(const base::string16& username,
174 const base::string16& password);
175
165 // Accessors 176 // Accessors
166 // Return the first created tab with a custom ManagePasswordsUIController. 177 // Return the first created tab with a custom ManagePasswordsUIController.
167 content::WebContents* WebContents(); 178 content::WebContents* WebContents();
168 content::RenderViewHost* RenderViewHost(); 179 content::RenderViewHost* RenderViewHost();
169 content::RenderFrameHost* RenderFrameHost(); 180 content::RenderFrameHost* RenderFrameHost();
170 net::EmbeddedTestServer& https_test_server() { return https_test_server_; } 181 net::EmbeddedTestServer& https_test_server() { return https_test_server_; }
171 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; } 182 net::MockCertVerifier& mock_cert_verifier() { return mock_cert_verifier_; }
172 183
173 private: 184 private:
174 net::EmbeddedTestServer https_test_server_; 185 net::EmbeddedTestServer https_test_server_;
175 net::MockCertVerifier mock_cert_verifier_; 186 net::MockCertVerifier mock_cert_verifier_;
176 // A tab with some hooks injected. 187 // A tab with some hooks injected.
177 content::WebContents* web_contents_; 188 content::WebContents* web_contents_;
178 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase); 189 DISALLOW_COPY_AND_ASSIGN(PasswordManagerBrowserTestBase);
179 }; 190 };
180 191
181 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_ 192 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_MANAGER_TEST_BASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698