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 "chrome/browser/chromeos/file_system_provider/operations/move_entry.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/move_entry.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 const base::FilePath::CharType kTargetPath[] = "/kitty/and/puppy/happy"; | 31 const base::FilePath::CharType kTargetPath[] = "/kitty/and/puppy/happy"; |
32 | 32 |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 class FileSystemProviderOperationsMoveEntryTest : public testing::Test { | 35 class FileSystemProviderOperationsMoveEntryTest : public testing::Test { |
36 protected: | 36 protected: |
37 FileSystemProviderOperationsMoveEntryTest() {} | 37 FileSystemProviderOperationsMoveEntryTest() {} |
38 virtual ~FileSystemProviderOperationsMoveEntryTest() {} | 38 virtual ~FileSystemProviderOperationsMoveEntryTest() {} |
39 | 39 |
40 virtual void SetUp() override { | 40 virtual void SetUp() override { |
| 41 MountOptions mount_options(kFileSystemId, "" /* display_name */); |
| 42 mount_options.writable = true; |
41 file_system_info_ = | 43 file_system_info_ = |
42 ProvidedFileSystemInfo(kExtensionId, | 44 ProvidedFileSystemInfo(kExtensionId, mount_options, base::FilePath()); |
43 kFileSystemId, | |
44 "" /* file_system_name */, | |
45 true /* writable */, | |
46 false /* supports_notify_tag */, | |
47 base::FilePath() /* mount_path */); | |
48 } | 45 } |
49 | 46 |
50 ProvidedFileSystemInfo file_system_info_; | 47 ProvidedFileSystemInfo file_system_info_; |
51 }; | 48 }; |
52 | 49 |
53 TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute) { | 50 TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute) { |
54 using extensions::api::file_system_provider::MoveEntryRequestedOptions; | 51 using extensions::api::file_system_provider::MoveEntryRequestedOptions; |
55 | 52 |
56 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 53 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
57 util::StatusCallbackLog callback_log; | 54 util::StatusCallbackLog callback_log; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 98 |
102 EXPECT_FALSE(move_entry.Execute(kRequestId)); | 99 EXPECT_FALSE(move_entry.Execute(kRequestId)); |
103 } | 100 } |
104 | 101 |
105 TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute_ReadOnly) { | 102 TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute_ReadOnly) { |
106 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 103 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
107 util::StatusCallbackLog callback_log; | 104 util::StatusCallbackLog callback_log; |
108 | 105 |
109 const ProvidedFileSystemInfo read_only_file_system_info( | 106 const ProvidedFileSystemInfo read_only_file_system_info( |
110 kExtensionId, | 107 kExtensionId, |
111 kFileSystemId, | 108 MountOptions(kFileSystemId, "" /* display_name */), |
112 "" /* file_system_name */, | |
113 false /* writable */, | |
114 false /* supports_notify_tag */, | |
115 base::FilePath() /* mount_path */); | 109 base::FilePath() /* mount_path */); |
116 | 110 |
117 MoveEntry move_entry(NULL, | 111 MoveEntry move_entry(NULL, |
118 read_only_file_system_info, | 112 read_only_file_system_info, |
119 base::FilePath::FromUTF8Unsafe(kSourcePath), | 113 base::FilePath::FromUTF8Unsafe(kSourcePath), |
120 base::FilePath::FromUTF8Unsafe(kTargetPath), | 114 base::FilePath::FromUTF8Unsafe(kTargetPath), |
121 base::Bind(&util::LogStatusCallback, &callback_log)); | 115 base::Bind(&util::LogStatusCallback, &callback_log)); |
122 move_entry.SetDispatchEventImplForTesting( | 116 move_entry.SetDispatchEventImplForTesting( |
123 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 117 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
124 base::Unretained(&dispatcher))); | 118 base::Unretained(&dispatcher))); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 move_entry.OnError(kRequestId, | 160 move_entry.OnError(kRequestId, |
167 scoped_ptr<RequestValue>(new RequestValue()), | 161 scoped_ptr<RequestValue>(new RequestValue()), |
168 base::File::FILE_ERROR_TOO_MANY_OPENED); | 162 base::File::FILE_ERROR_TOO_MANY_OPENED); |
169 ASSERT_EQ(1u, callback_log.size()); | 163 ASSERT_EQ(1u, callback_log.size()); |
170 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 164 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
171 } | 165 } |
172 | 166 |
173 } // namespace operations | 167 } // namespace operations |
174 } // namespace file_system_provider | 168 } // namespace file_system_provider |
175 } // namespace chromeos | 169 } // namespace chromeos |
OLD | NEW |