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

Side by Side Diff: webkit/browser/fileapi/sandbox_directory_database_unittest.cc

Issue 16950028: Move file_util::Delete to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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 "webkit/browser/fileapi/sandbox_directory_database.h" 5 #include "webkit/browser/fileapi/sandbox_directory_database.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ASSERT_EQ(base::PLATFORM_FILE_OK, error); 93 ASSERT_EQ(base::PLATFORM_FILE_OK, error);
94 ASSERT_TRUE(created); 94 ASSERT_TRUE(created);
95 ASSERT_TRUE(base::ClosePlatformFile(file)); 95 ASSERT_TRUE(base::ClosePlatformFile(file));
96 96
97 if (file_id_out) 97 if (file_id_out)
98 *file_id_out = file_id; 98 *file_id_out = file_id;
99 } 99 }
100 100
101 void ClearDatabaseAndDirectory() { 101 void ClearDatabaseAndDirectory() {
102 db_.reset(); 102 db_.reset();
103 ASSERT_TRUE(file_util::Delete(path(), true /* recursive */)); 103 ASSERT_TRUE(base::Delete(path(), true /* recursive */));
104 ASSERT_TRUE(file_util::CreateDirectory(path())); 104 ASSERT_TRUE(file_util::CreateDirectory(path()));
105 db_.reset(new SandboxDirectoryDatabase(path())); 105 db_.reset(new SandboxDirectoryDatabase(path()));
106 } 106 }
107 107
108 bool RepairDatabase() { 108 bool RepairDatabase() {
109 return db()->RepairDatabase( 109 return db()->RepairDatabase(
110 FilePathToString(path().Append(kDirectoryDatabaseName))); 110 FilePathToString(path().Append(kDirectoryDatabaseName)));
111 } 111 }
112 112
113 const base::FilePath& path() { 113 const base::FilePath& path() {
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 528
529 EXPECT_TRUE(db()->IsFileSystemConsistent()); 529 EXPECT_TRUE(db()->IsFileSystemConsistent());
530 } 530 }
531 531
532 TEST_F(SandboxDirectoryDatabaseTest, 532 TEST_F(SandboxDirectoryDatabaseTest,
533 TestConsistencyCheck_BackingMultiEntry) { 533 TestConsistencyCheck_BackingMultiEntry) {
534 const base::FilePath::CharType kBackingFileName[] = FPL("the celeb"); 534 const base::FilePath::CharType kBackingFileName[] = FPL("the celeb");
535 CreateFile(0, FPL("foo"), kBackingFileName, NULL); 535 CreateFile(0, FPL("foo"), kBackingFileName, NULL);
536 536
537 EXPECT_TRUE(db()->IsFileSystemConsistent()); 537 EXPECT_TRUE(db()->IsFileSystemConsistent());
538 ASSERT_TRUE(file_util::Delete(path().Append(kBackingFileName), false)); 538 ASSERT_TRUE(base::Delete(path().Append(kBackingFileName), false));
539 CreateFile(0, FPL("bar"), kBackingFileName, NULL); 539 CreateFile(0, FPL("bar"), kBackingFileName, NULL);
540 EXPECT_FALSE(db()->IsFileSystemConsistent()); 540 EXPECT_FALSE(db()->IsFileSystemConsistent());
541 } 541 }
542 542
543 TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_FileLost) { 543 TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_FileLost) {
544 const base::FilePath::CharType kBackingFileName[] = FPL("hoge"); 544 const base::FilePath::CharType kBackingFileName[] = FPL("hoge");
545 CreateFile(0, FPL("foo"), kBackingFileName, NULL); 545 CreateFile(0, FPL("foo"), kBackingFileName, NULL);
546 546
547 EXPECT_TRUE(db()->IsFileSystemConsistent()); 547 EXPECT_TRUE(db()->IsFileSystemConsistent());
548 ASSERT_TRUE(file_util::Delete(path().Append(kBackingFileName), false)); 548 ASSERT_TRUE(base::Delete(path().Append(kBackingFileName), false));
549 EXPECT_TRUE(db()->IsFileSystemConsistent()); 549 EXPECT_TRUE(db()->IsFileSystemConsistent());
550 } 550 }
551 551
552 TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_OrphanFile) { 552 TEST_F(SandboxDirectoryDatabaseTest, TestConsistencyCheck_OrphanFile) {
553 CreateFile(0, FPL("foo"), FPL("hoge"), NULL); 553 CreateFile(0, FPL("foo"), FPL("hoge"), NULL);
554 554
555 EXPECT_TRUE(db()->IsFileSystemConsistent()); 555 EXPECT_TRUE(db()->IsFileSystemConsistent());
556 556
557 bool created = false; 557 bool created = false;
558 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED; 558 base::PlatformFileError error = base::PLATFORM_FILE_ERROR_FAILED;
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 EXPECT_FALSE(db()->IsFileSystemConsistent()); 669 EXPECT_FALSE(db()->IsFileSystemConsistent());
670 670
671 FileId file_id; 671 FileId file_id;
672 EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id)); 672 EXPECT_TRUE(db()->GetChildWithName(0, kFileName, &file_id));
673 EXPECT_EQ(file_id_prev, file_id); 673 EXPECT_EQ(file_id_prev, file_id);
674 674
675 EXPECT_TRUE(db()->IsFileSystemConsistent()); 675 EXPECT_TRUE(db()->IsFileSystemConsistent());
676 } 676 }
677 677
678 } // namespace fileapi 678 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/browser/fileapi/sandbox_directory_database.cc ('k') | webkit/browser/fileapi/sandbox_isolated_origin_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698