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

Side by Side Diff: webkit/fileapi/local_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 <string> 5 #include <string>
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/memory/scoped_callback_factory.h" 8 #include "base/memory/scoped_callback_factory.h"
9 #include "base/message_loop_proxy.h" 9 #include "base/message_loop_proxy.h"
10 #include "base/platform_file.h" 10 #include "base/platform_file.h"
11 #include "base/scoped_temp_dir.h" 11 #include "base/scoped_temp_dir.h"
12 #include "base/sys_string_conversions.h" 12 #include "base/sys_string_conversions.h"
13 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "webkit/fileapi/file_system_context.h" 15 #include "webkit/fileapi/file_system_context.h"
16 #include "webkit/fileapi/file_system_file_util.h" 16 #include "webkit/fileapi/file_system_file_util.h"
17 #include "webkit/fileapi/file_system_operation_context.h" 17 #include "webkit/fileapi/file_system_operation_context.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_test_helper.h" 19 #include "webkit/fileapi/file_system_test_helper.h"
20 #include "webkit/fileapi/file_system_types.h" 20 #include "webkit/fileapi/file_system_types.h"
21 #include "webkit/fileapi/local_file_system_file_util.h" 21 #include "webkit/fileapi/local_file_system_file_util.h"
22 #include "webkit/fileapi/quota_file_util.h"
23 #include "webkit/quota/quota_manager.h"
24 22
25 namespace fileapi { 23 namespace fileapi {
26 24
27 // TODO(dmikurube): Cover all public methods in LocalFileSystemFileUtil. 25 // TODO(dmikurube): Cover all public methods in LocalFileSystemFileUtil.
28 class LocalFileSystemFileUtilTest : public testing::Test { 26 class LocalFileSystemFileUtilTest : public testing::Test {
29 public: 27 public:
30 LocalFileSystemFileUtilTest() 28 LocalFileSystemFileUtilTest()
31 : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 29 : local_file_util_(
30 new LocalFileSystemFileUtil(FileSystemFileUtil::GetInstance())),
31 callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
32 } 32 }
33 33
34 void SetUp() { 34 void SetUp() {
35 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 35 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
36 test_helper_.SetUp(data_dir_.path(), FileUtil()); 36 test_helper_.SetUp(data_dir_.path(), FileUtil());
37 } 37 }
38 38
39 void TearDown() { 39 void TearDown() {
40 test_helper_.TearDown(); 40 test_helper_.TearDown();
41 } 41 }
42 42
43 protected: 43 protected:
44 FileSystemOperationContext* NewContext() { 44 FileSystemOperationContext* NewContext() {
45 FileSystemOperationContext* context = test_helper_.NewOperationContext(); 45 FileSystemOperationContext* context = test_helper_.NewOperationContext();
46 context->set_allowed_bytes_growth(QuotaFileUtil::kNoLimit);
47 return context; 46 return context;
48 } 47 }
49 48
50 LocalFileSystemFileUtil* FileUtil() { 49 LocalFileSystemFileUtil* FileUtil() {
51 return LocalFileSystemFileUtil::GetInstance(); 50 return local_file_util_.get();
52 } 51 }
53 52
54 static FilePath Path(const std::string& file_name) { 53 static FilePath Path(const std::string& file_name) {
55 return FilePath().AppendASCII(file_name); 54 return FilePath().AppendASCII(file_name);
56 } 55 }
57 56
58 FilePath LocalPath(const char *file_name) { 57 FilePath LocalPath(const char *file_name) {
59 return test_helper_.GetLocalPathFromASCII(file_name); 58 return test_helper_.GetLocalPathFromASCII(file_name);
60 } 59 }
61 60
(...skipping 26 matching lines...) Expand all
88 87
89 base::PlatformFileError EnsureFileExists(const char* file_name, 88 base::PlatformFileError EnsureFileExists(const char* file_name,
90 bool* created) { 89 bool* created) {
91 scoped_ptr<FileSystemOperationContext> context(NewContext()); 90 scoped_ptr<FileSystemOperationContext> context(NewContext());
92 return FileUtil()->EnsureFileExists( 91 return FileUtil()->EnsureFileExists(
93 context.get(), 92 context.get(),
94 Path(file_name), created); 93 Path(file_name), created);
95 } 94 }
96 95
97 private: 96 private:
97 scoped_ptr<LocalFileSystemFileUtil> local_file_util_;
98 ScopedTempDir data_dir_; 98 ScopedTempDir data_dir_;
99 FileSystemTestOriginHelper test_helper_; 99 FileSystemTestOriginHelper test_helper_;
100 100
101 base::ScopedCallbackFactory<LocalFileSystemFileUtilTest> callback_factory_; 101 base::ScopedCallbackFactory<LocalFileSystemFileUtilTest> callback_factory_;
102 102
103 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemFileUtilTest); 103 DISALLOW_COPY_AND_ASSIGN(LocalFileSystemFileUtilTest);
104 }; 104 };
105 105
106 TEST_F(LocalFileSystemFileUtilTest, CreateAndClose) { 106 TEST_F(LocalFileSystemFileUtilTest, CreateAndClose) {
107 const char *file_name = "test_file"; 107 const char *file_name = "test_file";
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 ASSERT_EQ(base::PLATFORM_FILE_OK, 266 ASSERT_EQ(base::PLATFORM_FILE_OK,
267 FileUtil()->Move(context.get(), Path(from_dir), Path(to_dir))); 267 FileUtil()->Move(context.get(), Path(from_dir), Path(to_dir)));
268 268
269 EXPECT_FALSE(DirectoryExists(from_dir)); 269 EXPECT_FALSE(DirectoryExists(from_dir));
270 EXPECT_TRUE(DirectoryExists(to_dir)); 270 EXPECT_TRUE(DirectoryExists(to_dir));
271 EXPECT_TRUE(FileExists(to_file)); 271 EXPECT_TRUE(FileExists(to_file));
272 EXPECT_EQ(1020, GetSize(to_file)); 272 EXPECT_EQ(1020, GetSize(to_file));
273 } 273 }
274 274
275 } // namespace fileapi 275 } // namespace fileapi
OLDNEW
« no previous file with comments | « webkit/fileapi/local_file_system_file_util.cc ('k') | webkit/fileapi/obfuscated_file_system_file_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698