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

Side by Side Diff: webkit/fileapi/local_file_system_operation_unittest.cc

Issue 12051010: (For-try) Divide recursive Copy/Move into multiple async tasks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test fix Created 7 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 "webkit/fileapi/local_file_system_operation.h" 5 #include "webkit/fileapi/local_file_system_operation.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 FilePath dest_dir_path(CreateUniqueDir()); 679 FilePath dest_dir_path(CreateUniqueDir());
680 operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path), 680 operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir_path),
681 RecordStatusCallback()); 681 RecordStatusCallback());
682 MessageLoop::current()->RunUntilIdle(); 682 MessageLoop::current()->RunUntilIdle();
683 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); 683 EXPECT_EQ(base::PLATFORM_FILE_OK, status());
684 EXPECT_TRUE(DirectoryExists(dest_dir_path.Append( 684 EXPECT_TRUE(DirectoryExists(dest_dir_path.Append(
685 VirtualPath::BaseName(child_dir_path)))); 685 VirtualPath::BaseName(child_dir_path))));
686 EXPECT_TRUE(FileExists(dest_dir_path.Append( 686 EXPECT_TRUE(FileExists(dest_dir_path.Append(
687 VirtualPath::BaseName(child_dir_path)).Append( 687 VirtualPath::BaseName(child_dir_path)).Append(
688 VirtualPath::BaseName(grandchild_file_path)))); 688 VirtualPath::BaseName(grandchild_file_path))));
689 EXPECT_EQ(1, quota_manager_proxy()->notify_storage_accessed_count()); 689
690 // For recursive copy we may record multiple read access.
691 EXPECT_GE(quota_manager_proxy()->notify_storage_accessed_count(), 1);
690 692
691 EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count()); 693 EXPECT_EQ(2, change_observer()->get_and_reset_create_directory_count());
692 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count()); 694 EXPECT_EQ(1, change_observer()->get_and_reset_remove_directory_count());
693 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count()); 695 EXPECT_EQ(1, change_observer()->get_and_reset_create_file_from_count());
694 EXPECT_TRUE(change_observer()->HasNoChange()); 696 EXPECT_TRUE(change_observer()->HasNoChange());
695 } 697 }
696 698
697 TEST_F(LocalFileSystemOperationTest, TestCopyInForeignFileSuccess) { 699 TEST_F(LocalFileSystemOperationTest, TestCopyInForeignFileSuccess) {
698 FilePath src_local_disk_file_path; 700 FilePath src_local_disk_file_path;
699 file_util::CreateTemporaryFile(&src_local_disk_file_path); 701 file_util::CreateTemporaryFile(&src_local_disk_file_path);
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 FilePath child_file_path(CreateUniqueFileInDir(parent_dir_path)); 1042 FilePath child_file_path(CreateUniqueFileInDir(parent_dir_path));
1041 FilePath child_dir_path(CreateUniqueDirInDir(parent_dir_path)); 1043 FilePath child_dir_path(CreateUniqueDirInDir(parent_dir_path));
1042 ASSERT_FALSE(child_dir_path.empty()); 1044 ASSERT_FALSE(child_dir_path.empty());
1043 1045
1044 operation()->Remove(URLForPath(parent_dir_path), true /* recursive */, 1046 operation()->Remove(URLForPath(parent_dir_path), true /* recursive */,
1045 RecordStatusCallback()); 1047 RecordStatusCallback());
1046 MessageLoop::current()->RunUntilIdle(); 1048 MessageLoop::current()->RunUntilIdle();
1047 EXPECT_EQ(base::PLATFORM_FILE_OK, status()); 1049 EXPECT_EQ(base::PLATFORM_FILE_OK, status());
1048 EXPECT_FALSE(DirectoryExists(parent_dir_path)); 1050 EXPECT_FALSE(DirectoryExists(parent_dir_path));
1049 1051
1050 // Remove is not a 'read' access.
1051 EXPECT_EQ(0, quota_manager_proxy()->notify_storage_accessed_count());
1052
1053 EXPECT_EQ(2, change_observer()->get_and_reset_remove_directory_count()); 1052 EXPECT_EQ(2, change_observer()->get_and_reset_remove_directory_count());
1054 EXPECT_EQ(1, change_observer()->get_and_reset_remove_file_count()); 1053 EXPECT_EQ(1, change_observer()->get_and_reset_remove_file_count());
1055 EXPECT_TRUE(change_observer()->HasNoChange()); 1054 EXPECT_TRUE(change_observer()->HasNoChange());
1056 } 1055 }
1057 1056
1058 TEST_F(LocalFileSystemOperationTest, TestTruncate) { 1057 TEST_F(LocalFileSystemOperationTest, TestTruncate) {
1059 FilePath dir_path(CreateUniqueDir()); 1058 FilePath dir_path(CreateUniqueDir());
1060 FilePath file_path(CreateUniqueFileInDir(dir_path)); 1059 FilePath file_path(CreateUniqueFileInDir(dir_path));
1061 1060
1062 char test_data[] = "test data"; 1061 char test_data[] = "test data";
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1199 EXPECT_FALSE(info().is_directory); 1198 EXPECT_FALSE(info().is_directory);
1200 EXPECT_EQ(PlatformPath(file_path), path()); 1199 EXPECT_EQ(PlatformPath(file_path), path());
1201 EXPECT_TRUE(change_observer()->HasNoChange()); 1200 EXPECT_TRUE(change_observer()->HasNoChange());
1202 1201
1203 // The FileSystemOpration implementation does not create a 1202 // The FileSystemOpration implementation does not create a
1204 // shareable file reference. 1203 // shareable file reference.
1205 EXPECT_EQ(NULL, shareable_file_ref()); 1204 EXPECT_EQ(NULL, shareable_file_ref());
1206 } 1205 }
1207 1206
1208 } // namespace fileapi 1207 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698