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

Side by Side Diff: content/browser/fileapi/file_system_operation_impl_unittest.cc

Issue 510323003: Revert of Modify test case to support streaming operation in sandbox file system. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | content/browser/fileapi/obfuscated_file_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/file_system_operation_impl.h" 5 #include "webkit/browser/fileapi/file_system_operation_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.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/logging.h" 10 #include "base/logging.h"
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 void AddQuota(int64 quota_delta) { 271 void AddQuota(int64 quota_delta) {
272 int64 quota; 272 int64 quota;
273 GetUsageAndQuota(NULL, &quota); 273 GetUsageAndQuota(NULL, &quota);
274 quota_manager()->SetQuota(sandbox_file_system_.origin(), 274 quota_manager()->SetQuota(sandbox_file_system_.origin(),
275 sandbox_file_system_.storage_type(), 275 sandbox_file_system_.storage_type(),
276 quota + quota_delta); 276 quota + quota_delta);
277 } 277 }
278 278
279 private: 279 private:
280 base::MessageLoopForIO message_loop_; 280 base::MessageLoop message_loop_;
281 scoped_refptr<QuotaManager> quota_manager_; 281 scoped_refptr<QuotaManager> quota_manager_;
282 scoped_refptr<QuotaManagerProxy> quota_manager_proxy_; 282 scoped_refptr<QuotaManagerProxy> quota_manager_proxy_;
283 283
284 // Common temp base for nondestructive uses. 284 // Common temp base for nondestructive uses.
285 base::ScopedTempDir base_; 285 base::ScopedTempDir base_;
286 286
287 SandboxFileSystemTestHelper sandbox_file_system_; 287 SandboxFileSystemTestHelper sandbox_file_system_;
288 288
289 // For post-operation status. 289 // For post-operation status.
290 int status_; 290 int status_;
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 TEST_F(FileSystemOperationImplTest, TestCopyFailureSrcFileExistsDestDir) { 546 TEST_F(FileSystemOperationImplTest, TestCopyFailureSrcFileExistsDestDir) {
547 // Src exists and is a file. Dest is a directory. 547 // Src exists and is a file. Dest is a directory.
548 FileSystemURL src_file(CreateFile("src")); 548 FileSystemURL src_file(CreateFile("src"));
549 FileSystemURL dest_dir(CreateDirectory("dest")); 549 FileSystemURL dest_dir(CreateDirectory("dest"));
550 550
551 operation_runner()->Copy(src_file, dest_dir, 551 operation_runner()->Copy(src_file, dest_dir,
552 FileSystemOperation::OPTION_NONE, 552 FileSystemOperation::OPTION_NONE,
553 FileSystemOperationRunner::CopyProgressCallback(), 553 FileSystemOperationRunner::CopyProgressCallback(),
554 RecordStatusCallback()); 554 RecordStatusCallback());
555 base::RunLoop().RunUntilIdle(); 555 base::RunLoop().RunUntilIdle();
556 EXPECT_EQ(3, quota_manager_proxy()->notify_storage_accessed_count()); 556 EXPECT_EQ(base::File::FILE_ERROR_INVALID_OPERATION, status());
557
558 EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count());
559 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count());
560 EXPECT_EQ(base::File::FILE_ERROR_NOT_A_DIRECTORY, status());
561 EXPECT_TRUE(change_observer()->HasNoChange()); 557 EXPECT_TRUE(change_observer()->HasNoChange());
562 } 558 }
563 559
564 TEST_F(FileSystemOperationImplTest, TestCopyFailureDestParentDoesntExist) { 560 TEST_F(FileSystemOperationImplTest, TestCopyFailureDestParentDoesntExist) {
565 // Dest. parent path does not exist. 561 // Dest. parent path does not exist.
566 FileSystemURL src_dir(CreateDirectory("src")); 562 FileSystemURL src_dir(CreateDirectory("src"));
567 563
568 operation_runner()->Copy(src_dir, URLForPath("nonexistent/dest"), 564 operation_runner()->Copy(src_dir, URLForPath("nonexistent/dest"),
569 FileSystemOperation::OPTION_NONE, 565 FileSystemOperation::OPTION_NONE,
570 FileSystemOperationRunner::CopyProgressCallback(), 566 FileSystemOperationRunner::CopyProgressCallback(),
(...skipping 30 matching lines...) Expand all
601 FileSystemURL src_file(CreateFile("src")); 597 FileSystemURL src_file(CreateFile("src"));
602 FileSystemURL dest_file(CreateFile("dest")); 598 FileSystemURL dest_file(CreateFile("dest"));
603 599
604 operation_runner()->Copy(src_file, dest_file, 600 operation_runner()->Copy(src_file, dest_file,
605 FileSystemOperation::OPTION_NONE, 601 FileSystemOperation::OPTION_NONE,
606 FileSystemOperationRunner::CopyProgressCallback(), 602 FileSystemOperationRunner::CopyProgressCallback(),
607 RecordStatusCallback()); 603 RecordStatusCallback());
608 base::RunLoop().RunUntilIdle(); 604 base::RunLoop().RunUntilIdle();
609 EXPECT_EQ(base::File::FILE_OK, status()); 605 EXPECT_EQ(base::File::FILE_OK, status());
610 EXPECT_TRUE(FileExists("dest")); 606 EXPECT_TRUE(FileExists("dest"));
611 EXPECT_EQ(4, quota_manager_proxy()->notify_storage_accessed_count()); 607 EXPECT_EQ(2, quota_manager_proxy()->notify_storage_accessed_count());
612 608
609 EXPECT_EQ(1, change_observer()->get_and_reset_modify_file_count());
613 EXPECT_TRUE(change_observer()->HasNoChange()); 610 EXPECT_TRUE(change_observer()->HasNoChange());
614 } 611 }
615 612
616 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcFileAndNew) { 613 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcFileAndNew) {
617 FileSystemURL src_file(CreateFile("src")); 614 FileSystemURL src_file(CreateFile("src"));
618 615
619 operation_runner()->Copy(src_file, URLForPath("new"), 616 operation_runner()->Copy(src_file, URLForPath("new"),
620 FileSystemOperation::OPTION_NONE, 617 FileSystemOperation::OPTION_NONE,
621 FileSystemOperationRunner::CopyProgressCallback(), 618 FileSystemOperationRunner::CopyProgressCallback(),
622 RecordStatusCallback()); 619 RecordStatusCallback());
623 base::RunLoop().RunUntilIdle(); 620 base::RunLoop().RunUntilIdle();
624 EXPECT_EQ(base::File::FILE_OK, status()); 621 EXPECT_EQ(base::File::FILE_OK, status());
625 EXPECT_TRUE(FileExists("new")); 622 EXPECT_TRUE(FileExists("new"));
626 EXPECT_EQ(4, quota_manager_proxy()->notify_storage_accessed_count()); 623 EXPECT_EQ(2, quota_manager_proxy()->notify_storage_accessed_count());
627 624
628 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count()); 625 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count());
629 EXPECT_TRUE(change_observer()->HasNoChange()); 626 EXPECT_TRUE(change_observer()->HasNoChange());
630 } 627 }
631 628
632 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirAndOverwrite) { 629 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirAndOverwrite) {
633 FileSystemURL src_dir(CreateDirectory("src")); 630 FileSystemURL src_dir(CreateDirectory("src"));
634 FileSystemURL dest_dir(CreateDirectory("dest")); 631 FileSystemURL dest_dir(CreateDirectory("dest"));
635 632
636 operation_runner()->Copy(src_dir, dest_dir, 633 operation_runner()->Copy(src_dir, dest_dir,
637 FileSystemOperation::OPTION_NONE, 634 FileSystemOperation::OPTION_NONE,
638 FileSystemOperationRunner::CopyProgressCallback(), 635 FileSystemOperationRunner::CopyProgressCallback(),
639 RecordStatusCallback()); 636 RecordStatusCallback());
640 base::RunLoop().RunUntilIdle(); 637 base::RunLoop().RunUntilIdle();
641 EXPECT_EQ(base::File::FILE_OK, status()); 638 EXPECT_EQ(base::File::FILE_OK, status());
642 639
643 // Make sure we've overwritten but not copied the source under the |dest_dir|. 640 // Make sure we've overwritten but not copied the source under the |dest_dir|.
644 EXPECT_TRUE(DirectoryExists("dest")); 641 EXPECT_TRUE(DirectoryExists("dest"));
645 EXPECT_FALSE(DirectoryExists("dest/src")); 642 EXPECT_FALSE(DirectoryExists("dest/src"));
646 EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 3); 643 EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 3);
647 644
645 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count());
648 EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count()); 646 EXPECT_EQ(1, change_observer()->get_and_reset_create_directory_count());
649 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count());
650 EXPECT_TRUE(change_observer()->HasNoChange()); 647 EXPECT_TRUE(change_observer()->HasNoChange());
651 } 648 }
652 649
653 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirAndNew) { 650 TEST_F(FileSystemOperationImplTest, TestCopySuccessSrcDirAndNew) {
654 FileSystemURL src_dir(CreateDirectory("src")); 651 FileSystemURL src_dir(CreateDirectory("src"));
655 FileSystemURL dest_dir_new(URLForPath("dest")); 652 FileSystemURL dest_dir_new(URLForPath("dest"));
656 653
657 operation_runner()->Copy(src_dir, dest_dir_new, 654 operation_runner()->Copy(src_dir, dest_dir_new,
658 FileSystemOperation::OPTION_NONE, 655 FileSystemOperation::OPTION_NONE,
659 FileSystemOperationRunner::CopyProgressCallback(), 656 FileSystemOperationRunner::CopyProgressCallback(),
(...skipping 20 matching lines...) Expand all
680 RecordStatusCallback()); 677 RecordStatusCallback());
681 base::RunLoop().RunUntilIdle(); 678 base::RunLoop().RunUntilIdle();
682 679
683 EXPECT_EQ(base::File::FILE_OK, status()); 680 EXPECT_EQ(base::File::FILE_OK, status());
684 EXPECT_TRUE(DirectoryExists("dest/dir")); 681 EXPECT_TRUE(DirectoryExists("dest/dir"));
685 EXPECT_TRUE(FileExists("dest/dir/sub")); 682 EXPECT_TRUE(FileExists("dest/dir/sub"));
686 683
687 // For recursive copy we may record multiple read access. 684 // For recursive copy we may record multiple read access.
688 EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 1); 685 EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 1);
689 686
690 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_count());
691 EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count()); 687 EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count());
692 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); 688 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count());
689 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count());
693 EXPECT_TRUE(change_observer()->HasNoChange()); 690 EXPECT_TRUE(change_observer()->HasNoChange());
694 } 691 }
695 692
696 TEST_F(FileSystemOperationImplTest, TestCopySuccessSamePath) { 693 TEST_F(FileSystemOperationImplTest, TestCopySuccessSamePath) {
697 FileSystemURL src_dir(CreateDirectory("src")); 694 FileSystemURL src_dir(CreateDirectory("src"));
698 CreateDirectory("src/dir"); 695 CreateDirectory("src/dir");
699 CreateFile("src/dir/sub"); 696 CreateFile("src/dir/sub");
700 697
701 operation_runner()->Copy(src_dir, src_dir, 698 operation_runner()->Copy(src_dir, src_dir,
702 FileSystemOperation::OPTION_NONE, 699 FileSystemOperation::OPTION_NONE,
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 base::RunLoop().RunUntilIdle(); 1281 base::RunLoop().RunUntilIdle();
1285 1282
1286 expected_usage += grandchild_file_size + grandchild_path_cost; 1283 expected_usage += grandchild_file_size + grandchild_path_cost;
1287 usage = GetUsage(); 1284 usage = GetUsage();
1288 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size, 1285 EXPECT_EQ(2 * child_file_size + 3 * grandchild_file_size,
1289 GetDataSizeOnDisk()); 1286 GetDataSizeOnDisk());
1290 EXPECT_EQ(expected_usage, usage); 1287 EXPECT_EQ(expected_usage, usage);
1291 } 1288 }
1292 1289
1293 } // namespace content 1290 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/fileapi/obfuscated_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698