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/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/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 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 | 470 |
471 manager()->OnPasswordFormsParsed(observed); // The post-navigation load. | 471 manager()->OnPasswordFormsParsed(observed); // The post-navigation load. |
472 manager()->OnPasswordFormsRendered(observed); // The post-navigation layout. | 472 manager()->OnPasswordFormsRendered(observed); // The post-navigation layout. |
473 } | 473 } |
474 | 474 |
475 TEST_F(PasswordManagerTest, SavingDependsOnManagerEnabledPreference) { | 475 TEST_F(PasswordManagerTest, SavingDependsOnManagerEnabledPreference) { |
476 // Test that saving passwords depends on the password manager enabled | 476 // Test that saving passwords depends on the password manager enabled |
477 // preference. | 477 // preference. |
478 TestingPrefServiceSyncable* prefService = profile()->GetTestingPrefService(); | 478 TestingPrefServiceSyncable* prefService = profile()->GetTestingPrefService(); |
479 prefService->SetUserPref(prefs::kPasswordManagerEnabled, | 479 prefService->SetUserPref(prefs::kPasswordManagerEnabled, |
480 Value::CreateBooleanValue(true)); | 480 base::Value::CreateBooleanValue(true)); |
481 EXPECT_TRUE(manager()->IsSavingEnabled()); | 481 EXPECT_TRUE(manager()->IsSavingEnabled()); |
482 prefService->SetUserPref(prefs::kPasswordManagerEnabled, | 482 prefService->SetUserPref(prefs::kPasswordManagerEnabled, |
483 Value::CreateBooleanValue(false)); | 483 base::Value::CreateBooleanValue(false)); |
484 EXPECT_FALSE(manager()->IsSavingEnabled()); | 484 EXPECT_FALSE(manager()->IsSavingEnabled()); |
485 } | 485 } |
486 | 486 |
487 TEST_F(PasswordManagerTest, FillPasswordsOnDisabledManager) { | 487 TEST_F(PasswordManagerTest, FillPasswordsOnDisabledManager) { |
488 // Test fix for issue 158296: Passwords must be filled even if the password | 488 // Test fix for issue 158296: Passwords must be filled even if the password |
489 // manager is disabled. | 489 // manager is disabled. |
490 std::vector<PasswordForm*> result; | 490 std::vector<PasswordForm*> result; |
491 PasswordForm* existing = new PasswordForm(MakeSimpleForm()); | 491 PasswordForm* existing = new PasswordForm(MakeSimpleForm()); |
492 result.push_back(existing); | 492 result.push_back(existing); |
493 TestingPrefServiceSyncable* prefService = profile()->GetTestingPrefService(); | 493 TestingPrefServiceSyncable* prefService = profile()->GetTestingPrefService(); |
494 prefService->SetUserPref(prefs::kPasswordManagerEnabled, | 494 prefService->SetUserPref(prefs::kPasswordManagerEnabled, |
495 Value::CreateBooleanValue(false)); | 495 base::Value::CreateBooleanValue(false)); |
496 EXPECT_CALL(delegate_, FillPasswordForm(_)); | 496 EXPECT_CALL(delegate_, FillPasswordForm(_)); |
497 EXPECT_CALL(*store_.get(), | 497 EXPECT_CALL(*store_.get(), |
498 GetLogins(_, testing::Eq(PasswordStore::DISALLOW_PROMPT), _)) | 498 GetLogins(_, testing::Eq(PasswordStore::DISALLOW_PROMPT), _)) |
499 .WillRepeatedly(DoAll(WithArg<2>(InvokeConsumer(result)), Return(1))); | 499 .WillRepeatedly(DoAll(WithArg<2>(InvokeConsumer(result)), Return(1))); |
500 std::vector<PasswordForm> observed; | 500 std::vector<PasswordForm> observed; |
501 PasswordForm form(MakeSimpleForm()); | 501 PasswordForm form(MakeSimpleForm()); |
502 observed.push_back(form); | 502 observed.push_back(form); |
503 manager()->OnPasswordFormsParsed(observed); | 503 manager()->OnPasswordFormsParsed(observed); |
504 } | 504 } |
505 | 505 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 manager()->ProvisionallySavePassword(login_form); | 587 manager()->ProvisionallySavePassword(login_form); |
588 | 588 |
589 PasswordForm failed_login_form(MakeTwitterFailedLoginForm()); | 589 PasswordForm failed_login_form(MakeTwitterFailedLoginForm()); |
590 observed.clear(); | 590 observed.clear(); |
591 observed.push_back(failed_login_form); | 591 observed.push_back(failed_login_form); |
592 // A PasswordForm appears, and is visible in the layout: | 592 // A PasswordForm appears, and is visible in the layout: |
593 // No expected calls to the PasswordStore... | 593 // No expected calls to the PasswordStore... |
594 manager()->OnPasswordFormsParsed(observed); | 594 manager()->OnPasswordFormsParsed(observed); |
595 manager()->OnPasswordFormsRendered(observed); | 595 manager()->OnPasswordFormsRendered(observed); |
596 } | 596 } |
OLD | NEW |