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

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

Issue 101143006: Convert base::file_util to use File instead of PlatformFile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove base:: Created 6 years, 11 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 TEST_P(PasswordStoreXTest, NativeMigration) { 370 TEST_P(PasswordStoreXTest, NativeMigration) {
371 VectorOfForms expected_autofillable; 371 VectorOfForms expected_autofillable;
372 InitExpectedForms(true, 50, &expected_autofillable); 372 InitExpectedForms(true, 50, &expected_autofillable);
373 373
374 VectorOfForms expected_blacklisted; 374 VectorOfForms expected_blacklisted;
375 InitExpectedForms(false, 50, &expected_blacklisted); 375 InitExpectedForms(false, 50, &expected_blacklisted);
376 376
377 // Get the initial size of the login DB file, before we populate it. 377 // Get the initial size of the login DB file, before we populate it.
378 // This will be used later to make sure it gets back to this size. 378 // This will be used later to make sure it gets back to this size.
379 const base::FilePath login_db_file = temp_dir_.path().Append("login_test"); 379 const base::FilePath login_db_file = temp_dir_.path().Append("login_test");
380 base::PlatformFileInfo db_file_start_info; 380 base::File::Info db_file_start_info;
381 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_start_info)); 381 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_start_info));
382 382
383 LoginDatabase* login_db = login_db_.get(); 383 LoginDatabase* login_db = login_db_.get();
384 384
385 // Populate the login DB with logins that should be migrated. 385 // Populate the login DB with logins that should be migrated.
386 for (VectorOfForms::iterator it = expected_autofillable.begin(); 386 for (VectorOfForms::iterator it = expected_autofillable.begin();
387 it != expected_autofillable.end(); ++it) { 387 it != expected_autofillable.end(); ++it) {
388 login_db->AddLogin(**it); 388 login_db->AddLogin(**it);
389 } 389 }
390 for (VectorOfForms::iterator it = expected_blacklisted.begin(); 390 for (VectorOfForms::iterator it = expected_blacklisted.begin();
391 it != expected_blacklisted.end(); ++it) { 391 it != expected_blacklisted.end(); ++it) {
392 login_db->AddLogin(**it); 392 login_db->AddLogin(**it);
393 } 393 }
394 394
395 // Get the new size of the login DB file. We expect it to be larger. 395 // Get the new size of the login DB file. We expect it to be larger.
396 base::PlatformFileInfo db_file_full_info; 396 base::File::Info db_file_full_info;
397 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info)); 397 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_full_info));
398 EXPECT_GT(db_file_full_info.size, db_file_start_info.size); 398 EXPECT_GT(db_file_full_info.size, db_file_start_info.size);
399 399
400 // Initializing the PasswordStore shouldn't trigger a native migration (yet). 400 // Initializing the PasswordStore shouldn't trigger a native migration (yet).
401 scoped_refptr<PasswordStoreX> store( 401 scoped_refptr<PasswordStoreX> store(
402 new PasswordStoreX(login_db_.release(), 402 new PasswordStoreX(login_db_.release(),
403 profile_.get(), 403 profile_.get(),
404 GetBackend())); 404 GetBackend()));
405 store->Init(); 405 store->Init();
406 406
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 460
461 // Wait for the login DB methods to execute. 461 // Wait for the login DB methods to execute.
462 base::RunLoop().RunUntilIdle(); 462 base::RunLoop().RunUntilIdle();
463 463
464 if (GetParam() == WORKING_BACKEND) { 464 if (GetParam() == WORKING_BACKEND) {
465 // If the migration succeeded, then not only should there be no logins left 465 // If the migration succeeded, then not only should there be no logins left
466 // in the login DB, but also the file should have been deleted and then 466 // in the login DB, but also the file should have been deleted and then
467 // recreated. We approximate checking for this by checking that the file 467 // recreated. We approximate checking for this by checking that the file
468 // size is equal to the size before we populated it, even though it was 468 // size is equal to the size before we populated it, even though it was
469 // larger after populating it. 469 // larger after populating it.
470 base::PlatformFileInfo db_file_end_info; 470 base::File::Info db_file_end_info;
471 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_end_info)); 471 ASSERT_TRUE(base::GetFileInfo(login_db_file, &db_file_end_info));
472 EXPECT_EQ(db_file_start_info.size, db_file_end_info.size); 472 EXPECT_EQ(db_file_start_info.size, db_file_end_info.size);
473 } 473 }
474 474
475 STLDeleteElements(&expected_autofillable); 475 STLDeleteElements(&expected_autofillable);
476 STLDeleteElements(&expected_blacklisted); 476 STLDeleteElements(&expected_blacklisted);
477 477
478 // Public in PasswordStore, protected in PasswordStoreX. 478 // Public in PasswordStore, protected in PasswordStoreX.
479 static_cast<PasswordStore*>(store.get())->ShutdownOnUIThread(); 479 static_cast<PasswordStore*>(store.get())->ShutdownOnUIThread();
480 } 480 }
481 481
482 INSTANTIATE_TEST_CASE_P(NoBackend, 482 INSTANTIATE_TEST_CASE_P(NoBackend,
483 PasswordStoreXTest, 483 PasswordStoreXTest,
484 testing::Values(NO_BACKEND)); 484 testing::Values(NO_BACKEND));
485 INSTANTIATE_TEST_CASE_P(FailingBackend, 485 INSTANTIATE_TEST_CASE_P(FailingBackend,
486 PasswordStoreXTest, 486 PasswordStoreXTest,
487 testing::Values(FAILING_BACKEND)); 487 testing::Values(FAILING_BACKEND));
488 INSTANTIATE_TEST_CASE_P(WorkingBackend, 488 INSTANTIATE_TEST_CASE_P(WorkingBackend,
489 PasswordStoreXTest, 489 PasswordStoreXTest,
490 testing::Values(WORKING_BACKEND)); 490 testing::Values(WORKING_BACKEND));
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698