Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: chrome/browser/password_manager/password_form_manager_unittest.cc

Issue 23742004: Move PasswordForm from //content to //autofill. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move_password_form_conversion_utils
Patch Set: Rebase Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_store.h" 14 #include "chrome/browser/password_manager/password_store.h"
15 #include "chrome/browser/password_manager/password_store_factory.h" 15 #include "chrome/browser/password_manager/password_store_factory.h"
16 #include "chrome/browser/password_manager/test_password_store.h" 16 #include "chrome/browser/password_manager/test_password_store.h"
17 #include "chrome/browser/profiles/profile_manager.h" 17 #include "chrome/browser/profiles/profile_manager.h"
18 #include "chrome/test/base/testing_profile.h" 18 #include "chrome/test/base/testing_profile.h"
19 #include "content/public/common/password_form.h" 19 #include "components/autofill/core/common/password_form.h"
20 #include "content/public/test/test_utils.h" 20 #include "content/public/test/test_utils.h"
21 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
22 22
23 using content::PasswordForm; 23 using autofill::PasswordForm;
24 24
25 using ::testing::Eq; 25 using ::testing::Eq;
26 26
27 namespace { 27 namespace {
28 28
29 class TestPasswordManagerDelegate : public PasswordManagerDelegate { 29 class TestPasswordManagerDelegate : public PasswordManagerDelegate {
30 public: 30 public:
31 explicit TestPasswordManagerDelegate(Profile* profile) : profile_(profile) {} 31 explicit TestPasswordManagerDelegate(Profile* profile) : profile_(profile) {}
32 32
33 virtual void FillPasswordForm( 33 virtual void FillPasswordForm(
34 const autofill::PasswordFormFillData& form_data) OVERRIDE {} 34 const autofill::PasswordFormFillData& form_data) OVERRIDE {}
35 virtual void AddSavePasswordInfoBarIfPermitted( 35 virtual void AddSavePasswordInfoBarIfPermitted(
36 PasswordFormManager* form_to_save) OVERRIDE {} 36 PasswordFormManager* form_to_save) OVERRIDE {}
37 virtual Profile* GetProfile() OVERRIDE { return profile_; } 37 virtual Profile* GetProfile() OVERRIDE { return profile_; }
38 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; } 38 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; }
39 39
40 private: 40 private:
41 Profile* profile_; 41 Profile* profile_;
42 }; 42 };
43 43
44 class TestPasswordManager : public PasswordManager { 44 class TestPasswordManager : public PasswordManager {
45 public: 45 public:
46 explicit TestPasswordManager(PasswordManagerDelegate* delegate) 46 explicit TestPasswordManager(PasswordManagerDelegate* delegate)
47 : PasswordManager(NULL, delegate) {} 47 : PasswordManager(NULL, delegate) {}
48 48
49 virtual void Autofill( 49 virtual void Autofill(
50 const content::PasswordForm& form_for_autofill, 50 const autofill::PasswordForm& form_for_autofill,
51 const content::PasswordFormMap& best_matches, 51 const autofill::PasswordFormMap& best_matches,
52 const content::PasswordForm& preferred_match, 52 const autofill::PasswordForm& preferred_match,
53 bool wait_for_username) const OVERRIDE {} 53 bool wait_for_username) const OVERRIDE {}
54 }; 54 };
55 55
56 } // namespace 56 } // namespace
57 57
58 class TestPasswordFormManager : public PasswordFormManager { 58 class TestPasswordFormManager : public PasswordFormManager {
59 public: 59 public:
60 TestPasswordFormManager(Profile* profile, 60 TestPasswordFormManager(Profile* profile,
61 PasswordManager* manager, 61 PasswordManager* manager,
62 const content::PasswordForm& observed_form, 62 const autofill::PasswordForm& observed_form,
63 bool ssl_valid) 63 bool ssl_valid)
64 : PasswordFormManager(profile, manager, NULL, observed_form, ssl_valid), 64 : PasswordFormManager(profile, manager, NULL, observed_form, ssl_valid),
65 num_sent_messages_(0) {} 65 num_sent_messages_(0) {}
66 66
67 virtual void SendNotBlacklistedToRenderer() OVERRIDE { 67 virtual void SendNotBlacklistedToRenderer() OVERRIDE {
68 ++num_sent_messages_; 68 ++num_sent_messages_;
69 } 69 }
70 70
71 size_t num_sent_messages() { 71 size_t num_sent_messages() {
72 return num_sent_messages_; 72 return num_sent_messages_;
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 541
542 SanitizePossibleUsernames(manager.get(), &credentials); 542 SanitizePossibleUsernames(manager.get(), &credentials);
543 543
544 // SSN, duplicate in |other_possible_usernames| and duplicate of 544 // SSN, duplicate in |other_possible_usernames| and duplicate of
545 // |username_value| all removed. 545 // |username_value| all removed.
546 expected.clear(); 546 expected.clear();
547 expected.push_back(ASCIIToUTF16("duplicate")); 547 expected.push_back(ASCIIToUTF16("duplicate"));
548 expected.push_back(ASCIIToUTF16("random")); 548 expected.push_back(ASCIIToUTF16("random"));
549 EXPECT_THAT(credentials.other_possible_usernames, Eq(expected)); 549 EXPECT_THAT(credentials.other_possible_usernames, Eq(expected));
550 } 550 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698