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