| 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 <memory> |
| 7 #include <string> | 8 #include <string> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/files/file.h" | 11 #include "base/files/file.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "chrome/browser/chromeos/file_system_provider/operations/test_util.h" | 13 #include "chrome/browser/chromeos/file_system_provider/operations/test_util.h" |
| 14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" | 14 #include "chrome/browser/chromeos/file_system_provider/provided_file_system_inte
rface.h" |
| 15 #include "chrome/common/extensions/api/file_system_provider.h" | 15 #include "chrome/common/extensions/api/file_system_provider.h" |
| 16 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" | 16 #include "chrome/common/extensions/api/file_system_provider_capabilities/file_sy
stem_provider_capabilities_handler.h" |
| 17 #include "chrome/common/extensions/api/file_system_provider_internal.h" | 17 #include "chrome/common/extensions/api/file_system_provider_internal.h" |
| 18 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 19 #include "storage/browser/fileapi/async_file_util.h" | 19 #include "storage/browser/fileapi/async_file_util.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 | 21 |
| 22 namespace chromeos { | 22 namespace chromeos { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 DeleteEntry delete_entry(NULL, file_system_info_, base::FilePath(kEntryPath), | 123 DeleteEntry delete_entry(NULL, file_system_info_, base::FilePath(kEntryPath), |
| 124 true /* recursive */, | 124 true /* recursive */, |
| 125 base::Bind(&util::LogStatusCallback, &callback_log)); | 125 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 126 delete_entry.SetDispatchEventImplForTesting( | 126 delete_entry.SetDispatchEventImplForTesting( |
| 127 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 127 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| 128 base::Unretained(&dispatcher))); | 128 base::Unretained(&dispatcher))); |
| 129 | 129 |
| 130 EXPECT_TRUE(delete_entry.Execute(kRequestId)); | 130 EXPECT_TRUE(delete_entry.Execute(kRequestId)); |
| 131 | 131 |
| 132 delete_entry.OnSuccess(kRequestId, | 132 delete_entry.OnSuccess(kRequestId, |
| 133 scoped_ptr<RequestValue>(new RequestValue()), | 133 std::unique_ptr<RequestValue>(new RequestValue()), |
| 134 false /* has_more */); | 134 false /* has_more */); |
| 135 ASSERT_EQ(1u, callback_log.size()); | 135 ASSERT_EQ(1u, callback_log.size()); |
| 136 EXPECT_EQ(base::File::FILE_OK, callback_log[0]); | 136 EXPECT_EQ(base::File::FILE_OK, callback_log[0]); |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST_F(FileSystemProviderOperationsDeleteEntryTest, OnError) { | 139 TEST_F(FileSystemProviderOperationsDeleteEntryTest, OnError) { |
| 140 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 140 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 141 util::StatusCallbackLog callback_log; | 141 util::StatusCallbackLog callback_log; |
| 142 | 142 |
| 143 DeleteEntry delete_entry(NULL, file_system_info_, base::FilePath(kEntryPath), | 143 DeleteEntry delete_entry(NULL, file_system_info_, base::FilePath(kEntryPath), |
| 144 true /* recursive */, | 144 true /* recursive */, |
| 145 base::Bind(&util::LogStatusCallback, &callback_log)); | 145 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 146 delete_entry.SetDispatchEventImplForTesting( | 146 delete_entry.SetDispatchEventImplForTesting( |
| 147 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 147 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| 148 base::Unretained(&dispatcher))); | 148 base::Unretained(&dispatcher))); |
| 149 | 149 |
| 150 EXPECT_TRUE(delete_entry.Execute(kRequestId)); | 150 EXPECT_TRUE(delete_entry.Execute(kRequestId)); |
| 151 | 151 |
| 152 delete_entry.OnError(kRequestId, | 152 delete_entry.OnError(kRequestId, |
| 153 scoped_ptr<RequestValue>(new RequestValue()), | 153 std::unique_ptr<RequestValue>(new RequestValue()), |
| 154 base::File::FILE_ERROR_TOO_MANY_OPENED); | 154 base::File::FILE_ERROR_TOO_MANY_OPENED); |
| 155 ASSERT_EQ(1u, callback_log.size()); | 155 ASSERT_EQ(1u, callback_log.size()); |
| 156 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 156 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
| 157 } | 157 } |
| 158 | 158 |
| 159 } // namespace operations | 159 } // namespace operations |
| 160 } // namespace file_system_provider | 160 } // namespace file_system_provider |
| 161 } // namespace chromeos | 161 } // namespace chromeos |
| OLD | NEW |