| 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/json/json_file_value_serializer.h" | 8 #include "base/json/json_file_value_serializer.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/message_loop_proxy.h" | 10 #include "base/message_loop_proxy.h" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/scoped_temp_dir.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/gdata/gdata_errorcode.h" | 15 #include "chrome/browser/chromeos/gdata/gdata_errorcode.h" |
| 16 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" | 16 #include "chrome/browser/chromeos/gdata/gdata_file_system.h" |
| 17 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" | |
| 18 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 17 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
| 19 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 18 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
| 20 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" | 19 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
| 21 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" | 20 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" |
| 21 #include "chrome/browser/chromeos/gdata/operation_registry.h" |
| 22 #include "chrome/browser/extensions/extension_apitest.h" | 22 #include "chrome/browser/extensions/extension_apitest.h" |
| 23 #include "chrome/browser/extensions/extension_test_message_listener.h" | 23 #include "chrome/browser/extensions/extension_test_message_listener.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/browser.h" | 25 #include "chrome/browser/ui/browser.h" |
| 26 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
| 27 #include "chrome/common/chrome_paths.h" | 27 #include "chrome/common/chrome_paths.h" |
| 28 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
| 30 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
| 31 #include "content/public/test/test_utils.h" | 31 #include "content/public/test/test_utils.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 // created) because the system service instance is initialized very early | 199 // created) because the system service instance is initialized very early |
| 200 // by FileBrowserEventRouter. | 200 // by FileBrowserEventRouter. |
| 201 FilePath tmp_dir_path; | 201 FilePath tmp_dir_path; |
| 202 PathService::Get(base::DIR_TEMP, &tmp_dir_path); | 202 PathService::Get(base::DIR_TEMP, &tmp_dir_path); |
| 203 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDirUnderPath(tmp_dir_path)); | 203 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDirUnderPath(tmp_dir_path)); |
| 204 gdata::GDataSystemServiceFactory::set_cache_root_for_test( | 204 gdata::GDataSystemServiceFactory::set_cache_root_for_test( |
| 205 test_cache_root_.path().value()); | 205 test_cache_root_.path().value()); |
| 206 | 206 |
| 207 mock_drive_service_ = new gdata::MockDriveService(); | 207 mock_drive_service_ = new gdata::MockDriveService(); |
| 208 | 208 |
| 209 operation_registry_.reset(new gdata::GDataOperationRegistry()); | 209 operation_registry_.reset(new gdata::OperationRegistry()); |
| 210 // FileBrowserEventRouter will add and remove itself from operation registry | 210 // FileBrowserEventRouter will add and remove itself from operation registry |
| 211 // observer list. | 211 // observer list. |
| 212 EXPECT_CALL(*mock_drive_service_, operation_registry()). | 212 EXPECT_CALL(*mock_drive_service_, operation_registry()). |
| 213 WillRepeatedly(Return(operation_registry_.get())); | 213 WillRepeatedly(Return(operation_registry_.get())); |
| 214 | 214 |
| 215 // |mock_drive_service_| will eventually get owned by a system service. | 215 // |mock_drive_service_| will eventually get owned by a system service. |
| 216 gdata::GDataSystemServiceFactory::set_drive_service_for_test( | 216 gdata::GDataSystemServiceFactory::set_drive_service_for_test( |
| 217 mock_drive_service_); | 217 mock_drive_service_); |
| 218 | 218 |
| 219 ExtensionApiTest::SetUp(); | 219 ExtensionApiTest::SetUp(); |
| 220 } | 220 } |
| 221 | 221 |
| 222 virtual void TearDown() OVERRIDE { | 222 virtual void TearDown() OVERRIDE { |
| 223 // Let's make sure we don't leak documents service. | 223 // Let's make sure we don't leak documents service. |
| 224 gdata::GDataSystemServiceFactory::set_drive_service_for_test(NULL); | 224 gdata::GDataSystemServiceFactory::set_drive_service_for_test(NULL); |
| 225 gdata::GDataSystemServiceFactory::set_cache_root_for_test(std::string()); | 225 gdata::GDataSystemServiceFactory::set_cache_root_for_test(std::string()); |
| 226 ExtensionApiTest::TearDown(); | 226 ExtensionApiTest::TearDown(); |
| 227 } | 227 } |
| 228 | 228 |
| 229 protected: | 229 protected: |
| 230 ScopedTempDir test_cache_root_; | 230 ScopedTempDir test_cache_root_; |
| 231 gdata::MockDriveService* mock_drive_service_; | 231 gdata::MockDriveService* mock_drive_service_; |
| 232 scoped_ptr<gdata::GDataOperationRegistry> operation_registry_; | 232 scoped_ptr<gdata::OperationRegistry> operation_registry_; |
| 233 }; | 233 }; |
| 234 | 234 |
| 235 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, LocalFileSystem) { | 235 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, LocalFileSystem) { |
| 236 AddTmpMountPoint(); | 236 AddTmpMountPoint(); |
| 237 ASSERT_TRUE(RunComponentExtensionTest("local_filesystem")) << message_; | 237 ASSERT_TRUE(RunComponentExtensionTest("local_filesystem")) << message_; |
| 238 } | 238 } |
| 239 | 239 |
| 240 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTest) { | 240 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, FileBrowserTest) { |
| 241 AddTmpMountPoint(); | 241 AddTmpMountPoint(); |
| 242 ASSERT_TRUE(RunExtensionTest("filesystem_handler")) << message_; | 242 ASSERT_TRUE(RunExtensionTest("filesystem_handler")) << message_; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 _, _)) | 356 _, _)) |
| 357 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); | 357 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); |
| 358 | 358 |
| 359 // On exit, all operations in progress should be cancelled. | 359 // On exit, all operations in progress should be cancelled. |
| 360 EXPECT_CALL(*mock_drive_service_, CancelAll()); | 360 EXPECT_CALL(*mock_drive_service_, CancelAll()); |
| 361 | 361 |
| 362 // All is set... RUN THE TEST. | 362 // All is set... RUN THE TEST. |
| 363 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", | 363 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", |
| 364 kComponentFlags)) << message_; | 364 kComponentFlags)) << message_; |
| 365 } | 365 } |
| OLD | NEW |