| 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 // File contains browser tests for the fileBrowserHandler api. | 5 // File contains browser tests for the fileBrowserHandler api. |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handler_a
pi.h" | 7 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_handler_a
pi.h" |
| 8 | 8 |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 | 10 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 | 333 |
| 334 scoped_refptr<FileBrowserHandlerInternalSelectFileFunction> | 334 scoped_refptr<FileBrowserHandlerInternalSelectFileFunction> |
| 335 select_file_function( | 335 select_file_function( |
| 336 new FileBrowserHandlerInternalSelectFileFunction( | 336 new FileBrowserHandlerInternalSelectFileFunction( |
| 337 new MockFileSelectorFactory(test_case), | 337 new MockFileSelectorFactory(test_case), |
| 338 false)); | 338 false)); |
| 339 | 339 |
| 340 select_file_function->set_has_callback(true); | 340 select_file_function->set_has_callback(true); |
| 341 select_file_function->set_user_gesture(true); | 341 select_file_function->set_user_gesture(true); |
| 342 | 342 |
| 343 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( | 343 std::unique_ptr<base::DictionaryValue> result( |
| 344 utils::RunFunctionAndReturnSingleResult( | 344 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
| 345 select_file_function.get(), | 345 select_file_function.get(), |
| 346 "[{\"suggestedName\": \"some_file_name.txt\"}]", | 346 "[{\"suggestedName\": \"some_file_name.txt\"}]", browser()))); |
| 347 browser()))); | |
| 348 | 347 |
| 349 EXPECT_FALSE(extensions::api_test_utils::GetBoolean(result.get(), "success")); | 348 EXPECT_FALSE(extensions::api_test_utils::GetBoolean(result.get(), "success")); |
| 350 base::DictionaryValue* entry_info; | 349 base::DictionaryValue* entry_info; |
| 351 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); | 350 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); |
| 352 } | 351 } |
| 353 | 352 |
| 354 // Tests that user cannot be suggested a full file path when selecting a file, | 353 // Tests that user cannot be suggested a full file path when selecting a file, |
| 355 // only a file name (i.e. that extension function caller has no influence on | 354 // only a file name (i.e. that extension function caller has no influence on |
| 356 // which directory contents will be initially displayed in selection dialog). | 355 // which directory contents will be initially displayed in selection dialog). |
| 357 IN_PROC_BROWSER_TEST_F(FileBrowserHandlerExtensionTest, SuggestedFullPath) { | 356 IN_PROC_BROWSER_TEST_F(FileBrowserHandlerExtensionTest, SuggestedFullPath) { |
| 358 TestCase test_case(base::FilePath("some_file_name.txt"), | 357 TestCase test_case(base::FilePath("some_file_name.txt"), |
| 359 std::vector<std::string>(), | 358 std::vector<std::string>(), |
| 360 false, | 359 false, |
| 361 base::FilePath()); | 360 base::FilePath()); |
| 362 | 361 |
| 363 scoped_refptr<FileBrowserHandlerInternalSelectFileFunction> | 362 scoped_refptr<FileBrowserHandlerInternalSelectFileFunction> |
| 364 select_file_function( | 363 select_file_function( |
| 365 new FileBrowserHandlerInternalSelectFileFunction( | 364 new FileBrowserHandlerInternalSelectFileFunction( |
| 366 new MockFileSelectorFactory(test_case), | 365 new MockFileSelectorFactory(test_case), |
| 367 false)); | 366 false)); |
| 368 | 367 |
| 369 select_file_function->set_has_callback(true); | 368 select_file_function->set_has_callback(true); |
| 370 select_file_function->set_user_gesture(true); | 369 select_file_function->set_user_gesture(true); |
| 371 | 370 |
| 372 scoped_ptr<base::DictionaryValue> result(utils::ToDictionary( | 371 std::unique_ptr<base::DictionaryValue> result( |
| 373 utils::RunFunctionAndReturnSingleResult( | 372 utils::ToDictionary(utils::RunFunctionAndReturnSingleResult( |
| 374 select_file_function.get(), | 373 select_file_function.get(), |
| 375 "[{\"suggestedName\": \"/path_to_file/some_file_name.txt\"}]", | 374 "[{\"suggestedName\": \"/path_to_file/some_file_name.txt\"}]", |
| 376 browser()))); | 375 browser()))); |
| 377 | 376 |
| 378 EXPECT_FALSE(extensions::api_test_utils::GetBoolean(result.get(), "success")); | 377 EXPECT_FALSE(extensions::api_test_utils::GetBoolean(result.get(), "success")); |
| 379 base::DictionaryValue* entry_info; | 378 base::DictionaryValue* entry_info; |
| 380 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); | 379 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); |
| 381 } | 380 } |
| 382 | 381 |
| 383 } // namespace | 382 } // namespace |
| OLD | NEW |