| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/configure.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/configure.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 "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 namespace chromeos { | 21 namespace chromeos { |
| 22 namespace file_system_provider { | 22 namespace file_system_provider { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 util::StatusCallbackLog callback_log; | 93 util::StatusCallbackLog callback_log; |
| 94 | 94 |
| 95 Configure configure(NULL, file_system_info_, | 95 Configure configure(NULL, file_system_info_, |
| 96 base::Bind(&util::LogStatusCallback, &callback_log)); | 96 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 97 configure.SetDispatchEventImplForTesting( | 97 configure.SetDispatchEventImplForTesting( |
| 98 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 98 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| 99 base::Unretained(&dispatcher))); | 99 base::Unretained(&dispatcher))); |
| 100 | 100 |
| 101 EXPECT_TRUE(configure.Execute(kRequestId)); | 101 EXPECT_TRUE(configure.Execute(kRequestId)); |
| 102 | 102 |
| 103 configure.OnSuccess(kRequestId, scoped_ptr<RequestValue>(new RequestValue()), | 103 configure.OnSuccess(kRequestId, |
| 104 std::unique_ptr<RequestValue>(new RequestValue()), |
| 104 false /* has_more */); | 105 false /* has_more */); |
| 105 ASSERT_EQ(1u, callback_log.size()); | 106 ASSERT_EQ(1u, callback_log.size()); |
| 106 base::File::Error event_result = callback_log[0]; | 107 base::File::Error event_result = callback_log[0]; |
| 107 EXPECT_EQ(base::File::FILE_OK, event_result); | 108 EXPECT_EQ(base::File::FILE_OK, event_result); |
| 108 } | 109 } |
| 109 | 110 |
| 110 TEST_F(FileSystemProviderOperationsConfigureTest, OnError) { | 111 TEST_F(FileSystemProviderOperationsConfigureTest, OnError) { |
| 111 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 112 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 112 util::StatusCallbackLog callback_log; | 113 util::StatusCallbackLog callback_log; |
| 113 | 114 |
| 114 Configure configure(NULL, file_system_info_, | 115 Configure configure(NULL, file_system_info_, |
| 115 base::Bind(&util::LogStatusCallback, &callback_log)); | 116 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 116 configure.SetDispatchEventImplForTesting( | 117 configure.SetDispatchEventImplForTesting( |
| 117 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 118 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| 118 base::Unretained(&dispatcher))); | 119 base::Unretained(&dispatcher))); |
| 119 | 120 |
| 120 EXPECT_TRUE(configure.Execute(kRequestId)); | 121 EXPECT_TRUE(configure.Execute(kRequestId)); |
| 121 | 122 |
| 122 configure.OnError(kRequestId, scoped_ptr<RequestValue>(new RequestValue()), | 123 configure.OnError(kRequestId, |
| 124 std::unique_ptr<RequestValue>(new RequestValue()), |
| 123 base::File::FILE_ERROR_NOT_FOUND); | 125 base::File::FILE_ERROR_NOT_FOUND); |
| 124 ASSERT_EQ(1u, callback_log.size()); | 126 ASSERT_EQ(1u, callback_log.size()); |
| 125 base::File::Error event_result = callback_log[0]; | 127 base::File::Error event_result = callback_log[0]; |
| 126 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, event_result); | 128 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, event_result); |
| 127 } | 129 } |
| 128 | 130 |
| 129 } // namespace operations | 131 } // namespace operations |
| 130 } // namespace file_system_provider | 132 } // namespace file_system_provider |
| 131 } // namespace chromeos | 133 } // namespace chromeos |
| OLD | NEW |