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/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/password_form_manager.h" | 10 #include "chrome/browser/password_manager/password_form_manager.h" |
11 #include "chrome/browser/password_manager/password_manager.h" | 11 #include "chrome/browser/password_manager/password_manager.h" |
12 #include "chrome/browser/password_manager/password_manager_delegate.h" | 12 #include "chrome/browser/password_manager/password_manager_delegate.h" |
13 #include "chrome/browser/profiles/profile_manager.h" | 13 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/test/base/testing_profile.h" | 14 #include "chrome/test/base/testing_profile.h" |
15 #include "webkit/forms/password_form.h" | 15 #include "content/public/common/password_form.h" |
16 | 16 |
17 using webkit::forms::PasswordForm; | 17 using content::PasswordForm; |
18 | 18 |
19 class TestPasswordManagerDelegate : public PasswordManagerDelegate { | 19 class TestPasswordManagerDelegate : public PasswordManagerDelegate { |
20 public: | 20 public: |
21 explicit TestPasswordManagerDelegate(Profile* profile) : profile_(profile) {} | 21 explicit TestPasswordManagerDelegate(Profile* profile) : profile_(profile) {} |
22 | 22 |
23 virtual void FillPasswordForm( | 23 virtual void FillPasswordForm( |
24 const webkit::forms::PasswordFormFillData& form_data) OVERRIDE {} | 24 const PasswordFormFillData& form_data) OVERRIDE {} |
25 virtual void AddSavePasswordInfoBarIfPermitted( | 25 virtual void AddSavePasswordInfoBarIfPermitted( |
26 PasswordFormManager* form_to_save) OVERRIDE {} | 26 PasswordFormManager* form_to_save) OVERRIDE {} |
27 virtual Profile* GetProfile() OVERRIDE { return profile_; } | 27 virtual Profile* GetProfile() OVERRIDE { return profile_; } |
28 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; } | 28 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; } |
29 | 29 |
30 private: | 30 private: |
31 Profile* profile_; | 31 Profile* profile_; |
32 }; | 32 }; |
33 | 33 |
34 class TestPasswordManager : public PasswordManager { | 34 class TestPasswordManager : public PasswordManager { |
35 public: | 35 public: |
36 explicit TestPasswordManager(PasswordManagerDelegate* delegate) | 36 explicit TestPasswordManager(PasswordManagerDelegate* delegate) |
37 : PasswordManager(NULL, delegate) {} | 37 : PasswordManager(NULL, delegate) {} |
38 | 38 |
39 virtual void Autofill( | 39 virtual void Autofill( |
40 const webkit::forms::PasswordForm& form_for_autofill, | 40 const content::PasswordForm& form_for_autofill, |
41 const webkit::forms::PasswordFormMap& best_matches, | 41 const content::PasswordFormMap& best_matches, |
42 const webkit::forms::PasswordForm& preferred_match, | 42 const content::PasswordForm& preferred_match, |
43 bool wait_for_username) const OVERRIDE {} | 43 bool wait_for_username) const OVERRIDE {} |
44 }; | 44 }; |
45 | 45 |
46 class TestPasswordFormManager : public PasswordFormManager { | 46 class TestPasswordFormManager : public PasswordFormManager { |
47 public: | 47 public: |
48 TestPasswordFormManager(Profile* profile, | 48 TestPasswordFormManager(Profile* profile, |
49 PasswordManager* manager, | 49 PasswordManager* manager, |
50 const webkit::forms::PasswordForm& observed_form, | 50 const content::PasswordForm& observed_form, |
51 bool ssl_valid) | 51 bool ssl_valid) |
52 : PasswordFormManager(profile, manager, NULL, observed_form, ssl_valid), | 52 : PasswordFormManager(profile, manager, NULL, observed_form, ssl_valid), |
53 num_sent_messages_(0) {} | 53 num_sent_messages_(0) {} |
54 | 54 |
55 virtual void SendNotBlacklistedToRenderer() OVERRIDE { | 55 virtual void SendNotBlacklistedToRenderer() OVERRIDE { |
56 ++num_sent_messages_; | 56 ++num_sent_messages_; |
57 } | 57 } |
58 | 58 |
59 size_t num_sent_messages() { | 59 size_t num_sent_messages() { |
60 return num_sent_messages_; | 60 return num_sent_messages_; |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 // password store, but is blacklisted; We should not send the not blacklisted | 404 // password store, but is blacklisted; We should not send the not blacklisted |
405 // message. | 405 // message. |
406 manager.reset(new TestPasswordFormManager( | 406 manager.reset(new TestPasswordFormManager( |
407 profile(), &password_manager, *observed_form(), false)); | 407 profile(), &password_manager, *observed_form(), false)); |
408 SimulateFetchMatchingLoginsFromPasswordStore(manager.get(), 3); | 408 SimulateFetchMatchingLoginsFromPasswordStore(manager.get(), 3); |
409 result.clear(); | 409 result.clear(); |
410 result.push_back(CreateSavedMatch(true)); | 410 result.push_back(CreateSavedMatch(true)); |
411 SimulateResponseFromPasswordStore(manager.get(), 3, result); | 411 SimulateResponseFromPasswordStore(manager.get(), 3, result); |
412 EXPECT_EQ(0u, manager->num_sent_messages()); | 412 EXPECT_EQ(0u, manager->num_sent_messages()); |
413 } | 413 } |
OLD | NEW |