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

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

Issue 7608011: Simplify directory path accounting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix windows build problem. Created 9 years, 4 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"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 class FileSystemFileUtilTest : public testing::Test { 57 class FileSystemFileUtilTest : public testing::Test {
58 public: 58 public:
59 FileSystemFileUtilTest() { 59 FileSystemFileUtilTest() {
60 } 60 }
61 61
62 void SetUp() { 62 void SetUp() {
63 } 63 }
64 64
65 FileSystemOperationContext* NewContext(FileSystemTestOriginHelper* helper) { 65 FileSystemOperationContext* NewContext(FileSystemTestOriginHelper* helper) {
66 FileSystemOperationContext* context = helper->NewOperationContext(); 66 FileSystemOperationContext* context = helper->NewOperationContext();
67 context->set_allowed_bytes_growth(1024 * 1024); // For paths.
Dai Mikurube (NOT FULLTIME) 2011/08/12 05:17:54 Sorry, I don't understand the reason why this is r
ericu 2011/08/15 23:47:10 Added a better comment.
67 return context; 68 return context;
68 } 69 }
69 70
70 void TestCrossFileSystemCopyMoveHelper( 71 void TestCrossFileSystemCopyMoveHelper(
71 const GURL& src_origin, fileapi::FileSystemType src_type, 72 const GURL& src_origin, fileapi::FileSystemType src_type,
72 const GURL& dest_origin, fileapi::FileSystemType dest_type, 73 const GURL& dest_origin, fileapi::FileSystemType dest_type,
73 bool copy) { 74 bool copy) {
74 ScopedTempDir base_dir; 75 ScopedTempDir base_dir;
75 ASSERT_TRUE(base_dir.CreateUniqueTempDir()); 76 ASSERT_TRUE(base_dir.CreateUniqueTempDir());
76 scoped_refptr<ObfuscatedFileSystemFileUtil> file_util( 77 scoped_refptr<ObfuscatedFileSystemFileUtil> file_util(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 // Do the actual copy or move. 111 // Do the actual copy or move.
111 FileSystemContext* file_system_context = dest_helper.file_system_context(); 112 FileSystemContext* file_system_context = dest_helper.file_system_context();
112 scoped_ptr<FileSystemOperationContext> copy_context( 113 scoped_ptr<FileSystemOperationContext> copy_context(
113 new FileSystemOperationContext(file_system_context, NULL)); 114 new FileSystemOperationContext(file_system_context, NULL));
114 copy_context->set_src_file_system_file_util(file_util); 115 copy_context->set_src_file_system_file_util(file_util);
115 copy_context->set_dest_file_system_file_util(file_util); 116 copy_context->set_dest_file_system_file_util(file_util);
116 copy_context->set_src_origin_url(src_helper.origin()); 117 copy_context->set_src_origin_url(src_helper.origin());
117 copy_context->set_dest_origin_url(dest_helper.origin()); 118 copy_context->set_dest_origin_url(dest_helper.origin());
118 copy_context->set_src_type(src_helper.type()); 119 copy_context->set_src_type(src_helper.type());
119 copy_context->set_dest_type(dest_helper.type()); 120 copy_context->set_dest_type(dest_helper.type());
121 copy_context->set_allowed_bytes_growth(1024 * 1024); // For paths.
120 122
121 if (copy) 123 if (copy)
122 ASSERT_EQ(base::PLATFORM_FILE_OK, 124 ASSERT_EQ(base::PLATFORM_FILE_OK,
123 file_util->Copy(copy_context.get(), test_root, test_root)); 125 file_util->Copy(copy_context.get(), test_root, test_root));
124 else 126 else
125 ASSERT_EQ(base::PLATFORM_FILE_OK, 127 ASSERT_EQ(base::PLATFORM_FILE_OK,
126 file_util->Move(copy_context.get(), test_root, test_root)); 128 file_util->Move(copy_context.get(), test_root, test_root));
127 129
128 // Validate that the destination paths are correct. 130 // Validate that the destination paths are correct.
129 for (size_t i = 0; i < arraysize(kCopyMoveTestCases); ++i) { 131 for (size_t i = 0; i < arraysize(kCopyMoveTestCases); ++i) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 TestCrossFileSystemCopyMoveHelper(src_origin, type, dest_origin, type, false); 197 TestCrossFileSystemCopyMoveHelper(src_origin, type, dest_origin, type, false);
196 } 198 }
197 199
198 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) { 200 TEST_F(FileSystemFileUtilTest, TestCrossFileSystemMoveSameOrigin) {
199 GURL origin("http://www.example.com"); 201 GURL origin("http://www.example.com");
200 fileapi::FileSystemType src_type = kFileSystemTypePersistent; 202 fileapi::FileSystemType src_type = kFileSystemTypePersistent;
201 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary; 203 fileapi::FileSystemType dest_type = kFileSystemTypeTemporary;
202 204
203 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false); 205 TestCrossFileSystemCopyMoveHelper(origin, src_type, origin, dest_type, false);
204 } 206 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698