| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/password_manager/mock_password_store.h" | 10 #include "chrome/browser/password_manager/mock_password_store.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 observed.clear(); | 341 observed.clear(); |
| 342 manager()->OnPasswordFormsRendered(observed); // The initial layout. | 342 manager()->OnPasswordFormsRendered(observed); // The initial layout. |
| 343 | 343 |
| 344 manager()->OnPasswordFormsParsed(observed); // The post-navigation load. | 344 manager()->OnPasswordFormsParsed(observed); // The post-navigation load. |
| 345 manager()->OnPasswordFormsRendered(observed); // The post-navigation layout. | 345 manager()->OnPasswordFormsRendered(observed); // The post-navigation layout. |
| 346 } | 346 } |
| 347 | 347 |
| 348 TEST_F(PasswordManagerTest, SavingDependsOnManagerEnabledPreference) { | 348 TEST_F(PasswordManagerTest, SavingDependsOnManagerEnabledPreference) { |
| 349 // Test that saving passwords depends on the password manager enabled | 349 // Test that saving passwords depends on the password manager enabled |
| 350 // preference. | 350 // preference. |
| 351 TestingPrefService* prefService = testing_profile_->GetTestingPrefService(); | 351 TestingPrefServiceSyncable* prefService = |
| 352 testing_profile_->GetTestingPrefService(); |
| 352 prefService->SetUserPref(prefs::kPasswordManagerEnabled, | 353 prefService->SetUserPref(prefs::kPasswordManagerEnabled, |
| 353 Value::CreateBooleanValue(true)); | 354 Value::CreateBooleanValue(true)); |
| 354 EXPECT_TRUE(manager()->IsSavingEnabled()); | 355 EXPECT_TRUE(manager()->IsSavingEnabled()); |
| 355 prefService->SetUserPref(prefs::kPasswordManagerEnabled, | 356 prefService->SetUserPref(prefs::kPasswordManagerEnabled, |
| 356 Value::CreateBooleanValue(false)); | 357 Value::CreateBooleanValue(false)); |
| 357 EXPECT_FALSE(manager()->IsSavingEnabled()); | 358 EXPECT_FALSE(manager()->IsSavingEnabled()); |
| 358 } | 359 } |
| 359 | 360 |
| 360 TEST_F(PasswordManagerTest, FillPasswordsOnDisabledManager) { | 361 TEST_F(PasswordManagerTest, FillPasswordsOnDisabledManager) { |
| 361 // Test fix for issue 158296: Passwords must be filled even if the password | 362 // Test fix for issue 158296: Passwords must be filled even if the password |
| 362 // manager is disabled. | 363 // manager is disabled. |
| 363 std::vector<PasswordForm*> result; | 364 std::vector<PasswordForm*> result; |
| 364 PasswordForm* existing = new PasswordForm(MakeSimpleForm()); | 365 PasswordForm* existing = new PasswordForm(MakeSimpleForm()); |
| 365 result.push_back(existing); | 366 result.push_back(existing); |
| 366 TestingPrefService* prefService = testing_profile_->GetTestingPrefService(); | 367 TestingPrefServiceSyncable* prefService = |
| 368 testing_profile_->GetTestingPrefService(); |
| 367 prefService->SetUserPref(prefs::kPasswordManagerEnabled, | 369 prefService->SetUserPref(prefs::kPasswordManagerEnabled, |
| 368 Value::CreateBooleanValue(false)); | 370 Value::CreateBooleanValue(false)); |
| 369 EXPECT_CALL(delegate_, FillPasswordForm(_)); | 371 EXPECT_CALL(delegate_, FillPasswordForm(_)); |
| 370 EXPECT_CALL(*store_, GetLogins(_, _)) | 372 EXPECT_CALL(*store_, GetLogins(_, _)) |
| 371 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(result)), Return(1))); | 373 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(result)), Return(1))); |
| 372 std::vector<PasswordForm> observed; | 374 std::vector<PasswordForm> observed; |
| 373 PasswordForm form(MakeSimpleForm()); | 375 PasswordForm form(MakeSimpleForm()); |
| 374 observed.push_back(form); | 376 observed.push_back(form); |
| 375 manager()->OnPasswordFormsParsed(observed); | 377 manager()->OnPasswordFormsParsed(observed); |
| 376 } | 378 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 // navigation occurs. | 428 // navigation occurs. |
| 427 EXPECT_CALL(delegate_, | 429 EXPECT_CALL(delegate_, |
| 428 AddSavePasswordInfoBarIfPermitted(_)).Times(Exactly(0)); | 430 AddSavePasswordInfoBarIfPermitted(_)).Times(Exactly(0)); |
| 429 EXPECT_CALL(*store_, AddLogin(FormMatches(form))); | 431 EXPECT_CALL(*store_, AddLogin(FormMatches(form))); |
| 430 | 432 |
| 431 // Now the password manager waits for the navigation to complete. | 433 // Now the password manager waits for the navigation to complete. |
| 432 observed.clear(); | 434 observed.clear(); |
| 433 manager()->OnPasswordFormsParsed(observed); // The post-navigation load. | 435 manager()->OnPasswordFormsParsed(observed); // The post-navigation load. |
| 434 manager()->OnPasswordFormsRendered(observed); // The post-navigation layout. | 436 manager()->OnPasswordFormsRendered(observed); // The post-navigation layout. |
| 435 } | 437 } |
| OLD | NEW |