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

Side by Side Diff: chrome/browser/chromeos/file_manager/file_manager_browsertest.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 // Browser test for basic Chrome OS file manager functionality: 5 // Browser test for basic Chrome OS file manager functionality:
6 // - The file list is updated when a file is added externally to the Downloads 6 // - The file list is updated when a file is added externally to the Downloads
7 // folder. 7 // folder.
8 // - Selecting a file and copy-pasting it with the keyboard copies the file. 8 // - Selecting a file and copy-pasting it with the keyboard copies the file.
9 // - Selecting a file and pressing delete deletes it. 9 // - Selecting a file and pressing delete deletes it.
10 10
(...skipping 24 matching lines...) Expand all
35 #include "chromeos/chromeos_switches.h" 35 #include "chromeos/chromeos_switches.h"
36 #include "content/public/browser/browser_context.h" 36 #include "content/public/browser/browser_context.h"
37 #include "content/public/browser/notification_service.h" 37 #include "content/public/browser/notification_service.h"
38 #include "content/public/test/test_utils.h" 38 #include "content/public/test/test_utils.h"
39 #include "extensions/common/extension.h" 39 #include "extensions/common/extension.h"
40 #include "google_apis/drive/gdata_wapi_parser.h" 40 #include "google_apis/drive/gdata_wapi_parser.h"
41 #include "google_apis/drive/test_util.h" 41 #include "google_apis/drive/test_util.h"
42 #include "net/test/embedded_test_server/embedded_test_server.h" 42 #include "net/test/embedded_test_server/embedded_test_server.h"
43 #include "webkit/browser/fileapi/external_mount_points.h" 43 #include "webkit/browser/fileapi/external_mount_points.h"
44 44
45 using drive::DriveIntegrationServiceFactory;
46
45 namespace file_manager { 47 namespace file_manager {
46 namespace { 48 namespace {
47 49
48 enum EntryType { 50 enum EntryType {
49 FILE, 51 FILE,
50 DIRECTORY, 52 DIRECTORY,
51 }; 53 };
52 54
53 enum TargetVolume { 55 enum TargetVolume {
54 LOCAL_VOLUME, 56 LOCAL_VOLUME,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // The drive volume class for test. 265 // The drive volume class for test.
264 // This class provides the operations for a test volume that simulates Google 266 // This class provides the operations for a test volume that simulates Google
265 // drive. 267 // drive.
266 class DriveTestVolume { 268 class DriveTestVolume {
267 public: 269 public:
268 DriveTestVolume() : fake_drive_service_(NULL), 270 DriveTestVolume() : fake_drive_service_(NULL),
269 integration_service_(NULL) { 271 integration_service_(NULL) {
270 } 272 }
271 273
272 // Sends request to add this volume to the file system as Google drive. 274 // Sends request to add this volume to the file system as Google drive.
273 // This method must be calld at SetUp method of FileManagerBrowserTestBase. 275 // This method must be called at SetUp method of FileManagerBrowserTestBase.
274 // Returns true on success. 276 // Returns true on success.
275 bool SetUp() { 277 bool SetUp() {
276 if (!test_cache_root_.CreateUniqueTempDir()) 278 if (!test_cache_root_.CreateUniqueTempDir())
277 return false; 279 return false;
278 drive::DriveIntegrationServiceFactory::SetFactoryForTest( 280 create_drive_integration_service_ =
279 base::Bind(&DriveTestVolume::CreateDriveIntegrationService, 281 base::Bind(&DriveTestVolume::CreateDriveIntegrationService,
280 base::Unretained(this))); 282 base::Unretained(this));
283 service_factory_for_test_.reset(
284 new DriveIntegrationServiceFactory::ScopedFactoryForTest(
285 &create_drive_integration_service_));
281 return true; 286 return true;
282 } 287 }
283 288
284 void CreateEntry(const TestEntryInfo& entry) { 289 void CreateEntry(const TestEntryInfo& entry) {
285 const base::FilePath path = 290 const base::FilePath path =
286 base::FilePath::FromUTF8Unsafe(entry.target_path); 291 base::FilePath::FromUTF8Unsafe(entry.target_path);
287 const std::string target_name = path.BaseName().AsUTF8Unsafe(); 292 const std::string target_name = path.BaseName().AsUTF8Unsafe();
288 293
289 // Obtain the parent entry. 294 // Obtain the parent entry.
290 drive::FileError error = drive::FILE_ERROR_OK; 295 drive::FileError error = drive::FILE_ERROR_OK;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); 412 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json");
408 integration_service_ = new drive::DriveIntegrationService( 413 integration_service_ = new drive::DriveIntegrationService(
409 profile, NULL, fake_drive_service_, test_cache_root_.path(), NULL); 414 profile, NULL, fake_drive_service_, test_cache_root_.path(), NULL);
410 return integration_service_; 415 return integration_service_;
411 } 416 }
412 417
413 private: 418 private:
414 base::ScopedTempDir test_cache_root_; 419 base::ScopedTempDir test_cache_root_;
415 drive::FakeDriveService* fake_drive_service_; 420 drive::FakeDriveService* fake_drive_service_;
416 drive::DriveIntegrationService* integration_service_; 421 drive::DriveIntegrationService* integration_service_;
422 DriveIntegrationServiceFactory::FactoryCallback
423 create_drive_integration_service_;
424 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest>
425 service_factory_for_test_;
417 }; 426 };
418 427
419 // Listener to obtain the test relative messages synchronously. 428 // Listener to obtain the test relative messages synchronously.
420 class FileManagerTestListener : public content::NotificationObserver { 429 class FileManagerTestListener : public content::NotificationObserver {
421 public: 430 public:
422 struct Message { 431 struct Message {
423 int type; 432 int type;
424 std::string message; 433 std::string message;
425 scoped_refptr<extensions::TestSendMessageFunction> function; 434 scoped_refptr<extensions::TestSendMessageFunction> function;
426 }; 435 };
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "searchBoxFocus"))); 750 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "searchBoxFocus")));
742 751
743 INSTANTIATE_TEST_CASE_P( 752 INSTANTIATE_TEST_CASE_P(
744 Thumbnails, 753 Thumbnails,
745 FileManagerBrowserTest, 754 FileManagerBrowserTest,
746 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "thumbnailsDownloads"), 755 ::testing::Values(TestParameter(NOT_IN_GUEST_MODE, "thumbnailsDownloads"),
747 TestParameter(IN_GUEST_MODE, "thumbnailsDownloads"))); 756 TestParameter(IN_GUEST_MODE, "thumbnailsDownloads")));
748 757
749 } // namespace 758 } // namespace
750 } // namespace file_manager 759 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698