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

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

Issue 9586023: Fix memory failures in PasswordManager tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
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 <vector> 5 #include <vector>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/password_manager/password_manager.h" 10 #include "chrome/browser/password_manager/password_manager.h"
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 std::vector<PasswordForm*> result; // Empty password store. 201 std::vector<PasswordForm*> result; // Empty password store.
202 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0)); 202 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0));
203 EXPECT_CALL(*store_, GetLogins(_,_)) 203 EXPECT_CALL(*store_, GetLogins(_,_))
204 .WillOnce(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0))); 204 .WillOnce(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0)));
205 std::vector<PasswordForm> observed; 205 std::vector<PasswordForm> observed;
206 PasswordForm form(MakeSimpleForm()); 206 PasswordForm form(MakeSimpleForm());
207 observed.push_back(form); 207 observed.push_back(form);
208 manager()->OnPasswordFormsFound(observed); // The initial load. 208 manager()->OnPasswordFormsFound(observed); // The initial load.
209 manager()->OnPasswordFormsVisible(observed); // The initial layout. 209 manager()->OnPasswordFormsVisible(observed); // The initial layout.
210 210
211 PasswordForm empty_form(form);
212 empty_form.username_value = string16();
213 empty_form.password_value = string16();
211 content::LoadCommittedDetails details; 214 content::LoadCommittedDetails details;
212 content::FrameNavigateParams params; 215 content::FrameNavigateParams params;
213 params.password_form = form; 216 params.password_form = empty_form;
214 manager()->DidNavigateAnyFrame(details, params); 217 manager()->DidNavigateAnyFrame(details, params);
215 218
216 // No expected calls. 219 // No expected calls.
220 EXPECT_CALL(delegate_, AddSavePasswordInfoBar(_)).Times(0);
217 manager()->DidStopLoading(); 221 manager()->DidStopLoading();
218 } 222 }
219 223
220 TEST_F(PasswordManagerTest, FormSubmitAfterNavigateSubframe) { 224 TEST_F(PasswordManagerTest, FormSubmitAfterNavigateSubframe) {
221 // Test that navigating a subframe does not prevent us from showing the save 225 // Test that navigating a subframe does not prevent us from showing the save
222 // password infobar. 226 // password infobar.
223 std::vector<PasswordForm*> result; // Empty password store. 227 std::vector<PasswordForm*> result; // Empty password store.
224 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0)); 228 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0));
225 EXPECT_CALL(*store_, GetLogins(_,_)) 229 EXPECT_CALL(*store_, GetLogins(_,_))
226 .WillOnce(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0))); 230 .WillOnce(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0)));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 EXPECT_CALL(*store_, GetLogins(_,_)) 319 EXPECT_CALL(*store_, GetLogins(_,_))
316 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0))); 320 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0)));
317 std::vector<PasswordForm> observed; 321 std::vector<PasswordForm> observed;
318 PasswordForm form(MakeSimpleForm()); 322 PasswordForm form(MakeSimpleForm());
319 observed.push_back(form); 323 observed.push_back(form);
320 manager()->OnPasswordFormsFound(observed); // The initial load. 324 manager()->OnPasswordFormsFound(observed); // The initial load.
321 // PasswordFormsVisible is not called. 325 // PasswordFormsVisible is not called.
322 326
323 manager()->DidStopLoading(); 327 manager()->DidStopLoading();
324 } 328 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698