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/delete_entry.h
" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/delete_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 23 matching lines...) Expand all Loading... |
34 class FileSystemProviderOperationsDeleteEntryTest : public testing::Test { | 34 class FileSystemProviderOperationsDeleteEntryTest : public testing::Test { |
35 protected: | 35 protected: |
36 FileSystemProviderOperationsDeleteEntryTest() {} | 36 FileSystemProviderOperationsDeleteEntryTest() {} |
37 virtual ~FileSystemProviderOperationsDeleteEntryTest() {} | 37 virtual ~FileSystemProviderOperationsDeleteEntryTest() {} |
38 | 38 |
39 virtual void SetUp() OVERRIDE { | 39 virtual void SetUp() OVERRIDE { |
40 file_system_info_ = | 40 file_system_info_ = |
41 ProvidedFileSystemInfo(kExtensionId, | 41 ProvidedFileSystemInfo(kExtensionId, |
42 kFileSystemId, | 42 kFileSystemId, |
43 "" /* file_system_name */, | 43 "" /* file_system_name */, |
44 false /* writable */, | 44 true /* writable */, |
45 base::FilePath() /* mount_path */); | 45 base::FilePath() /* mount_path */); |
46 } | 46 } |
47 | 47 |
48 ProvidedFileSystemInfo file_system_info_; | 48 ProvidedFileSystemInfo file_system_info_; |
49 }; | 49 }; |
50 | 50 |
51 TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute) { | 51 TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute) { |
52 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 52 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
53 util::StatusCallbackLog callback_log; | 53 util::StatusCallbackLog callback_log; |
54 | 54 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 base::FilePath::FromUTF8Unsafe(kEntryPath), | 100 base::FilePath::FromUTF8Unsafe(kEntryPath), |
101 true /* recursive */, | 101 true /* recursive */, |
102 base::Bind(&util::LogStatusCallback, &callback_log)); | 102 base::Bind(&util::LogStatusCallback, &callback_log)); |
103 delete_entry.SetDispatchEventImplForTesting( | 103 delete_entry.SetDispatchEventImplForTesting( |
104 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 104 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
105 base::Unretained(&dispatcher))); | 105 base::Unretained(&dispatcher))); |
106 | 106 |
107 EXPECT_FALSE(delete_entry.Execute(kRequestId)); | 107 EXPECT_FALSE(delete_entry.Execute(kRequestId)); |
108 } | 108 } |
109 | 109 |
| 110 TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute_ReadOnly) { |
| 111 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 112 util::StatusCallbackLog callback_log; |
| 113 |
| 114 const ProvidedFileSystemInfo read_only_file_system_info( |
| 115 kExtensionId, |
| 116 kFileSystemId, |
| 117 "" /* file_system_name */, |
| 118 false /* writable */, |
| 119 base::FilePath() /* mount_path */); |
| 120 |
| 121 DeleteEntry delete_entry(NULL, |
| 122 read_only_file_system_info, |
| 123 base::FilePath::FromUTF8Unsafe(kEntryPath), |
| 124 true /* recursive */, |
| 125 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 126 delete_entry.SetDispatchEventImplForTesting( |
| 127 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| 128 base::Unretained(&dispatcher))); |
| 129 |
| 130 EXPECT_FALSE(delete_entry.Execute(kRequestId)); |
| 131 } |
| 132 |
110 TEST_F(FileSystemProviderOperationsDeleteEntryTest, OnSuccess) { | 133 TEST_F(FileSystemProviderOperationsDeleteEntryTest, OnSuccess) { |
111 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 134 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
112 util::StatusCallbackLog callback_log; | 135 util::StatusCallbackLog callback_log; |
113 | 136 |
114 DeleteEntry delete_entry(NULL, | 137 DeleteEntry delete_entry(NULL, |
115 file_system_info_, | 138 file_system_info_, |
116 base::FilePath::FromUTF8Unsafe(kEntryPath), | 139 base::FilePath::FromUTF8Unsafe(kEntryPath), |
117 true /* recursive */, | 140 true /* recursive */, |
118 base::Bind(&util::LogStatusCallback, &callback_log)); | 141 base::Bind(&util::LogStatusCallback, &callback_log)); |
119 delete_entry.SetDispatchEventImplForTesting( | 142 delete_entry.SetDispatchEventImplForTesting( |
(...skipping 27 matching lines...) Expand all Loading... |
147 delete_entry.OnError(kRequestId, | 170 delete_entry.OnError(kRequestId, |
148 scoped_ptr<RequestValue>(new RequestValue()), | 171 scoped_ptr<RequestValue>(new RequestValue()), |
149 base::File::FILE_ERROR_TOO_MANY_OPENED); | 172 base::File::FILE_ERROR_TOO_MANY_OPENED); |
150 ASSERT_EQ(1u, callback_log.size()); | 173 ASSERT_EQ(1u, callback_log.size()); |
151 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 174 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
152 } | 175 } |
153 | 176 |
154 } // namespace operations | 177 } // namespace operations |
155 } // namespace file_system_provider | 178 } // namespace file_system_provider |
156 } // namespace chromeos | 179 } // namespace chromeos |
OLD | NEW |