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

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

Issue 7174002: Change {Obfuscated|Local}FileSystemFileUtil non-Singleton to take an underlying *FileUtil. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebased. Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/file_system_context.h" 11 #include "webkit/fileapi/file_system_context.h"
12 #include "webkit/fileapi/file_system_operation_context.h" 12 #include "webkit/fileapi/file_system_operation_context.h"
13 #include "webkit/fileapi/file_system_test_helper.h" 13 #include "webkit/fileapi/file_system_test_helper.h"
14 #include "webkit/fileapi/local_file_system_file_util.h"
15 #include "webkit/fileapi/obfuscated_file_system_file_util.h" 14 #include "webkit/fileapi/obfuscated_file_system_file_util.h"
16 15
17 using namespace fileapi; 16 using namespace fileapi;
18 17
19 namespace { 18 namespace {
20 19
21 struct CopyMoveTestCaseRecord { 20 struct CopyMoveTestCaseRecord {
22 bool is_directory; 21 bool is_directory;
23 const FilePath::CharType path[64]; 22 const FilePath::CharType path[64];
24 int64 data_file_size; 23 int64 data_file_size;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 class FileSystemFileUtilTest : public testing::Test { 57 class FileSystemFileUtilTest : public testing::Test {
59 public: 58 public:
60 FileSystemFileUtilTest() { 59 FileSystemFileUtilTest() {
61 } 60 }
62 61
63 void SetUp() { 62 void SetUp() {
64 } 63 }
65 64
66 FileSystemOperationContext* NewContext(FileSystemTestOriginHelper* helper) { 65 FileSystemOperationContext* NewContext(FileSystemTestOriginHelper* helper) {
67 FileSystemOperationContext* context = helper->NewOperationContext(); 66 FileSystemOperationContext* context = helper->NewOperationContext();
68 context->set_allowed_bytes_growth(1024 * 1024);
69 return context; 67 return context;
70 } 68 }
71 69
72 void TestCrossFileSystemCopyMoveHelper( 70 void TestCrossFileSystemCopyMoveHelper(
73 const GURL& src_origin, fileapi::FileSystemType src_type, 71 const GURL& src_origin, fileapi::FileSystemType src_type,
74 const GURL& dest_origin, fileapi::FileSystemType dest_type, 72 const GURL& dest_origin, fileapi::FileSystemType dest_type,
75 bool copy) { 73 bool copy) {
76 ScopedTempDir base_dir; 74 ScopedTempDir base_dir;
77 ASSERT_TRUE(base_dir.CreateUniqueTempDir()); 75 ASSERT_TRUE(base_dir.CreateUniqueTempDir());
78 scoped_refptr<ObfuscatedFileSystemFileUtil> file_util( 76 scoped_refptr<ObfuscatedFileSystemFileUtil> file_util(
79 new ObfuscatedFileSystemFileUtil(base_dir.path())); 77 new ObfuscatedFileSystemFileUtil(base_dir.path(),
78 FileSystemFileUtil::GetInstance()));
80 FileSystemTestOriginHelper src_helper(src_origin, src_type); 79 FileSystemTestOriginHelper src_helper(src_origin, src_type);
81 src_helper.SetUp(base_dir.path(), 80 src_helper.SetUp(base_dir.path(),
82 false, // incognito 81 false, // incognito
83 false, // unlimited quota 82 false, // unlimited quota
84 NULL, // quota::QuotaManagerProxy 83 NULL, // quota::QuotaManagerProxy
85 file_util.get()); 84 file_util.get());
86 FileSystemTestOriginHelper dest_helper(dest_origin, dest_type); 85 FileSystemTestOriginHelper dest_helper(dest_origin, dest_type);
87 dest_helper.SetUp(src_helper.file_system_context(), NULL); 86 dest_helper.SetUp(src_helper.file_system_context(), NULL);
88 87
89 // Set up all the source data. 88 // Set up all the source data.
(...skipping 21 matching lines...) Expand all
111 // Do the actual copy or move. 110 // Do the actual copy or move.
112 FileSystemContext* file_system_context = dest_helper.file_system_context(); 111 FileSystemContext* file_system_context = dest_helper.file_system_context();
113 scoped_ptr<FileSystemOperationContext> copy_context( 112 scoped_ptr<FileSystemOperationContext> copy_context(
114 new FileSystemOperationContext(file_system_context, NULL)); 113 new FileSystemOperationContext(file_system_context, NULL));
115 copy_context->set_src_file_system_file_util(file_util); 114 copy_context->set_src_file_system_file_util(file_util);
116 copy_context->set_dest_file_system_file_util(file_util); 115 copy_context->set_dest_file_system_file_util(file_util);
117 copy_context->set_src_origin_url(src_helper.origin()); 116 copy_context->set_src_origin_url(src_helper.origin());
118 copy_context->set_dest_origin_url(dest_helper.origin()); 117 copy_context->set_dest_origin_url(dest_helper.origin());
119 copy_context->set_src_type(src_helper.type()); 118 copy_context->set_src_type(src_helper.type());
120 copy_context->set_dest_type(dest_helper.type()); 119 copy_context->set_dest_type(dest_helper.type());
121 copy_context->set_allowed_bytes_growth(1024 * 1024);
122 120
123 if (copy) 121 if (copy)
124 ASSERT_EQ(base::PLATFORM_FILE_OK, 122 ASSERT_EQ(base::PLATFORM_FILE_OK,
125 file_util->Copy(copy_context.get(), test_root, test_root)); 123 file_util->Copy(copy_context.get(), test_root, test_root));
126 else 124 else
127 ASSERT_EQ(base::PLATFORM_FILE_OK, 125 ASSERT_EQ(base::PLATFORM_FILE_OK,
128 file_util->Move(copy_context.get(), test_root, test_root)); 126 file_util->Move(copy_context.get(), test_root, test_root));
129 127
130 // Validate that the destination paths are correct. 128 // Validate that the destination paths are correct.
131 for (size_t i = 0; i < arraysize(kCopyMoveTestCases); ++i) { 129 for (size_t i = 0; i < arraysize(kCopyMoveTestCases); ++i) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 TestCrossFileSystemCopyMoveHelper(src_origin, type, dest_origin, type, false); 195 TestCrossFileSystemCopyMoveHelper(src_origin, type, dest_origin, type, false);
198 } 196 }
199 197
200 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) { 198 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) {
201 GURL origin("http://www.example.com"); 199 GURL origin("http://www.example.com");
202 fileapi::FileSystemType src_type = kFileSystemTypePersistent; 200 fileapi::FileSystemType src_type = kFileSystemTypePersistent;
203 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary; 201 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary;
204 202
205 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false); 203 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false);
206 } 204 }
OLDNEW
« no previous file with comments | « webkit/chromeos/fileapi/cros_mount_point_provider.cc ('k') | webkit/fileapi/file_system_mount_point_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698