OLD | NEW |
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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 | 43 |
44 virtual void TearDown() { | 44 virtual void TearDown() { |
45 file_system_context_ = NULL; | 45 file_system_context_ = NULL; |
46 base::MessageLoop::current()->RunUntilIdle(); | 46 base::MessageLoop::current()->RunUntilIdle(); |
47 } | 47 } |
48 | 48 |
49 protected: | 49 protected: |
50 FileSystemOperationContext* NewContext() { | 50 FileSystemOperationContext* NewContext() { |
51 FileSystemOperationContext* context = | 51 FileSystemOperationContext* context = |
52 new FileSystemOperationContext(file_system_context_); | 52 new FileSystemOperationContext(file_system_context_.get()); |
53 context->set_update_observers( | 53 context->set_update_observers( |
54 *file_system_context_->GetUpdateObservers(kFileSystemType)); | 54 *file_system_context_->GetUpdateObservers(kFileSystemType)); |
55 context->set_root_path(data_dir_.path()); | 55 context->set_root_path(data_dir_.path()); |
56 return context; | 56 return context; |
57 } | 57 } |
58 | 58 |
59 LocalFileUtil* file_util() { | 59 LocalFileUtil* file_util() { |
60 return static_cast<LocalFileUtil*>( | 60 return static_cast<LocalFileUtil*>( |
61 file_system_context_->GetFileUtil(kFileSystemType)); | 61 file_system_context_->GetFileUtil(kFileSystemType)); |
62 } | 62 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 103 |
104 base::PlatformFileError EnsureFileExists(const char* file_name, | 104 base::PlatformFileError EnsureFileExists(const char* file_name, |
105 bool* created) { | 105 bool* created) { |
106 scoped_ptr<FileSystemOperationContext> context(NewContext()); | 106 scoped_ptr<FileSystemOperationContext> context(NewContext()); |
107 return file_util()->EnsureFileExists( | 107 return file_util()->EnsureFileExists( |
108 context.get(), | 108 context.get(), |
109 CreateURL(file_name), created); | 109 CreateURL(file_name), created); |
110 } | 110 } |
111 | 111 |
112 FileSystemContext* file_system_context() { | 112 FileSystemContext* file_system_context() { |
113 return file_system_context_; | 113 return file_system_context_.get(); |
114 } | 114 } |
115 | 115 |
116 private: | 116 private: |
117 base::MessageLoop message_loop_; | 117 base::MessageLoop message_loop_; |
118 scoped_refptr<FileSystemContext> file_system_context_; | 118 scoped_refptr<FileSystemContext> file_system_context_; |
119 base::ScopedTempDir data_dir_; | 119 base::ScopedTempDir data_dir_; |
120 | 120 |
121 DISALLOW_COPY_AND_ASSIGN(LocalFileUtilTest); | 121 DISALLOW_COPY_AND_ASSIGN(LocalFileUtilTest); |
122 }; | 122 }; |
123 | 123 |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 CreateURL(from_dir), | 378 CreateURL(from_dir), |
379 CreateURL(to_dir))); | 379 CreateURL(to_dir))); |
380 | 380 |
381 EXPECT_FALSE(DirectoryExists(from_dir)); | 381 EXPECT_FALSE(DirectoryExists(from_dir)); |
382 EXPECT_TRUE(DirectoryExists(to_dir)); | 382 EXPECT_TRUE(DirectoryExists(to_dir)); |
383 EXPECT_TRUE(FileExists(to_file)); | 383 EXPECT_TRUE(FileExists(to_file)); |
384 EXPECT_EQ(1020, GetSize(to_file)); | 384 EXPECT_EQ(1020, GetSize(to_file)); |
385 } | 385 } |
386 | 386 |
387 } // namespace fileapi | 387 } // namespace fileapi |
OLD | NEW |