| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 scoped_refptr<TestPasswordStore> password_store = | 354 scoped_refptr<TestPasswordStore> password_store = |
| 355 static_cast<TestPasswordStore*>( | 355 static_cast<TestPasswordStore*>( |
| 356 PasswordStoreFactory::GetForProfile(profile(), | 356 PasswordStoreFactory::GetForProfile(profile(), |
| 357 Profile::IMPLICIT_ACCESS).get()); | 357 Profile::IMPLICIT_ACCESS).get()); |
| 358 TestPasswordManagerDelegate delegate(profile()); | 358 TestPasswordManagerDelegate delegate(profile()); |
| 359 TestPasswordManager password_manager(&delegate); | 359 TestPasswordManager password_manager(&delegate); |
| 360 scoped_ptr<TestPasswordFormManager> manager(new TestPasswordFormManager( | 360 scoped_ptr<TestPasswordFormManager> manager(new TestPasswordFormManager( |
| 361 profile(), &password_manager, *observed_form(), false)); | 361 profile(), &password_manager, *observed_form(), false)); |
| 362 | 362 |
| 363 password_store->AddLogin(*saved_match()); | 363 password_store->AddLogin(*saved_match()); |
| 364 manager->FetchMatchingLoginsFromPasswordStore(); | 364 manager->FetchMatchingLoginsFromPasswordStore(PasswordStore::ALLOW_PROMPT); |
| 365 content::RunAllPendingInMessageLoop(); | 365 content::RunAllPendingInMessageLoop(); |
| 366 | 366 |
| 367 // The saved match has the right username already. | 367 // The saved match has the right username already. |
| 368 PasswordForm login(*observed_form()); | 368 PasswordForm login(*observed_form()); |
| 369 login.username_value = saved_match()->username_value; | 369 login.username_value = saved_match()->username_value; |
| 370 login.password_value = saved_match()->password_value; | 370 login.password_value = saved_match()->password_value; |
| 371 login.preferred = true; | 371 login.preferred = true; |
| 372 manager->ProvisionallySave( | 372 manager->ProvisionallySave( |
| 373 login, | 373 login, |
| 374 PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES); | 374 PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 387 EXPECT_EQ( | 387 EXPECT_EQ( |
| 388 0U, | 388 0U, |
| 389 passwords[saved_match()->signon_realm][0]. | 389 passwords[saved_match()->signon_realm][0]. |
| 390 other_possible_usernames.size()); | 390 other_possible_usernames.size()); |
| 391 | 391 |
| 392 // This time use an alternate username | 392 // This time use an alternate username |
| 393 manager.reset(new TestPasswordFormManager( | 393 manager.reset(new TestPasswordFormManager( |
| 394 profile(), &password_manager, *observed_form(), false)); | 394 profile(), &password_manager, *observed_form(), false)); |
| 395 password_store->Clear(); | 395 password_store->Clear(); |
| 396 password_store->AddLogin(*saved_match()); | 396 password_store->AddLogin(*saved_match()); |
| 397 manager->FetchMatchingLoginsFromPasswordStore(); | 397 manager->FetchMatchingLoginsFromPasswordStore(PasswordStore::ALLOW_PROMPT); |
| 398 content::RunAllPendingInMessageLoop(); | 398 content::RunAllPendingInMessageLoop(); |
| 399 | 399 |
| 400 base::string16 new_username = saved_match()->other_possible_usernames[0]; | 400 base::string16 new_username = saved_match()->other_possible_usernames[0]; |
| 401 login.username_value = new_username; | 401 login.username_value = new_username; |
| 402 manager->ProvisionallySave( | 402 manager->ProvisionallySave( |
| 403 login, | 403 login, |
| 404 PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES); | 404 PasswordFormManager::ALLOW_OTHER_POSSIBLE_USERNAMES); |
| 405 | 405 |
| 406 EXPECT_FALSE(manager->IsNewLogin()); | 406 EXPECT_FALSE(manager->IsNewLogin()); |
| 407 manager->Save(); | 407 manager->Save(); |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 586 |
| 587 SanitizePossibleUsernames(manager.get(), &credentials); | 587 SanitizePossibleUsernames(manager.get(), &credentials); |
| 588 | 588 |
| 589 // SSN, duplicate in |other_possible_usernames| and duplicate of | 589 // SSN, duplicate in |other_possible_usernames| and duplicate of |
| 590 // |username_value| all removed. | 590 // |username_value| all removed. |
| 591 expected.clear(); | 591 expected.clear(); |
| 592 expected.push_back(ASCIIToUTF16("duplicate")); | 592 expected.push_back(ASCIIToUTF16("duplicate")); |
| 593 expected.push_back(ASCIIToUTF16("random")); | 593 expected.push_back(ASCIIToUTF16("random")); |
| 594 EXPECT_THAT(credentials.other_possible_usernames, Eq(expected)); | 594 EXPECT_THAT(credentials.other_possible_usernames, Eq(expected)); |
| 595 } | 595 } |
| OLD | NEW |