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

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

Issue 2133953002: PasswordForm -> FormDigest for GetLogins (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@413020_ssl_valid
Patch Set: Nits addressed Created 4 years, 5 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
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 "chrome/browser/password_manager/password_store_win.h" 5 #include "chrome/browser/password_manager/password_store_win.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 "http://example.com/origin", 239 "http://example.com/origin",
240 "http://example.com/action", 240 "http://example.com/action",
241 L"submit_element", 241 L"submit_element",
242 L"username_element", 242 L"username_element",
243 L"password_element", 243 L"password_element",
244 L"", 244 L"",
245 L"", 245 L"",
246 true, 246 true,
247 1, 247 1,
248 }; 248 };
249 std::unique_ptr<PasswordForm> form = 249 PasswordStore::FormDigest form(
250 CreatePasswordFormFromDataForTesting(form_data); 250 *CreatePasswordFormFromDataForTesting(form_data));
251 251
252 // The returned form will not have 'action' or '*_element' fields set. This 252 // The returned form will not have 'action' or '*_element' fields set. This
253 // is because credentials imported from IE don't have this information. 253 // is because credentials imported from IE don't have this information.
254 PasswordFormData expected_form_data = { 254 PasswordFormData expected_form_data = {
255 PasswordForm::SCHEME_HTML, 255 PasswordForm::SCHEME_HTML,
256 "http://example.com/", 256 "http://example.com/",
257 "http://example.com/origin", 257 "http://example.com/origin",
258 "", 258 "",
259 L"", 259 L"",
260 L"", 260 L"",
261 L"", 261 L"",
262 L"abcdefgh", 262 L"abcdefgh",
263 L"abcdefghijkl", 263 L"abcdefghijkl",
264 true, 264 true,
265 1, 265 1,
266 }; 266 };
267 ScopedVector<autofill::PasswordForm> expected_forms; 267 ScopedVector<autofill::PasswordForm> expected_forms;
268 expected_forms.push_back( 268 expected_forms.push_back(
269 CreatePasswordFormFromDataForTesting(expected_form_data)); 269 CreatePasswordFormFromDataForTesting(expected_form_data));
270 270
271 // The IE7 password should be returned. 271 // The IE7 password should be returned.
272 EXPECT_CALL(consumer, 272 EXPECT_CALL(consumer,
273 OnGetPasswordStoreResultsConstRef( 273 OnGetPasswordStoreResultsConstRef(
274 UnorderedPasswordFormElementsAre(expected_forms.get()))); 274 UnorderedPasswordFormElementsAre(expected_forms.get())));
275 275
276 store_->GetLogins(*form, &consumer); 276 store_->GetLogins(form, &consumer);
277 base::MessageLoop::current()->Run(); 277 base::MessageLoop::current()->Run();
278 } 278 }
279 279
280 TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) { 280 TEST_F(PasswordStoreWinTest, OutstandingWDSQueries) {
281 store_ = CreatePasswordStore(); 281 store_ = CreatePasswordStore();
282 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare())); 282 EXPECT_TRUE(store_->Init(syncer::SyncableService::StartSyncFlare()));
283 283
284 PasswordFormData form_data = { 284 PasswordFormData form_data = {
285 PasswordForm::SCHEME_HTML, 285 PasswordForm::SCHEME_HTML,
286 "http://example.com/", 286 "http://example.com/",
287 "http://example.com/origin", 287 "http://example.com/origin",
288 "http://example.com/action", 288 "http://example.com/action",
289 L"submit_element", 289 L"submit_element",
290 L"username_element", 290 L"username_element",
291 L"password_element", 291 L"password_element",
292 L"", 292 L"",
293 L"", 293 L"",
294 true, 294 true,
295 1, 295 1,
296 }; 296 };
297 std::unique_ptr<PasswordForm> form = 297 PasswordStore::FormDigest form(
298 CreatePasswordFormFromDataForTesting(form_data); 298 *CreatePasswordFormFromDataForTesting(form_data));
299 299
300 MockPasswordStoreConsumer consumer; 300 MockPasswordStoreConsumer consumer;
301 store_->GetLogins(*form, &consumer); 301 store_->GetLogins(form, &consumer);
302 302
303 // Release the PSW and the WDS before the query can return. 303 // Release the PSW and the WDS before the query can return.
304 store_->ShutdownOnUIThread(); 304 store_->ShutdownOnUIThread();
305 store_ = nullptr; 305 store_ = nullptr;
306 wds_->ShutdownOnUIThread(); 306 wds_->ShutdownOnUIThread();
307 wds_ = nullptr; 307 wds_ = nullptr;
308 wdbs_->ShutdownDatabase(); 308 wdbs_->ShutdownDatabase();
309 wdbs_ = nullptr; 309 wdbs_ = nullptr;
310 310
311 base::MessageLoop::current()->RunUntilIdle(); 311 base::MessageLoop::current()->RunUntilIdle();
(...skipping 30 matching lines...) Expand all
342 "http://example.com/origin", 342 "http://example.com/origin",
343 "http://example.com/action", 343 "http://example.com/action",
344 L"submit_element", 344 L"submit_element",
345 L"username_element", 345 L"username_element",
346 L"password_element", 346 L"password_element",
347 L"", 347 L"",
348 L"", 348 L"",
349 true, 349 true,
350 1, 350 1,
351 }; 351 };
352 std::unique_ptr<PasswordForm> form = 352 PasswordStore::FormDigest form(
353 CreatePasswordFormFromDataForTesting(form_data); 353 *CreatePasswordFormFromDataForTesting(form_data));
354 354
355 PasswordFormData expected_form_data = { 355 PasswordFormData expected_form_data = {
356 PasswordForm::SCHEME_HTML, 356 PasswordForm::SCHEME_HTML,
357 "http://example.com/", 357 "http://example.com/",
358 "http://example.com/origin", 358 "http://example.com/origin",
359 "http://example.com/action", 359 "http://example.com/action",
360 L"submit_element", 360 L"submit_element",
361 L"username_element", 361 L"username_element",
362 L"password_element", 362 L"password_element",
363 L"abcdefgh", 363 L"abcdefgh",
364 L"abcdefghijkl", 364 L"abcdefghijkl",
365 true, 365 true,
366 1, 366 1,
367 }; 367 };
368 ScopedVector<autofill::PasswordForm> expected_forms; 368 ScopedVector<autofill::PasswordForm> expected_forms;
369 expected_forms.push_back( 369 expected_forms.push_back(
370 CreatePasswordFormFromDataForTesting(expected_form_data)); 370 CreatePasswordFormFromDataForTesting(expected_form_data));
371 371
372 // The IE7 password should be returned. 372 // The IE7 password should be returned.
373 EXPECT_CALL(password_consumer, 373 EXPECT_CALL(password_consumer,
374 OnGetPasswordStoreResultsConstRef( 374 OnGetPasswordStoreResultsConstRef(
375 UnorderedPasswordFormElementsAre(expected_forms.get()))); 375 UnorderedPasswordFormElementsAre(expected_forms.get())));
376 376
377 store_->GetLogins(*form, &password_consumer); 377 store_->GetLogins(form, &password_consumer);
378 378
379 MockWebDataServiceConsumer wds_consumer; 379 MockWebDataServiceConsumer wds_consumer;
380 380
381 EXPECT_CALL(wds_consumer, OnWebDataServiceRequestDone(_, _)) 381 EXPECT_CALL(wds_consumer, OnWebDataServiceRequestDone(_, _))
382 .WillOnce(QuitUIMessageLoop()); 382 .WillOnce(QuitUIMessageLoop());
383 383
384 wds_->GetIE7Login(password_info, &wds_consumer); 384 wds_->GetIE7Login(password_info, &wds_consumer);
385 385
386 // Run the MessageLoop twice: once for the GetIE7Login that PasswordStoreWin 386 // Run the MessageLoop twice: once for the GetIE7Login that PasswordStoreWin
387 // schedules on the DB thread and once for the one we just scheduled on the UI 387 // schedules on the DB thread and once for the one we just scheduled on the UI
(...skipping 12 matching lines...) Expand all
400 "http://example.com/origin", 400 "http://example.com/origin",
401 "http://example.com/action", 401 "http://example.com/action",
402 L"submit_element", 402 L"submit_element",
403 L"username_element", 403 L"username_element",
404 L"password_element", 404 L"password_element",
405 L"", 405 L"",
406 L"", 406 L"",
407 true, 407 true,
408 1, 408 1,
409 }; 409 };
410 std::unique_ptr<PasswordForm> form = 410 PasswordStore::FormDigest form(
411 CreatePasswordFormFromDataForTesting(form_data); 411 *CreatePasswordFormFromDataForTesting(form_data));
412 412
413 MockPasswordStoreConsumer consumer; 413 MockPasswordStoreConsumer consumer;
414 414
415 // Make sure we quit the MessageLoop even if the test fails. 415 // Make sure we quit the MessageLoop even if the test fails.
416 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) 416 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_))
417 .WillByDefault(QuitUIMessageLoop()); 417 .WillByDefault(QuitUIMessageLoop());
418 418
419 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); 419 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty()));
420 420
421 store_->GetLogins(*form, &consumer); 421 store_->GetLogins(form, &consumer);
422 base::MessageLoop::current()->Run(); 422 base::MessageLoop::current()->Run();
423 } 423 }
424 424
425 TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) { 425 TEST_F(PasswordStoreWinTest, EmptyBlacklistLogins) {
426 store_ = CreatePasswordStore(); 426 store_ = CreatePasswordStore();
427 store_->Init(syncer::SyncableService::StartSyncFlare()); 427 store_->Init(syncer::SyncableService::StartSyncFlare());
428 428
429 MockPasswordStoreConsumer consumer; 429 MockPasswordStoreConsumer consumer;
430 430
431 // Make sure we quit the MessageLoop even if the test fails. 431 // Make sure we quit the MessageLoop even if the test fails.
(...skipping 14 matching lines...) Expand all
446 446
447 // Make sure we quit the MessageLoop even if the test fails. 447 // Make sure we quit the MessageLoop even if the test fails.
448 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_)) 448 ON_CALL(consumer, OnGetPasswordStoreResultsConstRef(_))
449 .WillByDefault(QuitUIMessageLoop()); 449 .WillByDefault(QuitUIMessageLoop());
450 450
451 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty())); 451 EXPECT_CALL(consumer, OnGetPasswordStoreResultsConstRef(IsEmpty()));
452 452
453 store_->GetAutofillableLogins(&consumer); 453 store_->GetAutofillableLogins(&consumer);
454 base::MessageLoop::current()->Run(); 454 base::MessageLoop::current()->Run();
455 } 455 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_win.cc ('k') | chrome/browser/password_manager/password_store_x.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698