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/abort.h" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/abort.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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 kFileSystemId, | 42 kFileSystemId, |
43 "" /* file_system_name */, | 43 "" /* file_system_name */, |
44 false /* writable */, | 44 false /* 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(FileSystemProviderOperationsAbortTest, Execute) { | 51 TEST_F(FileSystemProviderOperationsAbortTest, Execute) { |
| 52 using extensions::api::file_system_provider::AbortRequestedOptions; |
| 53 |
52 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 54 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
53 util::StatusCallbackLog callback_log; | 55 util::StatusCallbackLog callback_log; |
54 | 56 |
55 Abort abort(NULL, | 57 Abort abort(NULL, |
56 file_system_info_, | 58 file_system_info_, |
57 kOperationRequestId, | 59 kOperationRequestId, |
58 base::Bind(&util::LogStatusCallback, &callback_log)); | 60 base::Bind(&util::LogStatusCallback, &callback_log)); |
59 abort.SetDispatchEventImplForTesting( | 61 abort.SetDispatchEventImplForTesting( |
60 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 62 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
61 base::Unretained(&dispatcher))); | 63 base::Unretained(&dispatcher))); |
62 | 64 |
63 EXPECT_TRUE(abort.Execute(kRequestId)); | 65 EXPECT_TRUE(abort.Execute(kRequestId)); |
64 | 66 |
65 ASSERT_EQ(1u, dispatcher.events().size()); | 67 ASSERT_EQ(1u, dispatcher.events().size()); |
66 extensions::Event* event = dispatcher.events()[0]; | 68 extensions::Event* event = dispatcher.events()[0]; |
67 EXPECT_EQ(extensions::api::file_system_provider::OnAbortRequested::kEventName, | 69 EXPECT_EQ(extensions::api::file_system_provider::OnAbortRequested::kEventName, |
68 event->event_name); | 70 event->event_name); |
69 base::ListValue* event_args = event->event_args.get(); | 71 base::ListValue* event_args = event->event_args.get(); |
70 ASSERT_EQ(1u, event_args->GetSize()); | 72 ASSERT_EQ(1u, event_args->GetSize()); |
71 | 73 |
72 base::DictionaryValue* options = NULL; | 74 const base::DictionaryValue* options_as_value = NULL; |
73 ASSERT_TRUE(event_args->GetDictionary(0, &options)); | 75 ASSERT_TRUE(event_args->GetDictionary(0, &options_as_value)); |
74 | 76 |
75 std::string event_file_system_id; | 77 AbortRequestedOptions options; |
76 EXPECT_TRUE(options->GetString("fileSystemId", &event_file_system_id)); | 78 ASSERT_TRUE(AbortRequestedOptions::Populate(*options_as_value, &options)); |
77 EXPECT_EQ(kFileSystemId, event_file_system_id); | 79 EXPECT_EQ(kFileSystemId, options.file_system_id); |
78 | 80 EXPECT_EQ(kRequestId, options.request_id); |
79 int event_request_id = -1; | 81 EXPECT_EQ(kOperationRequestId, options.operation_request_id); |
80 EXPECT_TRUE(options->GetInteger("requestId", &event_request_id)); | |
81 EXPECT_EQ(kRequestId, event_request_id); | |
82 | |
83 int event_operation_request_id; | |
84 EXPECT_TRUE( | |
85 options->GetInteger("operationRequestId", &event_operation_request_id)); | |
86 EXPECT_EQ(kOperationRequestId, event_operation_request_id); | |
87 } | 82 } |
88 | 83 |
89 TEST_F(FileSystemProviderOperationsAbortTest, Execute_NoListener) { | 84 TEST_F(FileSystemProviderOperationsAbortTest, Execute_NoListener) { |
90 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); | 85 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); |
91 util::StatusCallbackLog callback_log; | 86 util::StatusCallbackLog callback_log; |
92 | 87 |
93 Abort abort(NULL, | 88 Abort abort(NULL, |
94 file_system_info_, | 89 file_system_info_, |
95 kOperationRequestId, | 90 kOperationRequestId, |
96 base::Bind(&util::LogStatusCallback, &callback_log)); | 91 base::Bind(&util::LogStatusCallback, &callback_log)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 abort.OnError(kRequestId, | 134 abort.OnError(kRequestId, |
140 scoped_ptr<RequestValue>(new RequestValue()), | 135 scoped_ptr<RequestValue>(new RequestValue()), |
141 base::File::FILE_ERROR_TOO_MANY_OPENED); | 136 base::File::FILE_ERROR_TOO_MANY_OPENED); |
142 ASSERT_EQ(1u, callback_log.size()); | 137 ASSERT_EQ(1u, callback_log.size()); |
143 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 138 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
144 } | 139 } |
145 | 140 |
146 } // namespace operations | 141 } // namespace operations |
147 } // namespace file_system_provider | 142 } // namespace file_system_provider |
148 } // namespace chromeos | 143 } // namespace chromeos |
OLD | NEW |