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

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

Issue 9616033: Merge CrossFileUtilHelper to FileUtilHelper as Copy() and Move(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 9 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
« no previous file with comments | « webkit/fileapi/file_system_file_util_proxy.cc ('k') | webkit/fileapi/file_system_test_helper.h » ('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 (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/file_path.h" 5 #include "base/file_path.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/platform_file.h" 8 #include "base/platform_file.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "webkit/fileapi/cross_file_util_helper.h"
12 #include "webkit/fileapi/file_system_context.h" 11 #include "webkit/fileapi/file_system_context.h"
13 #include "webkit/fileapi/file_system_operation_context.h" 12 #include "webkit/fileapi/file_system_operation_context.h"
14 #include "webkit/fileapi/file_system_test_helper.h" 13 #include "webkit/fileapi/file_system_test_helper.h"
14 #include "webkit/fileapi/file_util_helper.h"
15 #include "webkit/fileapi/native_file_util.h" 15 #include "webkit/fileapi/native_file_util.h"
16 #include "webkit/fileapi/obfuscated_file_util.h" 16 #include "webkit/fileapi/obfuscated_file_util.h"
17 #include "webkit/fileapi/test_file_set.h" 17 #include "webkit/fileapi/test_file_set.h"
18 18
19 namespace fileapi { 19 namespace fileapi {
20 20
21 // This is not yet a full unit test for FileSystemFileUtil. TODO(ericu): Adapt 21 // This is not yet a full unit test for FileSystemFileUtil. TODO(ericu): Adapt
22 // the other subclasses' unit tests, as mentioned in the comments in 22 // the other subclasses' unit tests, as mentioned in the comments in
23 // ObfuscatedFileUtil's unit test. 23 // ObfuscatedFileUtil's unit test.
24 // Currently this is just a test of cross-filesystem copy and move, which 24 // Currently this is just a test of cross-filesystem copy and move, which
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 } 83 }
84 } 84 }
85 85
86 FileSystemPath dest_root = dest_helper.CreatePathFromUTF8("root directory"); 86 FileSystemPath dest_root = dest_helper.CreatePathFromUTF8("root directory");
87 87
88 // Do the actual copy or move. 88 // Do the actual copy or move.
89 scoped_ptr<FileSystemOperationContext> copy_context( 89 scoped_ptr<FileSystemOperationContext> copy_context(
90 src_helper.NewOperationContext()); 90 src_helper.NewOperationContext());
91 copy_context->set_allowed_bytes_growth(1024 * 1024); // OFSFU path quota. 91 copy_context->set_allowed_bytes_growth(1024 * 1024); // OFSFU path quota.
92 92
93 CrossFileUtilHelper cross_util_helper( 93 if (copy) {
94 copy_context.get(), 94 ASSERT_EQ(
95 src_helper.file_util(), 95 base::PLATFORM_FILE_OK,
96 dest_helper.file_util(), 96 FileUtilHelper::Copy(
97 src_root, 97 copy_context.get(),
98 dest_root, 98 src_helper.file_util(), dest_helper.file_util(),
99 copy ? CrossFileUtilHelper::OPERATION_COPY 99 src_root, dest_root));
100 : CrossFileUtilHelper::OPERATION_MOVE); 100 } else {
101 ASSERT_EQ(base::PLATFORM_FILE_OK, cross_util_helper.DoWork()); 101 ASSERT_EQ(
102 base::PLATFORM_FILE_OK,
103 FileUtilHelper::Move(
104 copy_context.get(),
105 src_helper.file_util(), dest_helper.file_util(),
106 src_root, dest_root));
107 }
102 108
103 // Validate that the destination paths are correct. 109 // Validate that the destination paths are correct.
104 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) { 110 for (size_t i = 0; i < test::kRegularTestCaseSize; ++i) {
105 const test::TestCaseRecord& test_case = test::kRegularTestCases[i]; 111 const test::TestCaseRecord& test_case = test::kRegularTestCases[i];
106 FileSystemPath path = dest_root.Append(test_case.path); 112 FileSystemPath path = dest_root.Append(test_case.path);
107 113
108 base::PlatformFileInfo dest_file_info; 114 base::PlatformFileInfo dest_file_info;
109 FilePath data_path; 115 FilePath data_path;
110 context.reset(NewContext(&dest_helper)); 116 context.reset(NewContext(&dest_helper));
111 EXPECT_EQ(base::PLATFORM_FILE_OK, 117 EXPECT_EQ(base::PLATFORM_FILE_OK,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 178
173 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) { 179 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) {
174 GURL origin("http://www.example.com"); 180 GURL origin("http://www.example.com");
175 fileapi::FileSystemType src_type = kFileSystemTypePersistent; 181 fileapi::FileSystemType src_type = kFileSystemTypePersistent;
176 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary; 182 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary;
177 183
178 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false); 184 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false);
179 } 185 }
180 186
181 } // namespace fileapi 187 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/file_system_file_util_proxy.cc ('k') | webkit/fileapi/file_system_test_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698