Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(544)

Side by Side Diff: chrome/browser/chromeos/file_manager/external_filesystem_apitest.cc

Issue 118043003: Fix app_shell shutdown crash due to BrowserContextKeyedServices (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ScopedFactoryForTest (shutdown_crash) Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_util.h" 6 #include "base/file_util.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "chrome/browser/chrome_notification_types.h" 9 #include "chrome/browser/chrome_notification_types.h"
10 #include "chrome/browser/chromeos/drive/drive_integration_service.h" 10 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
(...skipping 25 matching lines...) Expand all
36 // extension with fileBrowserPrivate permission (i.e. a file browser 36 // extension with fileBrowserPrivate permission (i.e. a file browser
37 // extension). 37 // extension).
38 // - Performing read/write operations from file handler extensions. These 38 // - Performing read/write operations from file handler extensions. These
39 // extensions need a file browser extension to give them permissions to access 39 // extensions need a file browser extension to give them permissions to access
40 // files. This also includes file handler extensions in filesystem API. 40 // files. This also includes file handler extensions in filesystem API.
41 // - Observing directory changes from a file browser extension (using 41 // - Observing directory changes from a file browser extension (using
42 // fileBrowserPrivate API). 42 // fileBrowserPrivate API).
43 // - Doing searches on drive file system from file browser extension (using 43 // - Doing searches on drive file system from file browser extension (using
44 // fileBrowserPrivate API). 44 // fileBrowserPrivate API).
45 45
46 using drive::DriveIntegrationServiceFactory;
46 using extensions::Extension; 47 using extensions::Extension;
47 48
48 namespace file_manager { 49 namespace file_manager {
49 namespace { 50 namespace {
50 51
51 // Root dirs for file systems expected by the test extensions. 52 // Root dirs for file systems expected by the test extensions.
52 // NOTE: Root dir for drive file system is set by Chrome's drive implementation, 53 // NOTE: Root dir for drive file system is set by Chrome's drive implementation,
53 // but the test will have to make sure the mount point is added before 54 // but the test will have to make sure the mount point is added before
54 // starting a test extension using WaitUntilDriveMountPointIsAdded(). 55 // starting a test extension using WaitUntilDriveMountPointIsAdded().
55 const char kLocalMountPointName[] = "local"; 56 const char kLocalMountPointName[] = "local";
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 DriveFileSystemExtensionApiTest() : fake_drive_service_(NULL) {} 292 DriveFileSystemExtensionApiTest() : fake_drive_service_(NULL) {}
292 virtual ~DriveFileSystemExtensionApiTest() {} 293 virtual ~DriveFileSystemExtensionApiTest() {}
293 294
294 // FileSystemExtensionApiTestBase OVERRIDE. 295 // FileSystemExtensionApiTestBase OVERRIDE.
295 virtual void InitTestFileSystem() OVERRIDE { 296 virtual void InitTestFileSystem() OVERRIDE {
296 // Set up cache root to be used by DriveIntegrationService. This has to be 297 // Set up cache root to be used by DriveIntegrationService. This has to be
297 // done before the browser is created because the service instance is 298 // done before the browser is created because the service instance is
298 // initialized by EventRouter. 299 // initialized by EventRouter.
299 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDir()); 300 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDir());
300 301
301 drive::DriveIntegrationServiceFactory::SetFactoryForTest( 302 // This callback will get called during Profile creation.
302 base::Bind( 303 create_drive_integration_service_ = base::Bind(
303 &DriveFileSystemExtensionApiTest::CreateDriveIntegrationService, 304 &DriveFileSystemExtensionApiTest::CreateDriveIntegrationService,
304 base::Unretained(this))); 305 base::Unretained(this));
306 service_factory_for_test_.reset(
307 new DriveIntegrationServiceFactory::ScopedFactoryForTest(
308 &create_drive_integration_service_));
305 } 309 }
306 310
307 // FileSystemExtensionApiTestBase OVERRIDE. 311 // FileSystemExtensionApiTestBase OVERRIDE.
308 virtual void AddTestMountPoint() OVERRIDE { 312 virtual void AddTestMountPoint() OVERRIDE {
309 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); 313 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
310 } 314 }
311 315
312 protected: 316 protected:
313 // DriveIntegrationService factory function for this test. 317 // DriveIntegrationService factory function for this test.
314 drive::DriveIntegrationService* CreateDriveIntegrationService( 318 drive::DriveIntegrationService* CreateDriveIntegrationService(
315 Profile* profile) { 319 Profile* profile) {
316 fake_drive_service_ = new drive::FakeDriveService; 320 fake_drive_service_ = new drive::FakeDriveService;
317 fake_drive_service_->LoadResourceListForWapi(kTestRootFeed); 321 fake_drive_service_->LoadResourceListForWapi(kTestRootFeed);
318 fake_drive_service_->LoadAccountMetadataForWapi( 322 fake_drive_service_->LoadAccountMetadataForWapi(
319 "gdata/account_metadata.json"); 323 "gdata/account_metadata.json");
320 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); 324 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json");
321 325
322 return new drive::DriveIntegrationService( 326 return new drive::DriveIntegrationService(
323 profile, NULL, 327 profile, NULL,
324 fake_drive_service_, test_cache_root_.path(), NULL); 328 fake_drive_service_, test_cache_root_.path(), NULL);
325 } 329 }
326 330
327 base::ScopedTempDir test_cache_root_; 331 base::ScopedTempDir test_cache_root_;
328 drive::FakeDriveService* fake_drive_service_; 332 drive::FakeDriveService* fake_drive_service_;
333 DriveIntegrationServiceFactory::FactoryCallback
334 create_drive_integration_service_;
335 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest>
336 service_factory_for_test_;
329 }; 337 };
330 338
331 // 339 //
332 // LocalFileSystemExtensionApiTests. 340 // LocalFileSystemExtensionApiTests.
333 // 341 //
334 342
335 IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileSystemOperations) { 343 IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileSystemOperations) {
336 EXPECT_TRUE(RunFileSystemExtensionApiTest( 344 EXPECT_TRUE(RunFileSystemExtensionApiTest(
337 "file_browser/filesystem_operations_test", 345 "file_browser/filesystem_operations_test",
338 FILE_PATH_LITERAL("manifest.json"), 346 FILE_PATH_LITERAL("manifest.json"),
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 fake_drive_service_->set_default_max_results(1); 435 fake_drive_service_->set_default_max_results(1);
428 EXPECT_TRUE(RunFileSystemExtensionApiTest( 436 EXPECT_TRUE(RunFileSystemExtensionApiTest(
429 "file_browser/handler_test_runner", 437 "file_browser/handler_test_runner",
430 FILE_PATH_LITERAL("manifest.json"), 438 FILE_PATH_LITERAL("manifest.json"),
431 "file_browser/app_file_handler", 439 "file_browser/app_file_handler",
432 FLAGS_USE_FILE_HANDLER)) << message_; 440 FLAGS_USE_FILE_HANDLER)) << message_;
433 } 441 }
434 442
435 } // namespace 443 } // namespace
436 } // namespace file_manager 444 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698