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" |
11 #include "chrome/browser/password_manager/password_form_manager.h" | 11 #include "chrome/browser/password_manager/password_form_manager.h" |
12 #include "chrome/browser/password_manager/password_manager.h" | 12 #include "chrome/browser/password_manager/password_manager.h" |
13 #include "chrome/browser/password_manager/password_manager_delegate.h" | 13 #include "chrome/browser/password_manager/password_manager_delegate.h" |
14 #include "chrome/browser/password_manager/password_manager_driver.h" | |
14 #include "chrome/browser/password_manager/password_store.h" | 15 #include "chrome/browser/password_manager/password_store.h" |
15 #include "chrome/browser/password_manager/password_store_factory.h" | 16 #include "chrome/browser/password_manager/password_store_factory.h" |
16 #include "chrome/browser/password_manager/test_password_store.h" | 17 #include "chrome/browser/password_manager/test_password_store.h" |
17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
18 #include "chrome/test/base/testing_profile.h" | 19 #include "chrome/test/base/testing_profile.h" |
19 #include "components/autofill/core/common/password_form.h" | 20 #include "components/autofill/core/common/password_form.h" |
20 #include "content/public/test/test_utils.h" | 21 #include "content/public/test/test_utils.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
22 | 23 |
24 class PasswordManagerDriver; | |
Patrick Dubroy
2014/02/03 13:15:08
Don't think you need this.
blundell
2014/02/03 14:37:59
Done.
| |
25 | |
23 using autofill::PasswordForm; | 26 using autofill::PasswordForm; |
24 using base::ASCIIToUTF16; | 27 using base::ASCIIToUTF16; |
25 using ::testing::Eq; | 28 using ::testing::Eq; |
26 | 29 |
27 namespace { | 30 namespace { |
28 | 31 |
32 class TestPasswordManagerDriver : public PasswordManagerDriver { | |
33 public: | |
34 TestPasswordManagerDriver() {} | |
35 | |
36 virtual void FillPasswordForm( | |
37 const autofill::PasswordFormFillData& form_data) OVERRIDE {} | |
38 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; } | |
39 }; | |
40 | |
29 class TestPasswordManagerDelegate : public PasswordManagerDelegate { | 41 class TestPasswordManagerDelegate : public PasswordManagerDelegate { |
30 public: | 42 public: |
31 explicit TestPasswordManagerDelegate(Profile* profile) : profile_(profile) {} | 43 explicit TestPasswordManagerDelegate(Profile* profile) : profile_(profile) {} |
32 | 44 |
33 virtual void FillPasswordForm( | |
34 const autofill::PasswordFormFillData& form_data) OVERRIDE {} | |
35 virtual void AddSavePasswordInfoBarIfPermitted( | 45 virtual void AddSavePasswordInfoBarIfPermitted( |
36 PasswordFormManager* form_to_save) OVERRIDE {} | 46 PasswordFormManager* form_to_save) OVERRIDE {} |
37 virtual Profile* GetProfile() OVERRIDE { return profile_; } | 47 virtual Profile* GetProfile() OVERRIDE { return profile_; } |
38 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; } | 48 virtual PasswordManagerDriver* GetDriver() OVERRIDE { return &driver_; } |
39 | 49 |
40 private: | 50 private: |
41 Profile* profile_; | 51 Profile* profile_; |
52 TestPasswordManagerDriver driver_; | |
42 }; | 53 }; |
43 | 54 |
44 class TestPasswordManager : public PasswordManager { | 55 class TestPasswordManager : public PasswordManager { |
45 public: | 56 public: |
46 explicit TestPasswordManager(PasswordManagerDelegate* delegate) | 57 explicit TestPasswordManager(PasswordManagerDelegate* delegate) |
47 : PasswordManager(NULL, delegate) {} | 58 : PasswordManager(NULL, delegate) {} |
48 | 59 |
49 virtual void Autofill( | 60 virtual void Autofill( |
50 const autofill::PasswordForm& form_for_autofill, | 61 const autofill::PasswordForm& form_for_autofill, |
51 const autofill::PasswordFormMap& best_matches, | 62 const autofill::PasswordFormMap& best_matches, |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
586 | 597 |
587 SanitizePossibleUsernames(manager.get(), &credentials); | 598 SanitizePossibleUsernames(manager.get(), &credentials); |
588 | 599 |
589 // SSN, duplicate in |other_possible_usernames| and duplicate of | 600 // SSN, duplicate in |other_possible_usernames| and duplicate of |
590 // |username_value| all removed. | 601 // |username_value| all removed. |
591 expected.clear(); | 602 expected.clear(); |
592 expected.push_back(ASCIIToUTF16("duplicate")); | 603 expected.push_back(ASCIIToUTF16("duplicate")); |
593 expected.push_back(ASCIIToUTF16("random")); | 604 expected.push_back(ASCIIToUTF16("random")); |
594 EXPECT_THAT(credentials.other_possible_usernames, Eq(expected)); | 605 EXPECT_THAT(credentials.other_possible_usernames, Eq(expected)); |
595 } | 606 } |
OLD | NEW |