| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/file_path.h" | 6 #include "base/file_path.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop_proxy.h" | 11 #include "base/message_loop_proxy.h" |
| 11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 12 #include "base/scoped_temp_dir.h" | |
| 13 #include "base/threading/worker_pool.h" | 13 #include "base/threading/worker_pool.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chrome/browser/chromeos/drive/drive_file_system.h" | 15 #include "chrome/browser/chromeos/drive/drive_file_system.h" |
| 16 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 16 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
| 17 #include "chrome/browser/extensions/event_router.h" | 17 #include "chrome/browser/extensions/event_router.h" |
| 18 #include "chrome/browser/extensions/extension_apitest.h" | 18 #include "chrome/browser/extensions/extension_apitest.h" |
| 19 #include "chrome/browser/extensions/extension_test_message_listener.h" | 19 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 20 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 20 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
| 21 #include "chrome/browser/google_apis/mock_drive_service.h" | 21 #include "chrome/browser/google_apis/mock_drive_service.h" |
| 22 #include "chrome/browser/google_apis/time_util.h" | 22 #include "chrome/browser/google_apis/time_util.h" |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 247 } |
| 248 | 248 |
| 249 void AddRestrictedMountPoint() { | 249 void AddRestrictedMountPoint() { |
| 250 fileapi::ExternalFileSystemMountPointProvider* provider = | 250 fileapi::ExternalFileSystemMountPointProvider* provider = |
| 251 BrowserContext::GetDefaultStoragePartition( | 251 BrowserContext::GetDefaultStoragePartition( |
| 252 browser()->profile())->GetFileSystemContext()->external_provider(); | 252 browser()->profile())->GetFileSystemContext()->external_provider(); |
| 253 provider->AddRestrictedLocalMountPoint(mount_point_dir_); | 253 provider->AddRestrictedLocalMountPoint(mount_point_dir_); |
| 254 } | 254 } |
| 255 | 255 |
| 256 protected: | 256 protected: |
| 257 ScopedTempDir tmp_dir_; | 257 base::ScopedTempDir tmp_dir_; |
| 258 FilePath mount_point_dir_; | 258 FilePath mount_point_dir_; |
| 259 }; | 259 }; |
| 260 | 260 |
| 261 | 261 |
| 262 class RemoteFileSystemExtensionApiTest : public ExtensionApiTest { | 262 class RemoteFileSystemExtensionApiTest : public ExtensionApiTest { |
| 263 public: | 263 public: |
| 264 RemoteFileSystemExtensionApiTest() {} | 264 RemoteFileSystemExtensionApiTest() {} |
| 265 | 265 |
| 266 virtual ~RemoteFileSystemExtensionApiTest() {} | 266 virtual ~RemoteFileSystemExtensionApiTest() {} |
| 267 | 267 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 286 } | 286 } |
| 287 | 287 |
| 288 virtual void TearDown() OVERRIDE { | 288 virtual void TearDown() OVERRIDE { |
| 289 // Let's make sure we don't leak documents service. | 289 // Let's make sure we don't leak documents service. |
| 290 drive::DriveSystemServiceFactory::set_drive_service_for_test(NULL); | 290 drive::DriveSystemServiceFactory::set_drive_service_for_test(NULL); |
| 291 drive::DriveSystemServiceFactory::set_cache_root_for_test(std::string()); | 291 drive::DriveSystemServiceFactory::set_cache_root_for_test(std::string()); |
| 292 ExtensionApiTest::TearDown(); | 292 ExtensionApiTest::TearDown(); |
| 293 } | 293 } |
| 294 | 294 |
| 295 protected: | 295 protected: |
| 296 ScopedTempDir test_cache_root_; | 296 base::ScopedTempDir test_cache_root_; |
| 297 google_apis::MockDriveService* mock_drive_service_; | 297 google_apis::MockDriveService* mock_drive_service_; |
| 298 }; | 298 }; |
| 299 | 299 |
| 300 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, LocalFileSystem) { | 300 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, LocalFileSystem) { |
| 301 AddTmpMountPoint(); | 301 AddTmpMountPoint(); |
| 302 ASSERT_TRUE(RunComponentExtensionTest("local_filesystem")) << message_; | 302 ASSERT_TRUE(RunComponentExtensionTest("local_filesystem")) << message_; |
| 303 } | 303 } |
| 304 | 304 |
| 305 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTest) { | 305 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTest) { |
| 306 AddTmpMountPoint(); | 306 AddTmpMountPoint(); |
| 307 ASSERT_TRUE(RunExtensionTest("filesystem_handler")) << message_; | 307 ASSERT_TRUE(RunExtensionTest("filesystem_handler")) << message_; |
| 308 ASSERT_TRUE(RunExtensionSubtest( | 308 ASSERT_TRUE(RunExtensionSubtest( |
| 309 "filebrowser_component", "read.html", kComponentFlags)) << message_; | 309 "filebrowser_component", "read.html", kComponentFlags)) << message_; |
| 310 } | 310 } |
| 311 | 311 |
| 312 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTestLazy) { | 312 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTestLazy) { |
| 313 AddTmpMountPoint(); | 313 AddTmpMountPoint(); |
| 314 ASSERT_TRUE(LoadExtensionAndWait("filesystem_handler_lazy_background")) | 314 ASSERT_TRUE(LoadExtensionAndWait("filesystem_handler_lazy_background")) |
| 315 << message_; | 315 << message_; |
| 316 ASSERT_TRUE(RunExtensionSubtest( | 316 ASSERT_TRUE(RunExtensionSubtest( |
| 317 "filebrowser_component", "read.html", kComponentFlags)) << message_; | 317 "filebrowser_component", "read.html", kComponentFlags)) << message_; |
| 318 } | 318 } |
| 319 | 319 |
| 320 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserWebIntentTest) { | 320 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserWebIntentTest) { |
| 321 AddTmpMountPoint(); | 321 AddTmpMountPoint(); |
| 322 | 322 |
| 323 ResultCatcher catcher; | 323 ResultCatcher catcher; |
| 324 ScopedTempDir tmp_dir; | 324 base::ScopedTempDir tmp_dir; |
| 325 ASSERT_TRUE(tmp_dir.CreateUniqueTempDir()); | 325 ASSERT_TRUE(tmp_dir.CreateUniqueTempDir()); |
| 326 | 326 |
| 327 // Create a test file inside the ScopedTempDir. | 327 // Create a test file inside the base::ScopedTempDir. |
| 328 FilePath test_file = tmp_dir.path().AppendASCII("text_file.xul"); | 328 FilePath test_file = tmp_dir.path().AppendASCII("text_file.xul"); |
| 329 CreateFileWithContent(test_file, kTestFileContent); | 329 CreateFileWithContent(test_file, kTestFileContent); |
| 330 | 330 |
| 331 ASSERT_TRUE(LoadExtension( | 331 ASSERT_TRUE(LoadExtension( |
| 332 test_data_dir_.AppendASCII("webintent_handler"))) << message_; | 332 test_data_dir_.AppendASCII("webintent_handler"))) << message_; |
| 333 | 333 |
| 334 // Load the source component, with the fileUrl within the virtual mount | 334 // Load the source component, with the fileUrl within the virtual mount |
| 335 // point. | 335 // point. |
| 336 const extensions::Extension* extension = LoadExtensionAsComponent( | 336 const extensions::Extension* extension = LoadExtensionAsComponent( |
| 337 test_data_dir_.AppendASCII("filebrowser_component")); | 337 test_data_dir_.AppendASCII("filebrowser_component")); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 _, _)) | 473 _, _)) |
| 474 .WillOnce(MockDownloadFileCallback(google_apis::HTTP_SUCCESS)); | 474 .WillOnce(MockDownloadFileCallback(google_apis::HTTP_SUCCESS)); |
| 475 | 475 |
| 476 // On exit, all operations in progress should be cancelled. | 476 // On exit, all operations in progress should be cancelled. |
| 477 EXPECT_CALL(*mock_drive_service_, CancelAll()); | 477 EXPECT_CALL(*mock_drive_service_, CancelAll()); |
| 478 | 478 |
| 479 // All is set... RUN THE TEST. | 479 // All is set... RUN THE TEST. |
| 480 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", | 480 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", |
| 481 kComponentFlags)) << message_; | 481 kComponentFlags)) << message_; |
| 482 } | 482 } |
| OLD | NEW |