| 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_browser_handler_api.h" | 7 #include "chrome/browser/chromeos/extensions/file_browser_handler_api.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/scoped_temp_dir.h" | 13 #include "base/scoped_temp_dir.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/extensions/extension_apitest.h" | 15 #include "chrome/browser/extensions/extension_apitest.h" |
| 16 #include "chrome/browser/extensions/extension_function_test_utils.h" | 16 #include "chrome/browser/extensions/extension_function_test_utils.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/test/base/in_process_browser_test.h" | 19 #include "chrome/test/base/in_process_browser_test.h" |
| 20 #include "chrome/test/base/ui_test_utils.h" | 20 #include "chrome/test/base/ui_test_utils.h" |
| 21 #include "content/public/browser/browser_context.h" |
| 22 #include "content/public/browser/storage_partition.h" |
| 21 #include "webkit/fileapi/file_system_context.h" | 23 #include "webkit/fileapi/file_system_context.h" |
| 22 #include "webkit/fileapi/file_system_mount_point_provider.h" | 24 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 23 | 25 |
| 24 namespace utils = extension_function_test_utils; | 26 namespace utils = extension_function_test_utils; |
| 25 | 27 |
| 26 using content::BrowserContext; | 28 using content::BrowserContext; |
| 27 using extensions::Extension; | 29 using extensions::Extension; |
| 28 | 30 |
| 29 namespace { | 31 namespace { |
| 30 | 32 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ASSERT_TRUE(scoped_tmp_dir_.CreateUniqueTempDirUnderPath(tmp_dir_path)); | 141 ASSERT_TRUE(scoped_tmp_dir_.CreateUniqueTempDirUnderPath(tmp_dir_path)); |
| 140 tmp_mount_point_ = scoped_tmp_dir_.path().Append("tmp"); | 142 tmp_mount_point_ = scoped_tmp_dir_.path().Append("tmp"); |
| 141 file_util::CreateDirectory(tmp_mount_point_); | 143 file_util::CreateDirectory(tmp_mount_point_); |
| 142 | 144 |
| 143 ExtensionApiTest::SetUp(); | 145 ExtensionApiTest::SetUp(); |
| 144 } | 146 } |
| 145 | 147 |
| 146 // Creates new, test mount point. | 148 // Creates new, test mount point. |
| 147 void AddTmpMountPoint() { | 149 void AddTmpMountPoint() { |
| 148 fileapi::ExternalFileSystemMountPointProvider* provider = | 150 fileapi::ExternalFileSystemMountPointProvider* provider = |
| 149 BrowserContext::GetFileSystemContext(browser()->profile())-> | 151 BrowserContext::GetDefaultStoragePartition(browser()->profile())-> |
| 150 external_provider(); | 152 GetFileSystemContext()->external_provider(); |
| 151 provider->AddLocalMountPoint(tmp_mount_point_); | 153 provider->AddLocalMountPoint(tmp_mount_point_); |
| 152 } | 154 } |
| 153 | 155 |
| 154 FilePath GetFullPathOnTmpMountPoint(const FilePath& relative_path) { | 156 FilePath GetFullPathOnTmpMountPoint(const FilePath& relative_path) { |
| 155 return tmp_mount_point_.Append(relative_path); | 157 return tmp_mount_point_.Append(relative_path); |
| 156 } | 158 } |
| 157 | 159 |
| 158 // Creates a new FileHandlerSelectFileFunction to be used in the test. | 160 // Creates a new FileHandlerSelectFileFunction to be used in the test. |
| 159 // This function will be called from ExtensionFunctinoDispatcher whenever | 161 // This function will be called from ExtensionFunctinoDispatcher whenever |
| 160 // an extension function for fileBrowserHandlerInternal.selectFile will be | 162 // an extension function for fileBrowserHandlerInternal.selectFile will be |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 select_file_function.get(), | 310 select_file_function.get(), |
| 309 "[{\"suggestedName\": \"/path_to_file/some_file_name.txt\"}]", | 311 "[{\"suggestedName\": \"/path_to_file/some_file_name.txt\"}]", |
| 310 browser()))); | 312 browser()))); |
| 311 | 313 |
| 312 EXPECT_FALSE(utils::GetBoolean(result.get(), "success")); | 314 EXPECT_FALSE(utils::GetBoolean(result.get(), "success")); |
| 313 DictionaryValue* entry_info; | 315 DictionaryValue* entry_info; |
| 314 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); | 316 EXPECT_FALSE(result->GetDictionary("entry", &entry_info)); |
| 315 } | 317 } |
| 316 | 318 |
| 317 } // namespace | 319 } // namespace |
| 318 | |
| OLD | NEW |