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

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

Issue 2754273003: Introduce restricted PasswordFormManager::GrabFetcher (Closed)
Patch Set: Remove redundant CredentialManagerPasswordFormManager::form_fetcher_ Created 3 years, 9 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
« no previous file with comments | « components/password_manager/core/browser/password_form_manager.cc ('k') | no next file » | 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 "components/password_manager/core/browser/password_form_manager.h" 5 #include "components/password_manager/core/browser/password_form_manager.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <utility> 10 #include <utility>
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 // Convenience downcasting method. 92 // Convenience downcasting method.
93 static MockFormSaver& Get(PasswordFormManager* form_manager) { 93 static MockFormSaver& Get(PasswordFormManager* form_manager) {
94 return *static_cast<MockFormSaver*>(form_manager->form_saver()); 94 return *static_cast<MockFormSaver*>(form_manager->form_saver());
95 } 95 }
96 96
97 private: 97 private:
98 DISALLOW_COPY_AND_ASSIGN(MockFormSaver); 98 DISALLOW_COPY_AND_ASSIGN(MockFormSaver);
99 }; 99 };
100 100
101 class MockFormFetcher : public FakeFormFetcher {
102 public:
103 MOCK_METHOD1(AddConsumer, void(Consumer*));
104 };
105
101 MATCHER_P(CheckUsername, username_value, "Username incorrect") { 106 MATCHER_P(CheckUsername, username_value, "Username incorrect") {
102 return arg.username_value == username_value; 107 return arg.username_value == username_value;
103 } 108 }
104 109
105 MATCHER_P(CheckUsernamePtr, username_value, "Username incorrect") { 110 MATCHER_P(CheckUsernamePtr, username_value, "Username incorrect") {
106 return arg && arg->username_value == username_value; 111 return arg && arg->username_value == username_value;
107 } 112 }
108 113
109 MATCHER_P2(CheckUploadedAutofillTypesAndSignature, 114 MATCHER_P2(CheckUploadedAutofillTypesAndSignature,
110 form_signature, 115 form_signature,
(...skipping 2841 matching lines...) Expand 10 before | Expand all | Expand 10 after
2952 form_manager()->ProvisionallySave( 2957 form_manager()->ProvisionallySave(
2953 updated, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES); 2958 updated, PasswordFormManager::IGNORE_OTHER_POSSIBLE_USERNAMES);
2954 credentials_to_update.clear(); 2959 credentials_to_update.clear();
2955 EXPECT_CALL(MockFormSaver::Get(form_manager()), Update(_, _, _, nullptr)) 2960 EXPECT_CALL(MockFormSaver::Get(form_manager()), Update(_, _, _, nullptr))
2956 .WillOnce(SaveArgPointee<2>(&credentials_to_update)); 2961 .WillOnce(SaveArgPointee<2>(&credentials_to_update));
2957 form_manager()->Save(); 2962 form_manager()->Save();
2958 2963
2959 EXPECT_THAT(credentials_to_update, IsEmpty()); 2964 EXPECT_THAT(credentials_to_update, IsEmpty());
2960 } 2965 }
2961 2966
2967 // Check that if asked to take ownership of the same FormFetcher which it had
2968 // consumed before, the PasswordFormManager does not add itself as a consumer
2969 // again.
2970 TEST_F(PasswordFormManagerTest, GrabFetcher_Same) {
2971 auto fetcher = base::MakeUnique<MockFormFetcher>();
2972 fetcher->Fetch();
2973 PasswordFormManager form_manager(
2974 password_manager(), client(), client()->driver(), *observed_form(),
2975 base::MakeUnique<MockFormSaver>(), fetcher.get());
2976
2977 EXPECT_CALL(*fetcher, AddConsumer(_)).Times(0);
2978 form_manager.GrabFetcher(std::move(fetcher));
2979 }
2980
2962 } // namespace password_manager 2981 } // namespace password_manager
OLDNEW
« no previous file with comments | « components/password_manager/core/browser/password_form_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698