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 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 true /* writable */, | 44 true /* 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(FileSystemProviderOperationsDeleteEntryTest, Execute) { | 51 TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute) { |
| 52 using extensions::api::file_system_provider::DeleteEntryRequestedOptions; |
| 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 DeleteEntry delete_entry(NULL, | 57 DeleteEntry delete_entry(NULL, |
56 file_system_info_, | 58 file_system_info_, |
57 base::FilePath::FromUTF8Unsafe(kEntryPath), | 59 base::FilePath::FromUTF8Unsafe(kEntryPath), |
58 true /* recursive */, | 60 true /* recursive */, |
59 base::Bind(&util::LogStatusCallback, &callback_log)); | 61 base::Bind(&util::LogStatusCallback, &callback_log)); |
60 delete_entry.SetDispatchEventImplForTesting( | 62 delete_entry.SetDispatchEventImplForTesting( |
61 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 63 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
62 base::Unretained(&dispatcher))); | 64 base::Unretained(&dispatcher))); |
63 | 65 |
64 EXPECT_TRUE(delete_entry.Execute(kRequestId)); | 66 EXPECT_TRUE(delete_entry.Execute(kRequestId)); |
65 | 67 |
66 ASSERT_EQ(1u, dispatcher.events().size()); | 68 ASSERT_EQ(1u, dispatcher.events().size()); |
67 extensions::Event* event = dispatcher.events()[0]; | 69 extensions::Event* event = dispatcher.events()[0]; |
68 EXPECT_EQ( | 70 EXPECT_EQ( |
69 extensions::api::file_system_provider::OnDeleteEntryRequested::kEventName, | 71 extensions::api::file_system_provider::OnDeleteEntryRequested::kEventName, |
70 event->event_name); | 72 event->event_name); |
71 base::ListValue* event_args = event->event_args.get(); | 73 base::ListValue* event_args = event->event_args.get(); |
72 ASSERT_EQ(1u, event_args->GetSize()); | 74 ASSERT_EQ(1u, event_args->GetSize()); |
73 | 75 |
74 base::DictionaryValue* options = NULL; | 76 const base::DictionaryValue* options_as_value = NULL; |
75 ASSERT_TRUE(event_args->GetDictionary(0, &options)); | 77 ASSERT_TRUE(event_args->GetDictionary(0, &options_as_value)); |
76 | 78 |
77 std::string event_file_system_id; | 79 DeleteEntryRequestedOptions options; |
78 EXPECT_TRUE(options->GetString("fileSystemId", &event_file_system_id)); | 80 ASSERT_TRUE( |
79 EXPECT_EQ(kFileSystemId, event_file_system_id); | 81 DeleteEntryRequestedOptions::Populate(*options_as_value, &options)); |
80 | 82 EXPECT_EQ(kFileSystemId, options.file_system_id); |
81 int event_request_id = -1; | 83 EXPECT_EQ(kRequestId, options.request_id); |
82 EXPECT_TRUE(options->GetInteger("requestId", &event_request_id)); | 84 EXPECT_EQ(kEntryPath, options.entry_path); |
83 EXPECT_EQ(kRequestId, event_request_id); | 85 EXPECT_TRUE(options.recursive); |
84 | |
85 std::string event_entry_path; | |
86 EXPECT_TRUE(options->GetString("entryPath", &event_entry_path)); | |
87 EXPECT_EQ(kEntryPath, event_entry_path); | |
88 | |
89 bool event_recursive; | |
90 EXPECT_TRUE(options->GetBoolean("recursive", &event_recursive)); | |
91 EXPECT_TRUE(event_recursive); | |
92 } | 86 } |
93 | 87 |
94 TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute_NoListener) { | 88 TEST_F(FileSystemProviderOperationsDeleteEntryTest, Execute_NoListener) { |
95 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); | 89 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); |
96 util::StatusCallbackLog callback_log; | 90 util::StatusCallbackLog callback_log; |
97 | 91 |
98 DeleteEntry delete_entry(NULL, | 92 DeleteEntry delete_entry(NULL, |
99 file_system_info_, | 93 file_system_info_, |
100 base::FilePath::FromUTF8Unsafe(kEntryPath), | 94 base::FilePath::FromUTF8Unsafe(kEntryPath), |
101 true /* recursive */, | 95 true /* recursive */, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 delete_entry.OnError(kRequestId, | 164 delete_entry.OnError(kRequestId, |
171 scoped_ptr<RequestValue>(new RequestValue()), | 165 scoped_ptr<RequestValue>(new RequestValue()), |
172 base::File::FILE_ERROR_TOO_MANY_OPENED); | 166 base::File::FILE_ERROR_TOO_MANY_OPENED); |
173 ASSERT_EQ(1u, callback_log.size()); | 167 ASSERT_EQ(1u, callback_log.size()); |
174 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); | 168 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, callback_log[0]); |
175 } | 169 } |
176 | 170 |
177 } // namespace operations | 171 } // namespace operations |
178 } // namespace file_system_provider | 172 } // namespace file_system_provider |
179 } // namespace chromeos | 173 } // namespace chromeos |
OLD | NEW |