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/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
12 #include "base/platform_file.h" | 12 #include "base/platform_file.h" |
13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
16 #include "webkit/browser/fileapi/async_file_test_helper.h" | 16 #include "webkit/browser/fileapi/async_file_test_helper.h" |
| 17 #include "webkit/browser/fileapi/async_file_util_adapter.h" |
17 #include "webkit/browser/fileapi/file_system_context.h" | 18 #include "webkit/browser/fileapi/file_system_context.h" |
18 #include "webkit/browser/fileapi/file_system_file_util.h" | 19 #include "webkit/browser/fileapi/file_system_file_util.h" |
19 #include "webkit/browser/fileapi/file_system_operation_context.h" | 20 #include "webkit/browser/fileapi/file_system_operation_context.h" |
20 #include "webkit/browser/fileapi/local_file_util.h" | 21 #include "webkit/browser/fileapi/local_file_util.h" |
21 #include "webkit/browser/fileapi/mock_file_system_context.h" | 22 #include "webkit/browser/fileapi/mock_file_system_context.h" |
22 #include "webkit/browser/fileapi/native_file_util.h" | 23 #include "webkit/browser/fileapi/native_file_util.h" |
23 #include "webkit/common/fileapi/file_system_types.h" | 24 #include "webkit/common/fileapi/file_system_types.h" |
24 | 25 |
25 namespace fileapi { | 26 namespace fileapi { |
26 | 27 |
(...skipping 23 matching lines...) Expand all Loading... |
50 FileSystemOperationContext* NewContext() { | 51 FileSystemOperationContext* NewContext() { |
51 FileSystemOperationContext* context = | 52 FileSystemOperationContext* context = |
52 new FileSystemOperationContext(file_system_context_.get()); | 53 new FileSystemOperationContext(file_system_context_.get()); |
53 context->set_update_observers( | 54 context->set_update_observers( |
54 *file_system_context_->GetUpdateObservers(kFileSystemType)); | 55 *file_system_context_->GetUpdateObservers(kFileSystemType)); |
55 context->set_root_path(data_dir_.path()); | 56 context->set_root_path(data_dir_.path()); |
56 return context; | 57 return context; |
57 } | 58 } |
58 | 59 |
59 LocalFileUtil* file_util() { | 60 LocalFileUtil* file_util() { |
60 return static_cast<LocalFileUtil*>( | 61 AsyncFileUtilAdapter* adapter = static_cast<AsyncFileUtilAdapter*>( |
61 file_system_context_->GetFileUtil(kFileSystemType)); | 62 file_system_context_->GetAsyncFileUtil(kFileSystemType)); |
| 63 return static_cast<LocalFileUtil*>(adapter->sync_file_util()); |
62 } | 64 } |
63 | 65 |
64 FileSystemURL CreateURL(const std::string& file_name) { | 66 FileSystemURL CreateURL(const std::string& file_name) { |
65 return file_system_context_->CreateCrackedFileSystemURL( | 67 return file_system_context_->CreateCrackedFileSystemURL( |
66 kOrigin, kFileSystemType, base::FilePath().FromUTF8Unsafe(file_name)); | 68 kOrigin, kFileSystemType, base::FilePath().FromUTF8Unsafe(file_name)); |
67 } | 69 } |
68 | 70 |
69 base::FilePath LocalPath(const char *file_name) { | 71 base::FilePath LocalPath(const char *file_name) { |
70 base::FilePath path; | 72 base::FilePath path; |
71 scoped_ptr<FileSystemOperationContext> context(NewContext()); | 73 scoped_ptr<FileSystemOperationContext> context(NewContext()); |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 CreateURL(from_dir), | 380 CreateURL(from_dir), |
379 CreateURL(to_dir))); | 381 CreateURL(to_dir))); |
380 | 382 |
381 EXPECT_FALSE(DirectoryExists(from_dir)); | 383 EXPECT_FALSE(DirectoryExists(from_dir)); |
382 EXPECT_TRUE(DirectoryExists(to_dir)); | 384 EXPECT_TRUE(DirectoryExists(to_dir)); |
383 EXPECT_TRUE(FileExists(to_file)); | 385 EXPECT_TRUE(FileExists(to_file)); |
384 EXPECT_EQ(1020, GetSize(to_file)); | 386 EXPECT_EQ(1020, GetSize(to_file)); |
385 } | 387 } |
386 | 388 |
387 } // namespace fileapi | 389 } // namespace fileapi |
OLD | NEW |