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

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

Issue 152693003: Expose PasswordManagerDriver as a public interface to core Password code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Response to review Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/password_manager/password_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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
23 using autofill::PasswordForm; 24 using autofill::PasswordForm;
24 using base::ASCIIToUTF16; 25 using base::ASCIIToUTF16;
25 using ::testing::Eq; 26 using ::testing::Eq;
26 27
27 namespace { 28 namespace {
28 29
30 class TestPasswordManagerDriver : public PasswordManagerDriver {
31 public:
32 TestPasswordManagerDriver() {}
33
34 virtual void FillPasswordForm(
35 const autofill::PasswordFormFillData& form_data) OVERRIDE {}
36 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; }
37 };
38
29 class TestPasswordManagerDelegate : public PasswordManagerDelegate { 39 class TestPasswordManagerDelegate : public PasswordManagerDelegate {
30 public: 40 public:
31 explicit TestPasswordManagerDelegate(Profile* profile) : profile_(profile) {} 41 explicit TestPasswordManagerDelegate(Profile* profile) : profile_(profile) {}
32 42
33 virtual void FillPasswordForm(
34 const autofill::PasswordFormFillData& form_data) OVERRIDE {}
35 virtual void AddSavePasswordInfoBarIfPermitted( 43 virtual void AddSavePasswordInfoBarIfPermitted(
36 PasswordFormManager* form_to_save) OVERRIDE {} 44 PasswordFormManager* form_to_save) OVERRIDE {}
37 virtual Profile* GetProfile() OVERRIDE { return profile_; } 45 virtual Profile* GetProfile() OVERRIDE { return profile_; }
38 virtual bool DidLastPageLoadEncounterSSLErrors() OVERRIDE { return false; } 46 virtual PasswordManagerDriver* GetDriver() OVERRIDE { return &driver_; }
39 47
40 private: 48 private:
41 Profile* profile_; 49 Profile* profile_;
50 TestPasswordManagerDriver driver_;
42 }; 51 };
43 52
44 class TestPasswordManager : public PasswordManager { 53 class TestPasswordManager : public PasswordManager {
45 public: 54 public:
46 explicit TestPasswordManager(PasswordManagerDelegate* delegate) 55 explicit TestPasswordManager(PasswordManagerDelegate* delegate)
47 : PasswordManager(NULL, delegate) {} 56 : PasswordManager(NULL, delegate) {}
48 57
49 virtual void Autofill( 58 virtual void Autofill(
50 const autofill::PasswordForm& form_for_autofill, 59 const autofill::PasswordForm& form_for_autofill,
51 const autofill::PasswordFormMap& best_matches, 60 const autofill::PasswordFormMap& best_matches,
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 595
587 SanitizePossibleUsernames(manager.get(), &credentials); 596 SanitizePossibleUsernames(manager.get(), &credentials);
588 597
589 // SSN, duplicate in |other_possible_usernames| and duplicate of 598 // SSN, duplicate in |other_possible_usernames| and duplicate of
590 // |username_value| all removed. 599 // |username_value| all removed.
591 expected.clear(); 600 expected.clear();
592 expected.push_back(ASCIIToUTF16("duplicate")); 601 expected.push_back(ASCIIToUTF16("duplicate"));
593 expected.push_back(ASCIIToUTF16("random")); 602 expected.push_back(ASCIIToUTF16("random"));
594 EXPECT_THAT(credentials.other_possible_usernames, Eq(expected)); 603 EXPECT_THAT(credentials.other_possible_usernames, Eq(expected));
595 } 604 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/password_manager/password_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698