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

Side by Side Diff: components/password_manager/core/browser/password_manager_unittest.cc

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 "components/password_manager/core/browser/password_manager.h" 5 #include "components/password_manager/core/browser/password_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 MOCK_METHOD0(DidLastPageLoadEncounterSSLErrors, bool()); 73 MOCK_METHOD0(DidLastPageLoadEncounterSSLErrors, bool());
74 }; 74 };
75 75
76 ACTION_P(InvokeConsumer, forms) { arg0->OnGetPasswordStoreResults(forms); } 76 ACTION_P(InvokeConsumer, forms) { arg0->OnGetPasswordStoreResults(forms); }
77 77
78 ACTION_P(SaveToScopedPtr, scoped) { scoped->reset(arg0); } 78 ACTION_P(SaveToScopedPtr, scoped) { scoped->reset(arg0); }
79 79
80 class TestPasswordManager : public PasswordManager { 80 class TestPasswordManager : public PasswordManager {
81 public: 81 public:
82 explicit TestPasswordManager(PasswordManagerClient* client) 82 explicit TestPasswordManager(PasswordManagerClient* client)
83 : PasswordManager(client) {} 83 : PasswordManager(client, client->GetDriver()) {}
84 ~TestPasswordManager() override {} 84 ~TestPasswordManager() override {}
85 85
86 private: 86 private:
87 DISALLOW_COPY_AND_ASSIGN(TestPasswordManager); 87 DISALLOW_COPY_AND_ASSIGN(TestPasswordManager);
88 }; 88 };
89 89
90 } // namespace 90 } // namespace
91 91
92 class PasswordManagerTest : public testing::Test { 92 class PasswordManagerTest : public testing::Test {
93 protected: 93 protected:
94 void SetUp() override { 94 void SetUp() override {
95 prefs_.registry()->RegisterBooleanPref(prefs::kPasswordManagerSavingEnabled, 95 prefs_.registry()->RegisterBooleanPref(prefs::kPasswordManagerSavingEnabled,
96 true); 96 true);
97 97
98 store_ = new MockPasswordStore; 98 store_ = new MockPasswordStore;
99 EXPECT_CALL(*store_.get(), ReportMetrics(_, _)).Times(AnyNumber()); 99 EXPECT_CALL(*store_.get(), ReportMetrics(_, _)).Times(AnyNumber());
100 CHECK(store_->Init(syncer::SyncableService::StartSyncFlare())); 100 CHECK(store_->Init(syncer::SyncableService::StartSyncFlare()));
101 101
102 EXPECT_CALL(client_, IsPasswordManagerEnabledForCurrentPage()) 102 EXPECT_CALL(client_, IsPasswordManagerEnabledForCurrentPage())
103 .WillRepeatedly(Return(true)); 103 .WillRepeatedly(Return(true));
104 EXPECT_CALL(client_, IsSyncAccountCredential(_, _)) 104 EXPECT_CALL(client_, IsSyncAccountCredential(_, _))
105 .WillRepeatedly(Return(false)); 105 .WillRepeatedly(Return(false));
106 EXPECT_CALL(client_, GetPasswordStore()) 106 EXPECT_CALL(client_, GetPasswordStore())
107 .WillRepeatedly(Return(store_.get())); 107 .WillRepeatedly(Return(store_.get()));
108 EXPECT_CALL(client_, GetPrefs()).WillRepeatedly(Return(&prefs_)); 108 EXPECT_CALL(client_, GetPrefs()).WillRepeatedly(Return(&prefs_));
109 EXPECT_CALL(client_, GetDriver()).WillRepeatedly(Return(&driver_)); 109 EXPECT_CALL(client_, GetDriver()).WillRepeatedly(Return(&driver_));
110 110
111 manager_.reset(new TestPasswordManager(&client_)); 111 manager_.reset(new TestPasswordManager(&client_));
112 password_autofill_manager_.reset( 112 password_autofill_manager_.reset(
113 new PasswordAutofillManager(&client_, NULL)); 113 new PasswordAutofillManager(&client_, client_.GetDriver(), NULL));
114 114
115 EXPECT_CALL(driver_, GetPasswordManager()) 115 EXPECT_CALL(driver_, GetPasswordManager())
116 .WillRepeatedly(Return(manager_.get())); 116 .WillRepeatedly(Return(manager_.get()));
117 EXPECT_CALL(driver_, GetPasswordAutofillManager()) 117 EXPECT_CALL(driver_, GetPasswordAutofillManager())
118 .WillRepeatedly(Return(password_autofill_manager_.get())); 118 .WillRepeatedly(Return(password_autofill_manager_.get()));
119 EXPECT_CALL(driver_, DidLastPageLoadEncounterSSLErrors()) 119 EXPECT_CALL(driver_, DidLastPageLoadEncounterSSLErrors())
120 .WillRepeatedly(Return(false)); 120 .WillRepeatedly(Return(false));
121 } 121 }
122 122
123 void TearDown() override { 123 void TearDown() override {
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 true); // The post-navigation layout. 865 true); // The post-navigation layout.
866 866
867 ASSERT_TRUE(form_to_save.get()); 867 ASSERT_TRUE(form_to_save.get());
868 EXPECT_CALL(*store_.get(), AddLogin(FormMatches(form))); 868 EXPECT_CALL(*store_.get(), AddLogin(FormMatches(form)));
869 869
870 // Simulate saving the form, as if the info bar was accepted. 870 // Simulate saving the form, as if the info bar was accepted.
871 form_to_save->Save(); 871 form_to_save->Save();
872 } 872 }
873 873
874 } // namespace password_manager 874 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698