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

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

Issue 9564001: Clean up password manager code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't reset password form managers when subframes are navigated 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "chrome/browser/password_manager/password_manager_delegate.h" 11 #include "chrome/browser/password_manager/password_manager_delegate.h"
12 #include "chrome/browser/password_manager/password_store.h" 12 #include "chrome/browser/password_manager/password_store.h"
13 #include "chrome/common/url_constants.h" 13 #include "chrome/common/url_constants.h"
14 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 14 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
15 #include "chrome/test/base/testing_profile.h" 15 #include "chrome/test/base/testing_profile.h"
16 #include "content/browser/tab_contents/test_tab_contents.h" 16 #include "content/browser/tab_contents/test_tab_contents.h"
17 #include "content/public/browser/navigation_details.h"
18 #include "content/public/common/frame_navigate_params.h"
17 #include "content/test/test_browser_thread.h" 19 #include "content/test/test_browser_thread.h"
18 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
20 22
21 using content::BrowserThread; 23 using content::BrowserThread;
22 using webkit::forms::PasswordForm; 24 using webkit::forms::PasswordForm;
23 using testing::_; 25 using testing::_;
24 using testing::DoAll; 26 using testing::DoAll;
25 using ::testing::Exactly; 27 using ::testing::Exactly;
26 using ::testing::WithArg; 28 using ::testing::WithArg;
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 std::vector<PasswordForm*> result; // Empty password store. 201 std::vector<PasswordForm*> result; // Empty password store.
200 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0)); 202 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0));
201 EXPECT_CALL(*store_, GetLogins(_,_)) 203 EXPECT_CALL(*store_, GetLogins(_,_))
202 .WillOnce(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0))); 204 .WillOnce(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0)));
203 std::vector<PasswordForm> observed; 205 std::vector<PasswordForm> observed;
204 PasswordForm form(MakeSimpleForm()); 206 PasswordForm form(MakeSimpleForm());
205 observed.push_back(form); 207 observed.push_back(form);
206 manager()->OnPasswordFormsFound(observed); // The initial load. 208 manager()->OnPasswordFormsFound(observed); // The initial load.
207 manager()->OnPasswordFormsVisible(observed); // The initial layout. 209 manager()->OnPasswordFormsVisible(observed); // The initial layout.
208 210
209 manager()->DidNavigate(); 211 content::LoadCommittedDetails details;
212 content::FrameNavigateParams params;
213 manager()->DidNavigateAnyFrame(details, params);
210 214
211 // No expected calls. 215 // No expected calls.
212 manager()->DidStopLoading(); 216 manager()->DidStopLoading();
213 } 217 }
214 218
215 TEST_F(PasswordManagerTest, FormSubmitFailedLogin) { 219 TEST_F(PasswordManagerTest, FormSubmitFailedLogin) {
216 std::vector<PasswordForm*> result; // Empty password store. 220 std::vector<PasswordForm*> result; // Empty password store.
217 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0)); 221 EXPECT_CALL(delegate_, FillPasswordForm(_)).Times(Exactly(0));
218 EXPECT_CALL(*store_, GetLogins(_,_)) 222 EXPECT_CALL(*store_, GetLogins(_,_))
219 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0))); 223 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0)));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 EXPECT_CALL(*store_, GetLogins(_,_)) 278 EXPECT_CALL(*store_, GetLogins(_,_))
275 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0))); 279 .WillRepeatedly(DoAll(WithArg<1>(InvokeConsumer(0, result)), Return(0)));
276 std::vector<PasswordForm> observed; 280 std::vector<PasswordForm> observed;
277 PasswordForm form(MakeSimpleForm()); 281 PasswordForm form(MakeSimpleForm());
278 observed.push_back(form); 282 observed.push_back(form);
279 manager()->OnPasswordFormsFound(observed); // The initial load. 283 manager()->OnPasswordFormsFound(observed); // The initial load.
280 // PasswordFormsVisible is not called. 284 // PasswordFormsVisible is not called.
281 285
282 manager()->DidStopLoading(); 286 manager()->DidStopLoading();
283 } 287 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698