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 <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/thread_task_runner_handle.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/extensions/extension_apitest.h" | 15 #include "chrome/browser/extensions/extension_apitest.h" |
15 #include "chrome/browser/extensions/extension_function_test_utils.h" | 16 #include "chrome/browser/extensions/extension_function_test_utils.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/public/browser/browser_context.h" | 21 #include "content/public/browser/browser_context.h" |
21 #include "extensions/browser/api_test_utils.h" | 22 #include "extensions/browser/api_test_utils.h" |
22 #include "extensions/common/extension.h" | 23 #include "extensions/common/extension.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 // Confirm that the function allowed us the right extensions. | 95 // Confirm that the function allowed us the right extensions. |
95 EXPECT_EQ(allowed_extensions_.size(), allowed_extensions.size()); | 96 EXPECT_EQ(allowed_extensions_.size(), allowed_extensions.size()); |
96 if (allowed_extensions_.size() == allowed_extensions.size()) { | 97 if (allowed_extensions_.size() == allowed_extensions.size()) { |
97 for (size_t i = 0; i < allowed_extensions_.size(); ++i) { | 98 for (size_t i = 0; i < allowed_extensions_.size(); ++i) { |
98 EXPECT_EQ(allowed_extensions_[i], allowed_extensions[i]); | 99 EXPECT_EQ(allowed_extensions_[i], allowed_extensions[i]); |
99 } | 100 } |
100 } | 101 } |
101 | 102 |
102 // Send response to the extension function. | 103 // Send response to the extension function. |
103 // The callback will take a reference to the function and keep it alive. | 104 // The callback will take a reference to the function and keep it alive. |
104 base::MessageLoopProxy::current()->PostTask(FROM_HERE, | 105 base::ThreadTaskRunnerHandle::Get()->PostTask( |
105 base::Bind(&FileBrowserHandlerInternalSelectFileFunction:: | 106 FROM_HERE, |
106 OnFilePathSelected, | 107 base::Bind( |
107 function, success_, selected_path_)); | 108 &FileBrowserHandlerInternalSelectFileFunction::OnFilePathSelected, |
| 109 function, success_, selected_path_)); |
108 delete this; | 110 delete this; |
109 } | 111 } |
110 | 112 |
111 private: | 113 private: |
112 // File name that is expected to be suggested by the function. | 114 // File name that is expected to be suggested by the function. |
113 base::FilePath suggested_name_; | 115 base::FilePath suggested_name_; |
114 | 116 |
115 // Extensions that is expected to be allowed by the function. | 117 // Extensions that is expected to be allowed by the function. |
116 std::vector<std::string> allowed_extensions_; | 118 std::vector<std::string> allowed_extensions_; |
117 | 119 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 select_file_function.get(), | 371 select_file_function.get(), |
370 "[{\"suggestedName\": \"/path_to_file/some_file_name.txt\"}]", | 372 "[{\"suggestedName\": \"/path_to_file/some_file_name.txt\"}]", |
371 browser()))); | 373 browser()))); |
372 | 374 |
373 EXPECT_FALSE(extensions::api_test_utils::GetBoolean(result.get(), "success")); | 375 EXPECT_FALSE(extensions::api_test_utils::GetBoolean(result.get(), "success")); |
374 base::DictionaryValue* entry_info; | 376 base::DictionaryValue* entry_info; |
375 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); | 377 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); |
376 } | 378 } |
377 | 379 |
378 } // namespace | 380 } // namespace |
OLD | NEW |