OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "webkit/browser/fileapi/external_mount_points.h" | 26 #include "webkit/browser/fileapi/external_mount_points.h" |
27 #include "webkit/browser/fileapi/file_system_context.h" | 27 #include "webkit/browser/fileapi/file_system_context.h" |
28 #include "webkit/browser/fileapi/file_system_url.h" | 28 #include "webkit/browser/fileapi/file_system_url.h" |
29 #include "webkit/common/blob/shareable_file_reference.h" | 29 #include "webkit/common/blob/shareable_file_reference.h" |
30 | 30 |
31 namespace chromeos { | 31 namespace chromeos { |
32 namespace file_system_provider { | 32 namespace file_system_provider { |
33 namespace { | 33 namespace { |
34 | 34 |
35 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; | 35 const char kExtensionId[] = "mbflcebpggnecokmikipoihdbecnjfoj"; |
| 36 const char kFileSystemId[] = "testing-file-system"; |
36 | 37 |
37 // Logs callbacks invocations on the tested operations. | 38 // Logs callbacks invocations on the tested operations. |
38 // TODO(mtomasz): Store and verify more arguments, once the operations return | 39 // TODO(mtomasz): Store and verify more arguments, once the operations return |
39 // anything else than just an error. | 40 // anything else than just an error. |
40 class EventLogger { | 41 class EventLogger { |
41 public: | 42 public: |
42 EventLogger() : weak_ptr_factory_(this) {} | 43 EventLogger() : weak_ptr_factory_(this) {} |
43 virtual ~EventLogger() {} | 44 virtual ~EventLogger() {} |
44 | 45 |
45 void OnStatus(base::File::Error error) { | 46 void OnStatus(base::File::Error error) { |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 async_file_util_.reset(new internal::ProviderAsyncFileUtil); | 133 async_file_util_.reset(new internal::ProviderAsyncFileUtil); |
133 | 134 |
134 file_system_context_ = | 135 file_system_context_ = |
135 content::CreateFileSystemContextForTesting(NULL, data_dir_.path()); | 136 content::CreateFileSystemContextForTesting(NULL, data_dir_.path()); |
136 | 137 |
137 ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService); | 138 ServiceFactory::GetInstance()->SetTestingFactory(profile_, &CreateService); |
138 Service* service = Service::Get(profile_); // Owned by its factory. | 139 Service* service = Service::Get(profile_); // Owned by its factory. |
139 service->SetFileSystemFactoryForTests( | 140 service->SetFileSystemFactoryForTests( |
140 base::Bind(&FakeProvidedFileSystem::Create)); | 141 base::Bind(&FakeProvidedFileSystem::Create)); |
141 | 142 |
142 const int file_system_id = | 143 const bool result = service->MountFileSystem( |
143 service->MountFileSystem(kExtensionId, "testing-file-system"); | 144 kExtensionId, kFileSystemId, "Testing File System"); |
144 ASSERT_LT(0, file_system_id); | 145 ASSERT_TRUE(result); |
145 const ProvidedFileSystemInfo& file_system_info = | 146 const ProvidedFileSystemInfo& file_system_info = |
146 service->GetProvidedFileSystem(kExtensionId, file_system_id) | 147 service->GetProvidedFileSystem(kExtensionId, kFileSystemId) |
147 ->GetFileSystemInfo(); | 148 ->GetFileSystemInfo(); |
148 const std::string mount_point_name = | 149 const std::string mount_point_name = |
149 file_system_info.mount_path().BaseName().AsUTF8Unsafe(); | 150 file_system_info.mount_path().BaseName().AsUTF8Unsafe(); |
150 | 151 |
151 file_url_ = CreateFileSystemURL( | 152 file_url_ = CreateFileSystemURL( |
152 mount_point_name, base::FilePath::FromUTF8Unsafe("hello/world.txt")); | 153 mount_point_name, base::FilePath::FromUTF8Unsafe("hello/world.txt")); |
153 ASSERT_TRUE(file_url_.is_valid()); | 154 ASSERT_TRUE(file_url_.is_valid()); |
154 directory_url_ = CreateFileSystemURL( | 155 directory_url_ = CreateFileSystemURL( |
155 mount_point_name, base::FilePath::FromUTF8Unsafe("hello")); | 156 mount_point_name, base::FilePath::FromUTF8Unsafe("hello")); |
156 ASSERT_TRUE(directory_url_.is_valid()); | 157 ASSERT_TRUE(directory_url_.is_valid()); |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 CreateOperationContext(), | 411 CreateOperationContext(), |
411 file_url_, | 412 file_url_, |
412 base::Bind(&EventLogger::OnCreateSnapshotFile, logger.GetWeakPtr())); | 413 base::Bind(&EventLogger::OnCreateSnapshotFile, logger.GetWeakPtr())); |
413 | 414 |
414 ASSERT_TRUE(logger.error()); | 415 ASSERT_TRUE(logger.error()); |
415 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, *logger.error()); | 416 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, *logger.error()); |
416 } | 417 } |
417 | 418 |
418 } // namespace file_system_provider | 419 } // namespace file_system_provider |
419 } // namespace chromeos | 420 } // namespace chromeos |
OLD | NEW |