| 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 19 matching lines...) Expand all Loading... |
| 30 const base::FilePath::CharType kEntryPath[] = "/kitty/and/puppy/happy"; | 30 const base::FilePath::CharType kEntryPath[] = "/kitty/and/puppy/happy"; |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 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 MountOptions mount_options(kFileSystemId, "" /* display_name */); |
| 41 mount_options.writable = true; |
| 40 file_system_info_ = | 42 file_system_info_ = |
| 41 ProvidedFileSystemInfo(kExtensionId, | 43 ProvidedFileSystemInfo(kExtensionId, mount_options, base::FilePath()); |
| 42 kFileSystemId, | |
| 43 "" /* file_system_name */, | |
| 44 true /* writable */, | |
| 45 false /* supports_notify_tag */, | |
| 46 base::FilePath() /* mount_path */); | |
| 47 } | 44 } |
| 48 | 45 |
| 49 ProvidedFileSystemInfo file_system_info_; | 46 ProvidedFileSystemInfo file_system_info_; |
| 50 }; | 47 }; |
| 51 | 48 |
| 52 TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute) { | 49 TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute) { |
| 53 using extensions::api::file_system_provider::DeleteEntryRequestedOptions; | 50 using extensions::api::file_system_provider::DeleteEntryRequestedOptions; |
| 54 | 51 |
| 55 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 52 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 56 util::StatusCallbackLog callback_log; | 53 util::StatusCallbackLog callback_log; |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 98 |
| 102 EXPECT_FALSE(delete_entry.Execute(kRequestId)); | 99 EXPECT_FALSE(delete_entry.Execute(kRequestId)); |
| 103 } | 100 } |
| 104 | 101 |
| 105 TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute_ReadOnly) { | 102 TEST_F(FileSystemProviderOperationsDeleteEntryTest, 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 DeleteEntry delete_entry(NULL, | 111 DeleteEntry delete_entry(NULL, |
| 118 read_only_file_system_info, | 112 read_only_file_system_info, |
| 119 base::FilePath::FromUTF8Unsafe(kEntryPath), | 113 base::FilePath::FromUTF8Unsafe(kEntryPath), |
| 120 true /* recursive */, | 114 true /* recursive */, |
| 121 base::Bind(&util::LogStatusCallback, &callback_log)); | 115 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 122 delete_entry.SetDispatchEventImplForTesting( | 116 delete_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 delete_entry.OnError(kRequestId, | 160 delete_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 |