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 #include "chrome/browser/password_manager/password_manager_test_base.h" | 5 #include "chrome/browser/password_manager/password_manager_test_base.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // ManagePasswordsUIController subclass to capture the UI events. | 61 // ManagePasswordsUIController subclass to capture the UI events. |
| 62 class CustomManagePasswordsUIController : public ManagePasswordsUIController { | 62 class CustomManagePasswordsUIController : public ManagePasswordsUIController { |
| 63 public: | 63 public: |
| 64 explicit CustomManagePasswordsUIController( | 64 explicit CustomManagePasswordsUIController( |
| 65 content::WebContents* web_contents); | 65 content::WebContents* web_contents); |
| 66 | 66 |
| 67 void WaitForState(password_manager::ui::State target_state); | 67 void WaitForState(password_manager::ui::State target_state); |
| 68 | 68 |
| 69 void WaitForFallbackForSaving(); | |
| 70 | |
| 71 bool was_prompt_automatically_shown() { | |
| 72 return was_prompt_automatically_shown_; | |
| 73 } | |
| 74 | |
| 69 private: | 75 private: |
| 70 // PasswordsClientUIDelegate: | 76 // PasswordsClientUIDelegate: |
| 71 void OnPasswordSubmitted( | 77 void OnPasswordSubmitted( |
| 72 std::unique_ptr<password_manager::PasswordFormManager> form_manager) | 78 std::unique_ptr<password_manager::PasswordFormManager> form_manager) |
| 73 override; | 79 override; |
| 80 void OnUpdatePasswordSubmitted( | |
| 81 std::unique_ptr<password_manager::PasswordFormManager> form_manager) | |
| 82 override; | |
| 83 void OnShowManualFallbackForSaving( | |
| 84 std::unique_ptr<password_manager::PasswordFormManager> form_manager, | |
| 85 bool has_generated_password, | |
| 86 bool is_update) override; | |
| 74 bool OnChooseCredentials( | 87 bool OnChooseCredentials( |
| 75 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, | 88 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, |
| 76 const GURL& origin, | 89 const GURL& origin, |
| 77 const ManagePasswordsState::CredentialsCallback& callback) override; | 90 const ManagePasswordsState::CredentialsCallback& callback) override; |
| 78 void OnPasswordAutofilled( | 91 void OnPasswordAutofilled( |
| 79 const std::map<base::string16, const autofill::PasswordForm*>& | 92 const std::map<base::string16, const autofill::PasswordForm*>& |
| 80 password_form_map, | 93 password_form_map, |
| 81 const GURL& origin, | 94 const GURL& origin, |
| 82 const std::vector<const autofill::PasswordForm*>* federated_matches) | 95 const std::vector<const autofill::PasswordForm*>* federated_matches) |
| 83 override; | 96 override; |
| 84 | 97 |
| 85 // The loop to be stopped when the target state is observed. | 98 // Should not be used for manual fallback events. |
| 99 bool CheckIfTargetStateIsObserved( | |
|
vasilii
2017/08/09 09:32:15
IsTargetStateObserved
kolos1
2017/08/09 09:55:05
Done.
| |
| 100 const password_manager::ui::State target_state, | |
| 101 const password_manager::ui::State current_state) const; | |
| 102 | |
| 103 void ProcessStateExpectations( | |
| 104 const password_manager::ui::State target_state, | |
|
vasilii
2017/08/09 09:32:14
I don't see any single place where |target_state|
kolos1
2017/08/09 09:55:05
True. For this function we can always use target_s
| |
| 105 const password_manager::ui::State current_state); | |
| 106 | |
| 107 // Quits |run_loop_| and clears expectations. | |
| 108 void QuitRunLoop(); | |
| 109 | |
| 110 // The loop to be stopped when the target state or fallback is observed. | |
| 86 base::RunLoop* run_loop_; | 111 base::RunLoop* run_loop_; |
| 87 | 112 |
| 88 // The state CustomManagePasswordsUIController is currently waiting for. | 113 // The state CustomManagePasswordsUIController is currently waiting for. |
| 114 // Manual fallback events don't interrupt waiting. | |
| 89 password_manager::ui::State target_state_; | 115 password_manager::ui::State target_state_; |
| 90 | 116 |
| 117 // True iff showing fallback is waited. | |
| 118 bool wait_for_fallback_; | |
| 119 | |
| 120 // True iff a prompt was automatically shown. | |
| 121 bool was_prompt_automatically_shown_; | |
| 122 | |
| 91 DISALLOW_COPY_AND_ASSIGN(CustomManagePasswordsUIController); | 123 DISALLOW_COPY_AND_ASSIGN(CustomManagePasswordsUIController); |
| 92 }; | 124 }; |
| 93 | 125 |
| 94 CustomManagePasswordsUIController::CustomManagePasswordsUIController( | 126 CustomManagePasswordsUIController::CustomManagePasswordsUIController( |
| 95 content::WebContents* web_contents) | 127 content::WebContents* web_contents) |
| 96 : ManagePasswordsUIController(web_contents), | 128 : ManagePasswordsUIController(web_contents), |
| 97 run_loop_(nullptr), | 129 run_loop_(nullptr), |
| 98 target_state_(password_manager::ui::INACTIVE_STATE) { | 130 target_state_(password_manager::ui::INACTIVE_STATE), |
| 131 wait_for_fallback_(false), | |
| 132 was_prompt_automatically_shown_(false) { | |
| 99 // Attach CustomManagePasswordsUIController to |web_contents| so the default | 133 // Attach CustomManagePasswordsUIController to |web_contents| so the default |
| 100 // ManagePasswordsUIController isn't created. | 134 // ManagePasswordsUIController isn't created. |
| 101 // Do not silently replace an existing ManagePasswordsUIController because it | 135 // Do not silently replace an existing ManagePasswordsUIController because it |
| 102 // unregisters itself in WebContentsDestroyed(). | 136 // unregisters itself in WebContentsDestroyed(). |
| 103 EXPECT_FALSE(web_contents->GetUserData(UserDataKey())); | 137 EXPECT_FALSE(web_contents->GetUserData(UserDataKey())); |
| 104 web_contents->SetUserData(UserDataKey(), base::WrapUnique(this)); | 138 web_contents->SetUserData(UserDataKey(), base::WrapUnique(this)); |
| 105 } | 139 } |
| 106 | 140 |
| 107 void CustomManagePasswordsUIController::WaitForState( | 141 void CustomManagePasswordsUIController::WaitForState( |
| 108 password_manager::ui::State target_state) { | 142 password_manager::ui::State target_state) { |
| 143 if (CheckIfTargetStateIsObserved(target_state, GetState())) | |
| 144 return; | |
| 145 | |
| 109 base::RunLoop run_loop; | 146 base::RunLoop run_loop; |
| 110 target_state_ = target_state; | 147 target_state_ = target_state; |
| 111 run_loop_ = &run_loop; | 148 run_loop_ = &run_loop; |
| 112 run_loop_->Run(); | 149 run_loop_->Run(); |
| 113 } | 150 } |
| 114 | 151 |
| 152 void CustomManagePasswordsUIController::WaitForFallbackForSaving() { | |
| 153 if (!was_prompt_automatically_shown_ && | |
| 154 GetState() == password_manager::ui::PENDING_PASSWORD_STATE) | |
| 155 return; | |
| 156 | |
| 157 base::RunLoop run_loop; | |
| 158 wait_for_fallback_ = true; | |
| 159 run_loop_ = &run_loop; | |
| 160 run_loop_->Run(); | |
| 161 } | |
| 162 | |
| 115 void CustomManagePasswordsUIController::OnPasswordSubmitted( | 163 void CustomManagePasswordsUIController::OnPasswordSubmitted( |
| 116 std::unique_ptr<password_manager::PasswordFormManager> form_manager) { | 164 std::unique_ptr<password_manager::PasswordFormManager> form_manager) { |
| 117 if (target_state_ == password_manager::ui::PENDING_PASSWORD_STATE) { | 165 was_prompt_automatically_shown_ = true; |
| 118 run_loop_->Quit(); | 166 ProcessStateExpectations(target_state_, |
| 119 run_loop_ = nullptr; | 167 password_manager::ui::PENDING_PASSWORD_STATE); |
| 120 target_state_ = password_manager::ui::INACTIVE_STATE; | |
| 121 } | |
| 122 return ManagePasswordsUIController::OnPasswordSubmitted( | 168 return ManagePasswordsUIController::OnPasswordSubmitted( |
| 123 std::move(form_manager)); | 169 std::move(form_manager)); |
| 124 } | 170 } |
| 125 | 171 |
| 172 void CustomManagePasswordsUIController::OnUpdatePasswordSubmitted( | |
| 173 std::unique_ptr<password_manager::PasswordFormManager> form_manager) { | |
| 174 was_prompt_automatically_shown_ = true; | |
| 175 ProcessStateExpectations(target_state_, | |
| 176 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE); | |
| 177 return ManagePasswordsUIController::OnUpdatePasswordSubmitted( | |
| 178 std::move(form_manager)); | |
| 179 } | |
| 180 | |
| 181 void CustomManagePasswordsUIController::OnShowManualFallbackForSaving( | |
| 182 std::unique_ptr<password_manager::PasswordFormManager> form_manager, | |
| 183 bool has_generated_password, | |
| 184 bool is_update) { | |
| 185 if (wait_for_fallback_) | |
| 186 QuitRunLoop(); | |
| 187 | |
| 188 ManagePasswordsUIController::OnShowManualFallbackForSaving( | |
| 189 std::move(form_manager), has_generated_password, is_update); | |
| 190 } | |
| 191 | |
| 126 bool CustomManagePasswordsUIController::OnChooseCredentials( | 192 bool CustomManagePasswordsUIController::OnChooseCredentials( |
| 127 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, | 193 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials, |
| 128 const GURL& origin, | 194 const GURL& origin, |
| 129 const ManagePasswordsState::CredentialsCallback& callback) { | 195 const ManagePasswordsState::CredentialsCallback& callback) { |
| 130 if (target_state_ == password_manager::ui::CREDENTIAL_REQUEST_STATE) { | 196 ProcessStateExpectations(target_state_, |
| 131 run_loop_->Quit(); | 197 password_manager::ui::CREDENTIAL_REQUEST_STATE); |
| 132 run_loop_ = nullptr; | |
| 133 target_state_ = password_manager::ui::INACTIVE_STATE; | |
| 134 } | |
| 135 return ManagePasswordsUIController::OnChooseCredentials( | 198 return ManagePasswordsUIController::OnChooseCredentials( |
| 136 std::move(local_credentials), origin, callback); | 199 std::move(local_credentials), origin, callback); |
| 137 } | 200 } |
| 138 | 201 |
| 139 void CustomManagePasswordsUIController::OnPasswordAutofilled( | 202 void CustomManagePasswordsUIController::OnPasswordAutofilled( |
| 140 const std::map<base::string16, const autofill::PasswordForm*>& | 203 const std::map<base::string16, const autofill::PasswordForm*>& |
| 141 password_form_map, | 204 password_form_map, |
| 142 const GURL& origin, | 205 const GURL& origin, |
| 143 const std::vector<const autofill::PasswordForm*>* federated_matches) { | 206 const std::vector<const autofill::PasswordForm*>* federated_matches) { |
| 144 if (target_state_ == password_manager::ui::MANAGE_STATE) { | 207 ProcessStateExpectations(target_state_, password_manager::ui::MANAGE_STATE); |
| 145 run_loop_->Quit(); | |
| 146 run_loop_ = nullptr; | |
| 147 target_state_ = password_manager::ui::INACTIVE_STATE; | |
| 148 } | |
| 149 return ManagePasswordsUIController::OnPasswordAutofilled( | 208 return ManagePasswordsUIController::OnPasswordAutofilled( |
| 150 password_form_map, origin, federated_matches); | 209 password_form_map, origin, federated_matches); |
| 151 } | 210 } |
| 152 | 211 |
| 212 bool CustomManagePasswordsUIController::CheckIfTargetStateIsObserved( | |
| 213 const password_manager::ui::State target_state, | |
| 214 const password_manager::ui::State current_state) const { | |
| 215 // This function should not be used for manual fallback expectations. | |
| 216 DCHECK(!wait_for_fallback_); | |
| 217 | |
| 218 bool should_wait_for_automatic_prompt = | |
| 219 target_state == password_manager::ui::PENDING_PASSWORD_STATE || | |
| 220 target_state == password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; | |
| 221 return target_state == current_state && | |
| 222 (!should_wait_for_automatic_prompt || was_prompt_automatically_shown_); | |
| 223 } | |
| 224 | |
| 225 void CustomManagePasswordsUIController::ProcessStateExpectations( | |
| 226 const password_manager::ui::State target_state, | |
| 227 const password_manager::ui::State current_state) { | |
| 228 if (CheckIfTargetStateIsObserved(target_state, current_state)) | |
| 229 QuitRunLoop(); | |
| 230 } | |
| 231 | |
| 232 void CustomManagePasswordsUIController::QuitRunLoop() { | |
| 233 run_loop_->Quit(); | |
| 234 run_loop_ = nullptr; | |
| 235 wait_for_fallback_ = false; | |
| 236 target_state_ = password_manager::ui::INACTIVE_STATE; | |
| 237 } | |
| 238 | |
| 153 void AddHSTSHostImpl( | 239 void AddHSTSHostImpl( |
| 154 const scoped_refptr<net::URLRequestContextGetter>& request_context, | 240 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 155 const std::string& host) { | 241 const std::string& host) { |
| 156 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 242 ASSERT_TRUE(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); |
| 157 net::TransportSecurityState* transport_security_state = | 243 net::TransportSecurityState* transport_security_state = |
| 158 request_context->GetURLRequestContext()->transport_security_state(); | 244 request_context->GetURLRequestContext()->transport_security_state(); |
| 159 if (!transport_security_state) { | 245 if (!transport_security_state) { |
| 160 ADD_FAILURE(); | 246 ADD_FAILURE(); |
| 161 return; | 247 return; |
| 162 } | 248 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 197 } | 283 } |
| 198 | 284 |
| 199 void NavigationObserver::Wait() { | 285 void NavigationObserver::Wait() { |
| 200 run_loop_.Run(); | 286 run_loop_.Run(); |
| 201 } | 287 } |
| 202 | 288 |
| 203 BubbleObserver::BubbleObserver(content::WebContents* web_contents) | 289 BubbleObserver::BubbleObserver(content::WebContents* web_contents) |
| 204 : passwords_ui_controller_( | 290 : passwords_ui_controller_( |
| 205 ManagePasswordsUIController::FromWebContents(web_contents)) {} | 291 ManagePasswordsUIController::FromWebContents(web_contents)) {} |
| 206 | 292 |
| 207 bool BubbleObserver::IsShowingSavePrompt() const { | 293 bool BubbleObserver::IsSavePromptAvailable() const { |
| 208 return passwords_ui_controller_->GetState() == | 294 return passwords_ui_controller_->GetState() == |
| 209 password_manager::ui::PENDING_PASSWORD_STATE; | 295 password_manager::ui::PENDING_PASSWORD_STATE; |
| 210 } | 296 } |
| 211 | 297 |
| 212 bool BubbleObserver::IsShowingUpdatePrompt() const { | 298 bool BubbleObserver::IsUpdatePromptAvailable() const { |
| 213 return passwords_ui_controller_->GetState() == | 299 return passwords_ui_controller_->GetState() == |
| 214 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; | 300 password_manager::ui::PENDING_PASSWORD_UPDATE_STATE; |
| 215 } | 301 } |
| 216 | 302 |
| 303 bool BubbleObserver::IsSavePromptShownAutomatically() const { | |
| 304 if (!IsSavePromptAvailable()) | |
| 305 return false; | |
| 306 return static_cast<CustomManagePasswordsUIController*>( | |
| 307 passwords_ui_controller_) | |
| 308 ->was_prompt_automatically_shown(); | |
| 309 } | |
| 310 | |
| 311 bool BubbleObserver::IsUpdatePromptShownAutomatically() const { | |
| 312 if (!IsUpdatePromptAvailable()) | |
| 313 return false; | |
| 314 return static_cast<CustomManagePasswordsUIController*>( | |
| 315 passwords_ui_controller_) | |
| 316 ->was_prompt_automatically_shown(); | |
| 317 } | |
| 318 | |
| 217 void BubbleObserver::Dismiss() const { | 319 void BubbleObserver::Dismiss() const { |
| 218 passwords_ui_controller_->OnBubbleHidden(); | 320 passwords_ui_controller_->OnBubbleHidden(); |
| 219 ASSERT_EQ(password_manager::ui::INACTIVE_STATE, | 321 ASSERT_EQ(password_manager::ui::INACTIVE_STATE, |
| 220 passwords_ui_controller_->GetState()); | 322 passwords_ui_controller_->GetState()); |
| 221 } | 323 } |
| 222 | 324 |
| 223 void BubbleObserver::AcceptSavePrompt() const { | 325 void BubbleObserver::AcceptSavePrompt() const { |
| 224 ASSERT_TRUE(IsShowingSavePrompt()); | 326 ASSERT_TRUE(IsSavePromptAvailable()); |
| 225 passwords_ui_controller_->SavePassword( | 327 passwords_ui_controller_->SavePassword( |
| 226 passwords_ui_controller_->GetPendingPassword().username_value); | 328 passwords_ui_controller_->GetPendingPassword().username_value); |
| 227 EXPECT_FALSE(IsShowingSavePrompt()); | 329 EXPECT_FALSE(IsSavePromptAvailable()); |
| 228 } | 330 } |
| 229 | 331 |
| 230 void BubbleObserver::AcceptUpdatePrompt( | 332 void BubbleObserver::AcceptUpdatePrompt( |
| 231 const autofill::PasswordForm& form) const { | 333 const autofill::PasswordForm& form) const { |
| 232 ASSERT_TRUE(IsShowingUpdatePrompt()); | 334 ASSERT_TRUE(IsUpdatePromptShownAutomatically()); |
|
vasilii
2017/08/09 09:32:14
Automatic or not we don't care. Also this check li
kolos1
2017/08/09 09:55:05
oh, of course. Fixed.
| |
| 233 passwords_ui_controller_->UpdatePassword(form); | 335 passwords_ui_controller_->UpdatePassword(form); |
| 234 EXPECT_FALSE(IsShowingUpdatePrompt()); | 336 EXPECT_FALSE(IsUpdatePromptAvailable()); |
| 235 } | 337 } |
| 236 | 338 |
| 237 void BubbleObserver::WaitForAccountChooser() const { | 339 void BubbleObserver::WaitForAccountChooser() const { |
| 238 if (passwords_ui_controller_->GetState() == | |
| 239 password_manager::ui::CREDENTIAL_REQUEST_STATE) | |
| 240 return; | |
| 241 CustomManagePasswordsUIController* controller = | 340 CustomManagePasswordsUIController* controller = |
| 242 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); | 341 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); |
| 243 controller->WaitForState(password_manager::ui::CREDENTIAL_REQUEST_STATE); | 342 controller->WaitForState(password_manager::ui::CREDENTIAL_REQUEST_STATE); |
| 244 } | 343 } |
| 245 | 344 |
| 246 void BubbleObserver::WaitForManagementState() const { | 345 void BubbleObserver::WaitForManagementState() const { |
| 247 if (passwords_ui_controller_->GetState() == | |
| 248 password_manager::ui::MANAGE_STATE) | |
| 249 return; | |
| 250 CustomManagePasswordsUIController* controller = | 346 CustomManagePasswordsUIController* controller = |
| 251 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); | 347 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); |
| 252 controller->WaitForState(password_manager::ui::MANAGE_STATE); | 348 controller->WaitForState(password_manager::ui::MANAGE_STATE); |
| 253 } | 349 } |
| 254 | 350 |
| 255 void BubbleObserver::WaitForSavePrompt() const { | 351 void BubbleObserver::WaitForAutomaticSavePrompt() const { |
| 256 if (passwords_ui_controller_->GetState() == | |
| 257 password_manager::ui::PENDING_PASSWORD_STATE) | |
| 258 return; | |
| 259 CustomManagePasswordsUIController* controller = | 352 CustomManagePasswordsUIController* controller = |
| 260 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); | 353 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); |
| 261 controller->WaitForState(password_manager::ui::PENDING_PASSWORD_STATE); | 354 controller->WaitForState(password_manager::ui::PENDING_PASSWORD_STATE); |
| 262 } | 355 } |
| 263 | 356 |
| 357 void BubbleObserver::WaitForFallbackForSaving() const { | |
| 358 CustomManagePasswordsUIController* controller = | |
| 359 static_cast<CustomManagePasswordsUIController*>(passwords_ui_controller_); | |
| 360 controller->WaitForFallbackForSaving(); | |
| 361 } | |
| 362 | |
| 264 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase() | 363 PasswordManagerBrowserTestBase::PasswordManagerBrowserTestBase() |
| 265 : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS), | 364 : https_test_server_(net::EmbeddedTestServer::TYPE_HTTPS), |
| 266 web_contents_(nullptr) {} | 365 web_contents_(nullptr) {} |
| 267 | 366 |
| 268 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() = default; | 367 PasswordManagerBrowserTestBase::~PasswordManagerBrowserTestBase() = default; |
| 269 | 368 |
| 270 void PasswordManagerBrowserTestBase::SetUpOnMainThread() { | 369 void PasswordManagerBrowserTestBase::SetUpOnMainThread() { |
| 271 // Use TestPasswordStore to remove a possible race. Normally the | 370 // Use TestPasswordStore to remove a possible race. Normally the |
| 272 // PasswordStore does its database manipulation on the DB thread, which | 371 // PasswordStore does its database manipulation on the DB thread, which |
| 273 // creates a possible race during navigation. Specifically the | 372 // creates a possible race during navigation. Specifically the |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 493 | 592 |
| 494 content::BrowserThread::PostTaskAndReply( | 593 content::BrowserThread::PostTaskAndReply( |
| 495 content::BrowserThread::IO, FROM_HERE, | 594 content::BrowserThread::IO, FROM_HERE, |
| 496 base::BindOnce( | 595 base::BindOnce( |
| 497 &AddHSTSHostImpl, | 596 &AddHSTSHostImpl, |
| 498 make_scoped_refptr(browser()->profile()->GetRequestContext()), host), | 597 make_scoped_refptr(browser()->profile()->GetRequestContext()), host), |
| 499 run_loop.QuitClosure()); | 598 run_loop.QuitClosure()); |
| 500 | 599 |
| 501 run_loop.Run(); | 600 run_loop.Run(); |
| 502 } | 601 } |
| 602 | |
| 603 void PasswordManagerBrowserTestBase::CheckThatCredentialsStored( | |
| 604 const base::string16& username, | |
| 605 const base::string16& password) { | |
| 606 scoped_refptr<password_manager::TestPasswordStore> password_store = | |
| 607 static_cast<password_manager::TestPasswordStore*>( | |
| 608 PasswordStoreFactory::GetForProfile( | |
| 609 browser()->profile(), ServiceAccessType::IMPLICIT_ACCESS) | |
| 610 .get()); | |
| 611 auto& passwords_map = password_store->stored_passwords(); | |
| 612 ASSERT_EQ(1u, passwords_map.size()); | |
| 613 auto& passwords_vector = passwords_map.begin()->second; | |
| 614 ASSERT_EQ(1u, passwords_vector.size()); | |
| 615 const autofill::PasswordForm& form = passwords_vector[0]; | |
| 616 EXPECT_EQ(username, form.username_value); | |
| 617 EXPECT_EQ(password, form.password_value); | |
| 618 } | |
| OLD | NEW |