OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extensions/file_browser_handler_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_handler_api.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 .WillOnce(MockFileSelectorResponse(select_file_function.get(), false, | 189 .WillOnce(MockFileSelectorResponse(select_file_function.get(), false, |
190 FilePath())); | 190 FilePath())); |
191 | 191 |
192 FileHandlerSelectFileFunction::set_file_selector_for_test( | 192 FileHandlerSelectFileFunction::set_file_selector_for_test( |
193 mock_file_selector.get()); | 193 mock_file_selector.get()); |
194 | 194 |
195 select_file_function->set_has_callback(true); | 195 select_file_function->set_has_callback(true); |
196 select_file_function->set_user_gesture(true); | 196 select_file_function->set_user_gesture(true); |
197 | 197 |
198 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( | 198 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
199 utils::RunFunctionAndReturnResult( | 199 utils::RunFunctionAndReturnSingleResult( |
200 select_file_function.get(), | 200 select_file_function.get(), |
201 "[{\"suggestedName\": \"some_file_name.txt\"}]", | 201 "[{\"suggestedName\": \"some_file_name.txt\"}]", |
202 browser()))); | 202 browser()))); |
203 | 203 |
204 EXPECT_FALSE(utils::GetBoolean(result.get(), "success")); | 204 EXPECT_FALSE(utils::GetBoolean(result.get(), "success")); |
205 DictionaryValue* entry_info; | 205 DictionaryValue* entry_info; |
206 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); | 206 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); |
207 } | 207 } |
208 | 208 |
209 IN_PROC_BROWSER_TEST_F(FileBrowserHandlerTest, SuggestedFullPath) { | 209 IN_PROC_BROWSER_TEST_F(FileBrowserHandlerTest, SuggestedFullPath) { |
210 scoped_refptr<FileHandlerSelectFileFunction> select_file_function( | 210 scoped_refptr<FileHandlerSelectFileFunction> select_file_function( |
211 new FileHandlerSelectFileFunction()); | 211 new FileHandlerSelectFileFunction()); |
212 | 212 |
213 scoped_ptr<MockFileSelector> mock_file_selector(new MockFileSelector()); | 213 scoped_ptr<MockFileSelector> mock_file_selector(new MockFileSelector()); |
214 EXPECT_CALL(*mock_file_selector, | 214 EXPECT_CALL(*mock_file_selector, |
215 SelectFile(FilePath("some_file_name.txt"), _)) | 215 SelectFile(FilePath("some_file_name.txt"), _)) |
216 .WillOnce(MockFileSelectorResponse(select_file_function.get(), false, | 216 .WillOnce(MockFileSelectorResponse(select_file_function.get(), false, |
217 FilePath())); | 217 FilePath())); |
218 | 218 |
219 FileHandlerSelectFileFunction::set_file_selector_for_test( | 219 FileHandlerSelectFileFunction::set_file_selector_for_test( |
220 mock_file_selector.get()); | 220 mock_file_selector.get()); |
221 | 221 |
222 select_file_function->set_has_callback(true); | 222 select_file_function->set_has_callback(true); |
223 select_file_function->set_user_gesture(true); | 223 select_file_function->set_user_gesture(true); |
224 | 224 |
225 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( | 225 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( |
226 utils::RunFunctionAndReturnResult( | 226 utils::RunFunctionAndReturnSingleResult( |
227 select_file_function.get(), | 227 select_file_function.get(), |
228 "[{\"suggestedName\": \"/path_to_file/some_file_name.txt\"}]", | 228 "[{\"suggestedName\": \"/path_to_file/some_file_name.txt\"}]", |
229 browser()))); | 229 browser()))); |
230 | 230 |
231 EXPECT_FALSE(utils::GetBoolean(result.get(), "success")); | 231 EXPECT_FALSE(utils::GetBoolean(result.get(), "success")); |
232 DictionaryValue* entry_info; | 232 DictionaryValue* entry_info; |
233 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); | 233 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); |
234 } | 234 } |
235 | 235 |
OLD | NEW |