| 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/unmount.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/unmount.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 28 matching lines...) Expand all Loading... |
| 39 kFileSystemId, | 39 kFileSystemId, |
| 40 "" /* display_name */, | 40 "" /* display_name */, |
| 41 false /* writable */, | 41 false /* writable */, |
| 42 base::FilePath() /* mount_path */); | 42 base::FilePath() /* mount_path */); |
| 43 } | 43 } |
| 44 | 44 |
| 45 ProvidedFileSystemInfo file_system_info_; | 45 ProvidedFileSystemInfo file_system_info_; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 TEST_F(FileSystemProviderOperationsUnmountTest, Execute) { | 48 TEST_F(FileSystemProviderOperationsUnmountTest, Execute) { |
| 49 using extensions::api::file_system_provider::UnmountRequestedOptions; |
| 50 |
| 49 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 51 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
| 50 util::StatusCallbackLog callback_log; | 52 util::StatusCallbackLog callback_log; |
| 51 | 53 |
| 52 Unmount unmount(NULL, | 54 Unmount unmount(NULL, |
| 53 file_system_info_, | 55 file_system_info_, |
| 54 base::Bind(&util::LogStatusCallback, &callback_log)); | 56 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 55 unmount.SetDispatchEventImplForTesting( | 57 unmount.SetDispatchEventImplForTesting( |
| 56 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 58 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
| 57 base::Unretained(&dispatcher))); | 59 base::Unretained(&dispatcher))); |
| 58 | 60 |
| 59 EXPECT_TRUE(unmount.Execute(kRequestId)); | 61 EXPECT_TRUE(unmount.Execute(kRequestId)); |
| 60 | 62 |
| 61 ASSERT_EQ(1u, dispatcher.events().size()); | 63 ASSERT_EQ(1u, dispatcher.events().size()); |
| 62 extensions::Event* event = dispatcher.events()[0]; | 64 extensions::Event* event = dispatcher.events()[0]; |
| 63 EXPECT_EQ( | 65 EXPECT_EQ( |
| 64 extensions::api::file_system_provider::OnUnmountRequested::kEventName, | 66 extensions::api::file_system_provider::OnUnmountRequested::kEventName, |
| 65 event->event_name); | 67 event->event_name); |
| 66 base::ListValue* event_args = event->event_args.get(); | 68 base::ListValue* event_args = event->event_args.get(); |
| 67 ASSERT_EQ(1u, event_args->GetSize()); | 69 ASSERT_EQ(1u, event_args->GetSize()); |
| 68 | 70 |
| 69 base::DictionaryValue* options = NULL; | 71 const base::DictionaryValue* options_as_value = NULL; |
| 70 ASSERT_TRUE(event_args->GetDictionary(0, &options)); | 72 ASSERT_TRUE(event_args->GetDictionary(0, &options_as_value)); |
| 71 | 73 |
| 72 std::string event_file_system_id; | 74 UnmountRequestedOptions options; |
| 73 EXPECT_TRUE(options->GetString("fileSystemId", &event_file_system_id)); | 75 ASSERT_TRUE(UnmountRequestedOptions::Populate(*options_as_value, &options)); |
| 74 EXPECT_EQ(kFileSystemId, event_file_system_id); | 76 EXPECT_EQ(kFileSystemId, options.file_system_id); |
| 75 | 77 EXPECT_EQ(kRequestId, options.request_id); |
| 76 int event_request_id = -1; | |
| 77 EXPECT_TRUE(options->GetInteger("requestId", &event_request_id)); | |
| 78 EXPECT_EQ(kRequestId, event_request_id); | |
| 79 } | 78 } |
| 80 | 79 |
| 81 TEST_F(FileSystemProviderOperationsUnmountTest, Execute_NoListener) { | 80 TEST_F(FileSystemProviderOperationsUnmountTest, Execute_NoListener) { |
| 82 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); | 81 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); |
| 83 util::StatusCallbackLog callback_log; | 82 util::StatusCallbackLog callback_log; |
| 84 | 83 |
| 85 Unmount unmount(NULL, | 84 Unmount unmount(NULL, |
| 86 file_system_info_, | 85 file_system_info_, |
| 87 base::Bind(&util::LogStatusCallback, &callback_log)); | 86 base::Bind(&util::LogStatusCallback, &callback_log)); |
| 88 unmount.SetDispatchEventImplForTesting( | 87 unmount.SetDispatchEventImplForTesting( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 scoped_ptr<RequestValue>(new RequestValue()), | 132 scoped_ptr<RequestValue>(new RequestValue()), |
| 134 base::File::FILE_ERROR_NOT_FOUND); | 133 base::File::FILE_ERROR_NOT_FOUND); |
| 135 ASSERT_EQ(1u, callback_log.size()); | 134 ASSERT_EQ(1u, callback_log.size()); |
| 136 base::File::Error event_result = callback_log[0]; | 135 base::File::Error event_result = callback_log[0]; |
| 137 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, event_result); | 136 EXPECT_EQ(base::File::FILE_ERROR_NOT_FOUND, event_result); |
| 138 } | 137 } |
| 139 | 138 |
| 140 } // namespace operations | 139 } // namespace operations |
| 141 } // namespace file_system_provider | 140 } // namespace file_system_provider |
| 142 } // namespace chromeos | 141 } // namespace chromeos |
| OLD | NEW |