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/get_metadata.h
" | 5 #include "chrome/browser/chromeos/file_system_provider/operations/get_metadata.h
" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/files/file.h" | 9 #include "base/files/file.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 kFileSystemId, | 82 kFileSystemId, |
83 "" /* display_name */, | 83 "" /* display_name */, |
84 false /* writable */, | 84 false /* writable */, |
85 base::FilePath() /* mount_path */); | 85 base::FilePath() /* mount_path */); |
86 } | 86 } |
87 | 87 |
88 ProvidedFileSystemInfo file_system_info_; | 88 ProvidedFileSystemInfo file_system_info_; |
89 }; | 89 }; |
90 | 90 |
91 TEST_F(FileSystemProviderOperationsGetMetadataTest, Execute) { | 91 TEST_F(FileSystemProviderOperationsGetMetadataTest, Execute) { |
| 92 using extensions::api::file_system_provider::GetMetadataRequestedOptions; |
| 93 |
92 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); | 94 util::LoggingDispatchEventImpl dispatcher(true /* dispatch_reply */); |
93 CallbackLogger callback_logger; | 95 CallbackLogger callback_logger; |
94 | 96 |
95 GetMetadata get_metadata( | 97 GetMetadata get_metadata( |
96 NULL, | 98 NULL, |
97 file_system_info_, | 99 file_system_info_, |
98 base::FilePath::FromUTF8Unsafe(kDirectoryPath), | 100 base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
99 ProvidedFileSystemInterface::METADATA_FIELD_THUMBNAIL, | 101 ProvidedFileSystemInterface::METADATA_FIELD_THUMBNAIL, |
100 base::Bind(&CallbackLogger::OnGetMetadata, | 102 base::Bind(&CallbackLogger::OnGetMetadata, |
101 base::Unretained(&callback_logger))); | 103 base::Unretained(&callback_logger))); |
102 get_metadata.SetDispatchEventImplForTesting( | 104 get_metadata.SetDispatchEventImplForTesting( |
103 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, | 105 base::Bind(&util::LoggingDispatchEventImpl::OnDispatchEventImpl, |
104 base::Unretained(&dispatcher))); | 106 base::Unretained(&dispatcher))); |
105 | 107 |
106 EXPECT_TRUE(get_metadata.Execute(kRequestId)); | 108 EXPECT_TRUE(get_metadata.Execute(kRequestId)); |
107 | 109 |
108 ASSERT_EQ(1u, dispatcher.events().size()); | 110 ASSERT_EQ(1u, dispatcher.events().size()); |
109 extensions::Event* event = dispatcher.events()[0]; | 111 extensions::Event* event = dispatcher.events()[0]; |
110 EXPECT_EQ( | 112 EXPECT_EQ( |
111 extensions::api::file_system_provider::OnGetMetadataRequested::kEventName, | 113 extensions::api::file_system_provider::OnGetMetadataRequested::kEventName, |
112 event->event_name); | 114 event->event_name); |
113 base::ListValue* event_args = event->event_args.get(); | 115 base::ListValue* event_args = event->event_args.get(); |
114 ASSERT_EQ(1u, event_args->GetSize()); | 116 ASSERT_EQ(1u, event_args->GetSize()); |
115 | 117 |
116 base::DictionaryValue* options = NULL; | 118 const base::DictionaryValue* options_as_value = NULL; |
117 ASSERT_TRUE(event_args->GetDictionary(0, &options)); | 119 ASSERT_TRUE(event_args->GetDictionary(0, &options_as_value)); |
118 | 120 |
119 std::string event_file_system_id; | 121 GetMetadataRequestedOptions options; |
120 EXPECT_TRUE(options->GetString("fileSystemId", &event_file_system_id)); | 122 ASSERT_TRUE( |
121 EXPECT_EQ(kFileSystemId, event_file_system_id); | 123 GetMetadataRequestedOptions::Populate(*options_as_value, &options)); |
122 | 124 EXPECT_EQ(kFileSystemId, options.file_system_id); |
123 int event_request_id = -1; | 125 EXPECT_EQ(kRequestId, options.request_id); |
124 EXPECT_TRUE(options->GetInteger("requestId", &event_request_id)); | 126 EXPECT_EQ(kDirectoryPath, options.entry_path); |
125 EXPECT_EQ(kRequestId, event_request_id); | 127 EXPECT_TRUE(options.thumbnail); |
126 | |
127 std::string event_entry_path; | |
128 EXPECT_TRUE(options->GetString("entryPath", &event_entry_path)); | |
129 EXPECT_EQ(kDirectoryPath, event_entry_path); | |
130 | |
131 bool event_thumbnail; | |
132 EXPECT_TRUE(options->GetBoolean("thumbnail", &event_thumbnail)); | |
133 EXPECT_TRUE(event_thumbnail); | |
134 } | 128 } |
135 | 129 |
136 TEST_F(FileSystemProviderOperationsGetMetadataTest, Execute_NoListener) { | 130 TEST_F(FileSystemProviderOperationsGetMetadataTest, Execute_NoListener) { |
137 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); | 131 util::LoggingDispatchEventImpl dispatcher(false /* dispatch_reply */); |
138 CallbackLogger callback_logger; | 132 CallbackLogger callback_logger; |
139 | 133 |
140 GetMetadata get_metadata( | 134 GetMetadata get_metadata( |
141 NULL, | 135 NULL, |
142 file_system_info_, | 136 file_system_info_, |
143 base::FilePath::FromUTF8Unsafe(kDirectoryPath), | 137 base::FilePath::FromUTF8Unsafe(kDirectoryPath), |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 base::File::FILE_ERROR_TOO_MANY_OPENED); | 305 base::File::FILE_ERROR_TOO_MANY_OPENED); |
312 | 306 |
313 ASSERT_EQ(1u, callback_logger.events().size()); | 307 ASSERT_EQ(1u, callback_logger.events().size()); |
314 CallbackLogger::Event* event = callback_logger.events()[0]; | 308 CallbackLogger::Event* event = callback_logger.events()[0]; |
315 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); | 309 EXPECT_EQ(base::File::FILE_ERROR_TOO_MANY_OPENED, event->result()); |
316 } | 310 } |
317 | 311 |
318 } // namespace operations | 312 } // namespace operations |
319 } // namespace file_system_provider | 313 } // namespace file_system_provider |
320 } // namespace chromeos | 314 } // namespace chromeos |
OLD | NEW |