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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 base::FilePath::FromUTF8Unsafe(kSourcePath), | 101 base::FilePath::FromUTF8Unsafe(kSourcePath), |
102 base::FilePath::FromUTF8Unsafe(kTargetPath), | 102 base::FilePath::FromUTF8Unsafe(kTargetPath), |
103 base::Bind(&util::LogStatusCallback, &callback_log)); | 103 base::Bind(&util::LogStatusCallback, &callback_log)); |
104 move_entry.SetDispatchEventImplForTesting( | 104 move_entry.SetDispatchEventImplForTesting( |
105 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 105 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
106 base::Unretained(&dispatcher))); | 106 base::Unretained(&dispatcher))); |
107 | 107 |
108 EXPECT_FALSE(move_entry.Execute(kRequestId)); | 108 EXPECT_FALSE(move_entry.Execute(kRequestId)); |
109 } | 109 } |
110 | 110 |
| 111 TEST_F(FileSystemProviderOperationsMoveEntryTest, Execute_ReadOnly) { |
| 112 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 113 util::StatusCallbackLog callback_log; |
| 114 |
| 115 const ProvidedFileSystemInfo read_only_file_system_info( |
| 116 kExtensionId, |
| 117 kFileSystemId, |
| 118 "" /* file_system_name */, |
| 119 false /* writable */, |
| 120 base::FilePath() /* mount_path */); |
| 121 |
| 122 MoveEntry move_entry(NULL, |
| 123 read_only_file_system_info, |
| 124 base::FilePath::FromUTF8Unsafe(kSourcePath), |
| 125 base::FilePath::FromUTF8Unsafe(kTargetPath), |
| 126 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 127 move_entry.SetDispatchEventImplForTesting( |
| 128 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| 129 base::Unretained(&dispatcher))); |
| 130 |
| 131 EXPECT_FALSE(move_entry.Execute(kRequestId)); |
| 132 } |
| 133 |
111 TEST_F(FileSystemProviderOperationsMoveEntryTest, OnSuccess) { | 134 TEST_F(FileSystemProviderOperationsMoveEntryTest, OnSuccess) { |
112 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 135 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
113 util::StatusCallbackLog callback_log; | 136 util::StatusCallbackLog callback_log; |
114 | 137 |
115 MoveEntry move_entry(NULL, | 138 MoveEntry move_entry(NULL, |
116 file_system_info_, | 139 file_system_info_, |
117 base::FilePath::FromUTF8Unsafe(kSourcePath), | 140 base::FilePath::FromUTF8Unsafe(kSourcePath), |
118 base::FilePath::FromUTF8Unsafe(kTargetPath), | 141 base::FilePath::FromUTF8Unsafe(kTargetPath), |
119 base::Bind(&util::LogStatusCallback, &callback_log)); | 142 base::Bind(&util::LogStatusCallback, &callback_log)); |
120 move_entry.SetDispatchEventImplForTesting( | 143 move_entry.SetDispatchEventImplForTesting( |
(...skipping 27 matching lines...) Expand all Loading... |
148 move_entry.OnError(kRequestId, | 171 move_entry.OnError(kRequestId, |
149 scoped_ptr<RequestValue>(new RequestValue()), | 172 scoped_ptr<RequestValue>(new RequestValue()), |
150 base::File::FILE_ERROR_TOO_MANY_OPENED); | 173 base::File::FILE_ERROR_TOO_MANY_OPENED); |
151 ASSERT_EQ(1u, callback_log.size()); | 174 ASSERT_EQ(1u, callback_log.size()); |
152 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 175 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
153 } | 176 } |
154 | 177 |
155 } // namespace operations | 178 } // namespace operations |
156 } // namespace file_system_provider | 179 } // namespace file_system_provider |
157 } // namespace chromeos | 180 } // namespace chromeos |
OLD | NEW |