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/drive_file_system.h" | 15 #include "chrome/browser/chromeos/gdata/drive_file_system.h" |
16 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 16 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
17 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 17 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
18 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" | 18 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
19 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" | 19 #include "chrome/browser/chromeos/gdata/mock_drive_service.h" |
20 #include "chrome/browser/chromeos/gdata/operation_registry.h" | 20 #include "chrome/browser/chromeos/gdata/operation_registry.h" |
21 #include "chrome/browser/extensions/extension_apitest.h" | 21 #include "chrome/browser/extensions/extension_apitest.h" |
22 #include "chrome/browser/extensions/extension_test_message_listener.h" | 22 #include "chrome/browser/extensions/extension_test_message_listener.h" |
23 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/chrome_paths.h" | 26 #include "chrome/common/chrome_paths.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 virtual ~RemoteFileSystemExtensionApiTest() {} | 193 virtual ~RemoteFileSystemExtensionApiTest() {} |
194 | 194 |
195 virtual void SetUp() OVERRIDE { | 195 virtual void SetUp() OVERRIDE { |
196 // Set up cache root and documents service to be used when creating gdata | 196 // Set up cache root and documents service to be used when creating gdata |
197 // system service. This has to be done early on (before the browser is | 197 // system service. This has to be done early on (before the browser is |
198 // created) because the system service instance is initialized very early | 198 // created) because the system service instance is initialized very early |
199 // by FileBrowserEventRouter. | 199 // by FileBrowserEventRouter. |
200 FilePath tmp_dir_path; | 200 FilePath tmp_dir_path; |
201 PathService::Get(base::DIR_TEMP, &tmp_dir_path); | 201 PathService::Get(base::DIR_TEMP, &tmp_dir_path); |
202 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDirUnderPath(tmp_dir_path)); | 202 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDirUnderPath(tmp_dir_path)); |
203 gdata::GDataSystemServiceFactory::set_cache_root_for_test( | 203 gdata::DriveSystemServiceFactory::set_cache_root_for_test( |
204 test_cache_root_.path().value()); | 204 test_cache_root_.path().value()); |
205 | 205 |
206 mock_drive_service_ = new gdata::MockDriveService(); | 206 mock_drive_service_ = new gdata::MockDriveService(); |
207 | 207 |
208 operation_registry_.reset(new gdata::OperationRegistry()); | 208 operation_registry_.reset(new gdata::OperationRegistry()); |
209 // FileBrowserEventRouter will add and remove itself from operation registry | 209 // FileBrowserEventRouter will add and remove itself from operation registry |
210 // observer list. | 210 // observer list. |
211 EXPECT_CALL(*mock_drive_service_, operation_registry()). | 211 EXPECT_CALL(*mock_drive_service_, operation_registry()). |
212 WillRepeatedly(Return(operation_registry_.get())); | 212 WillRepeatedly(Return(operation_registry_.get())); |
213 | 213 |
214 // |mock_drive_service_| will eventually get owned by a system service. | 214 // |mock_drive_service_| will eventually get owned by a system service. |
215 gdata::GDataSystemServiceFactory::set_drive_service_for_test( | 215 gdata::DriveSystemServiceFactory::set_drive_service_for_test( |
216 mock_drive_service_); | 216 mock_drive_service_); |
217 | 217 |
218 ExtensionApiTest::SetUp(); | 218 ExtensionApiTest::SetUp(); |
219 } | 219 } |
220 | 220 |
221 virtual void TearDown() OVERRIDE { | 221 virtual void TearDown() OVERRIDE { |
222 // Let's make sure we don't leak documents service. | 222 // Let's make sure we don't leak documents service. |
223 gdata::GDataSystemServiceFactory::set_drive_service_for_test(NULL); | 223 gdata::DriveSystemServiceFactory::set_drive_service_for_test(NULL); |
224 gdata::GDataSystemServiceFactory::set_cache_root_for_test(std::string()); | 224 gdata::DriveSystemServiceFactory::set_cache_root_for_test(std::string()); |
225 ExtensionApiTest::TearDown(); | 225 ExtensionApiTest::TearDown(); |
226 } | 226 } |
227 | 227 |
228 protected: | 228 protected: |
229 ScopedTempDir test_cache_root_; | 229 ScopedTempDir test_cache_root_; |
230 gdata::MockDriveService* mock_drive_service_; | 230 gdata::MockDriveService* mock_drive_service_; |
231 scoped_ptr<gdata::OperationRegistry> operation_registry_; | 231 scoped_ptr<gdata::OperationRegistry> operation_registry_; |
232 }; | 232 }; |
233 | 233 |
234 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, LocalFileSystem) { | 234 IN_PROC_BROWSER_TEST_F(FileSystemExtensionApiTest, LocalFileSystem) { |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 _, _)) | 355 _, _)) |
356 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); | 356 .WillOnce(MockDownloadFileCallback(gdata::HTTP_SUCCESS)); |
357 | 357 |
358 // On exit, all operations in progress should be cancelled. | 358 // On exit, all operations in progress should be cancelled. |
359 EXPECT_CALL(*mock_drive_service_, CancelAll()); | 359 EXPECT_CALL(*mock_drive_service_, CancelAll()); |
360 | 360 |
361 // All is set... RUN THE TEST. | 361 // All is set... RUN THE TEST. |
362 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", | 362 EXPECT_TRUE(RunExtensionSubtest("filebrowser_component", "remote_search.html", |
363 kComponentFlags)) << message_; | 363 kComponentFlags)) << message_; |
364 } | 364 } |
OLD | NEW |