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

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

Issue 6905095: Integrated test with the actual QuotaManager and PathManager. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 8 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 "webkit/fileapi/file_system_operation.h" 5 #include "webkit/fileapi/file_system_operation.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/scoped_temp_dir.h" 10 #include "base/memory/scoped_temp_dir.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "webkit/fileapi/file_system_callback_dispatcher.h" 13 #include "webkit/fileapi/file_system_callback_dispatcher.h"
14 #include "webkit/fileapi/file_system_context.h" 14 #include "webkit/fileapi/file_system_context.h"
15 #include "webkit/fileapi/file_system_file_util.h" 15 #include "webkit/fileapi/file_system_file_util.h"
16 #include "webkit/fileapi/file_system_mount_point_provider.h" 16 #include "webkit/fileapi/file_system_mount_point_provider.h"
17 #include "webkit/fileapi/file_system_operation.h" 17 #include "webkit/fileapi/file_system_operation.h"
18 #include "webkit/fileapi/file_system_path_manager.h" 18 #include "webkit/fileapi/file_system_path_manager.h"
19 #include "webkit/fileapi/file_system_util.h" 19 #include "webkit/fileapi/file_system_util.h"
20 #include "webkit/fileapi/local_file_system_file_util.h" 20 #include "webkit/fileapi/local_file_system_file_util.h"
21 #include "webkit/fileapi/quota_file_util.h" 21 #include "webkit/fileapi/quota_file_util.h"
22 #include "webkit/quota/quota_manager.h" 22 #include "webkit/quota/quota_manager.h"
23 23
24 namespace fileapi { 24 namespace fileapi {
25 25
26 const int kFileOperationStatusNotSet = 1; 26 const int kFileOperationStatusNotSet = 1;
27 const int kFileOperationSucceeded = 0; 27 const int kFileOperationSucceeded = 0;
28 28
29 class MockDispatcher;
30
31 namespace { 29 namespace {
32 30
33 class MockQuotaManager : public quota::QuotaManager { 31 class MockQuotaManager : public quota::QuotaManager {
34 public: 32 public:
35 MockQuotaManager(int64 usage, int64 quota) 33 MockQuotaManager(int64 usage, int64 quota)
36 : quota::QuotaManager(false /* is_incognito */, 34 : quota::QuotaManager(false /* is_incognito */,
37 FilePath(), 35 FilePath(),
38 base::MessageLoopProxy::CreateForCurrentThread(), 36 base::MessageLoopProxy::CreateForCurrentThread(),
39 base::MessageLoopProxy::CreateForCurrentThread()), 37 base::MessageLoopProxy::CreateForCurrentThread()),
40 usage_(usage), 38 usage_(usage),
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 int status_; 153 int status_;
156 base::PlatformFileInfo info_; 154 base::PlatformFileInfo info_;
157 FilePath path_; 155 FilePath path_;
158 FilePath local_path_; 156 FilePath local_path_;
159 FilePath filesystem_dir_; 157 FilePath filesystem_dir_;
160 std::vector<base::FileUtilProxy::Entry> entries_; 158 std::vector<base::FileUtilProxy::Entry> entries_;
161 159
162 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest); 160 DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest);
163 }; 161 };
164 162
163 namespace {
164
165 class MockDispatcher : public FileSystemCallbackDispatcher { 165 class MockDispatcher : public FileSystemCallbackDispatcher {
166 public: 166 public:
167 MockDispatcher(FileSystemOperationTest* test) : test_(test) { } 167 MockDispatcher(FileSystemOperationTest* test) : test_(test) { }
168 168
169 virtual void DidFail(base::PlatformFileError status) { 169 virtual void DidFail(base::PlatformFileError status) {
170 test_->set_status(status); 170 test_->set_status(status);
171 } 171 }
172 172
173 virtual void DidSucceed() { 173 virtual void DidSucceed() {
174 test_->set_status(kFileOperationSucceeded); 174 test_->set_status(kFileOperationSucceeded);
(...skipping 23 matching lines...) Expand all
198 } 198 }
199 199
200 virtual void DidWrite(int64 bytes, bool complete) { 200 virtual void DidWrite(int64 bytes, bool complete) {
201 NOTREACHED(); 201 NOTREACHED();
202 } 202 }
203 203
204 private: 204 private:
205 FileSystemOperationTest* test_; 205 FileSystemOperationTest* test_;
206 }; 206 };
207 207
208 namespace {
209
210 class MockFileSystemPathManager : public FileSystemPathManager { 208 class MockFileSystemPathManager : public FileSystemPathManager {
211 public: 209 public:
212 MockFileSystemPathManager(const FilePath& filesystem_path) 210 MockFileSystemPathManager(const FilePath& filesystem_path)
213 : FileSystemPathManager(base::MessageLoopProxy::CreateForCurrentThread(), 211 : FileSystemPathManager(base::MessageLoopProxy::CreateForCurrentThread(),
214 filesystem_path, NULL, false, true), 212 filesystem_path, NULL, false, true),
215 test_filesystem_path_(filesystem_path) {} 213 test_filesystem_path_(filesystem_path) {}
216 214
217 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread( 215 virtual FilePath ValidateFileSystemRootAndGetPathOnFileThread(
218 const GURL& origin_url, 216 const GURL& origin_url,
219 FileSystemType type, 217 FileSystemType type,
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 880
883 operation()->Truncate(URLForPath(file_path), 11); 881 operation()->Truncate(URLForPath(file_path), 11);
884 MessageLoop::current()->RunAllPending(); 882 MessageLoop::current()->RunAllPending();
885 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status()); 883 EXPECT_EQ(base::PLATFORM_FILE_ERROR_NO_SPACE, status());
886 884
887 EXPECT_TRUE(file_util::GetFileInfo(PlatformPath(file_path), &info)); 885 EXPECT_TRUE(file_util::GetFileInfo(PlatformPath(file_path), &info));
888 EXPECT_EQ(10, info.size); 886 EXPECT_EQ(10, info.size);
889 } 887 }
890 888
891 } // namespace fileapi 889 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698