Chromium Code Reviews| 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_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 "base/path_service.h" | |
| 9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 11 #include "chrome/browser/chromeos/drive/drive_integration_service.h" | 12 #include "chrome/browser/chromeos/drive/drive_integration_service.h" |
| 12 #include "chrome/browser/chromeos/drive/test_util.h" | 13 #include "chrome/browser/chromeos/drive/test_util.h" |
| 13 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" | 14 #include "chrome/browser/chromeos/file_manager/drive_test_util.h" |
| 14 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 15 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
| 16 #include "chrome/browser/chromeos/login/user_manager.h" | |
| 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" | |
| 15 #include "chrome/browser/drive/fake_drive_service.h" | 18 #include "chrome/browser/drive/fake_drive_service.h" |
| 16 #include "chrome/browser/extensions/extension_apitest.h" | 19 #include "chrome/browser/extensions/extension_apitest.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
| 19 #include "chrome/browser/ui/browser.h" | 22 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 24 #include "chrome/common/chrome_paths.h" | |
| 21 #include "content/public/browser/browser_context.h" | 25 #include "content/public/browser/browser_context.h" |
| 22 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/test/test_utils.h" | 27 #include "content/public/test/test_utils.h" |
| 24 #include "google_apis/drive/test_util.h" | 28 #include "google_apis/drive/test_util.h" |
| 25 #include "google_apis/drive/time_util.h" | 29 #include "google_apis/drive/time_util.h" |
| 26 #include "webkit/browser/fileapi/external_mount_points.h" | 30 #include "webkit/browser/fileapi/external_mount_points.h" |
| 27 | 31 |
| 32 | |
|
Nikita (slow)
2014/05/14 20:10:16
nit: drop extra empty line.
zel
2014/05/14 21:17:57
Done.
| |
| 28 // Tests for access to external file systems (as defined in | 33 // Tests for access to external file systems (as defined in |
| 29 // webkit/common/fileapi/file_system_types.h) from extensions with | 34 // webkit/common/fileapi/file_system_types.h) from extensions with |
| 30 // fileBrowserPrivate and fileBrowserHandler extension permissions. | 35 // fileBrowserPrivate and fileBrowserHandler extension permissions. |
| 31 // The tests cover following external file system types: | 36 // The tests cover following external file system types: |
| 32 // - local (kFileSystemTypeLocalNative): a local file system on which files are | 37 // - local (kFileSystemTypeLocalNative): a local file system on which files are |
| 33 // accessed using native local path. | 38 // accessed using native local path. |
| 34 // - restricted (kFileSystemTypeRestrictedLocalNative): a *read-only* local file | 39 // - restricted (kFileSystemTypeRestrictedLocalNative): a *read-only* local file |
| 35 // system which can only be accessed by extensions that have full access to | 40 // system which can only be accessed by extensions that have full access to |
| 36 // external file systems (i.e. extensions with fileBrowserPrivate permission). | 41 // external file systems (i.e. extensions with fileBrowserPrivate permission). |
| 37 // - drive (kFileSystemTypeDrive): a file system that provides access to Google | 42 // - drive (kFileSystemTypeDrive): a file system that provides access to Google |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 58 // Root dirs for file systems expected by the test extensions. | 63 // Root dirs for file systems expected by the test extensions. |
| 59 // NOTE: Root dir for drive file system is set by Chrome's drive implementation, | 64 // NOTE: Root dir for drive file system is set by Chrome's drive implementation, |
| 60 // but the test will have to make sure the mount point is added before | 65 // but the test will have to make sure the mount point is added before |
| 61 // starting a test extension using WaitUntilDriveMountPointIsAdded(). | 66 // starting a test extension using WaitUntilDriveMountPointIsAdded(). |
| 62 const char kLocalMountPointName[] = "local"; | 67 const char kLocalMountPointName[] = "local"; |
| 63 const char kRestrictedMountPointName[] = "restricted"; | 68 const char kRestrictedMountPointName[] = "restricted"; |
| 64 | 69 |
| 65 // Default file content for the test files. | 70 // Default file content for the test files. |
| 66 const char kTestFileContent[] = "This is some test content."; | 71 const char kTestFileContent[] = "This is some test content."; |
| 67 | 72 |
| 73 // User account email and directory hash for secondary account for multi-profile | |
| 74 // sensitive test cases. | |
| 75 const char kSecondProfileAccount[] = "profile2@test.com"; | |
| 76 const char kSecondProfileHash[] = "fileBrowserApiTestProfile2"; | |
| 77 | |
| 68 // Sets up the initial file system state for native local and restricted native | 78 // Sets up the initial file system state for native local and restricted native |
| 69 // local file systems. The hierarchy is the same as for the drive file system. | 79 // local file systems. The hierarchy is the same as for the drive file system. |
| 70 // The directory is created at unique_temp_dir/|mount_point_name| path. | 80 // The directory is created at unique_temp_dir/|mount_point_name| path. |
| 71 bool InitializeLocalFileSystem(std::string mount_point_name, | 81 bool InitializeLocalFileSystem(std::string mount_point_name, |
| 72 base::ScopedTempDir* tmp_dir, | 82 base::ScopedTempDir* tmp_dir, |
| 73 base::FilePath* mount_point_dir) { | 83 base::FilePath* mount_point_dir) { |
| 74 if (!tmp_dir->CreateUniqueTempDir()) | 84 if (!tmp_dir->CreateUniqueTempDir()) |
| 75 return false; | 85 return false; |
| 76 | 86 |
| 77 *mount_point_dir = tmp_dir->path().AppendASCII(mount_point_name); | 87 *mount_point_dir = tmp_dir->path().AppendASCII(mount_point_name); |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 service_factory_for_test_; | 504 service_factory_for_test_; |
| 495 }; | 505 }; |
| 496 | 506 |
| 497 // Tests for Drive file systems in multi-profile setting. | 507 // Tests for Drive file systems in multi-profile setting. |
| 498 class MultiProfileDriveFileSystemExtensionApiTest : | 508 class MultiProfileDriveFileSystemExtensionApiTest : |
| 499 public FileSystemExtensionApiTestBase { | 509 public FileSystemExtensionApiTestBase { |
| 500 public: | 510 public: |
| 501 MultiProfileDriveFileSystemExtensionApiTest() : second_profile(NULL) {} | 511 MultiProfileDriveFileSystemExtensionApiTest() : second_profile(NULL) {} |
| 502 | 512 |
| 503 virtual void SetUpOnMainThread() OVERRIDE { | 513 virtual void SetUpOnMainThread() OVERRIDE { |
| 514 base::FilePath user_data_directory; | |
| 515 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); | |
| 516 chromeos::UserManager::Get()->UserLoggedIn(kSecondProfileAccount, | |
| 517 kSecondProfileHash, | |
| 518 false); | |
| 504 // Set up the secondary profile. | 519 // Set up the secondary profile. |
| 505 base::FilePath profile_dir; | 520 base::FilePath profile_dir = |
| 506 base::CreateNewTempDirectory(base::FilePath::StringType(), &profile_dir); | 521 user_data_directory.Append( |
| 507 profile_dir = profile_dir.AppendASCII( | 522 chromeos::ProfileHelper::GetUserProfileDir( |
| 508 std::string(chrome::kProfileDirPrefix) + "fileBrowserApiTestProfile2"); | 523 kSecondProfileHash).BaseName()); |
| 509 second_profile = | 524 second_profile = |
| 510 g_browser_process->profile_manager()->GetProfile(profile_dir); | 525 g_browser_process->profile_manager()->GetProfile(profile_dir); |
| 511 | 526 |
| 512 FileSystemExtensionApiTestBase::SetUpOnMainThread(); | 527 FileSystemExtensionApiTestBase::SetUpOnMainThread(); |
| 513 } | 528 } |
| 514 | 529 |
| 515 virtual void InitTestFileSystem() OVERRIDE { | 530 virtual void InitTestFileSystem() OVERRIDE { |
| 516 // This callback will get called during Profile creation. | 531 // This callback will get called during Profile creation. |
| 517 create_drive_integration_service_ = base::Bind( | 532 create_drive_integration_service_ = base::Bind( |
| 518 &MultiProfileDriveFileSystemExtensionApiTest:: | 533 &MultiProfileDriveFileSystemExtensionApiTest:: |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 ASSERT_TRUE(AddTestHostedDocuments()); | 708 ASSERT_TRUE(AddTestHostedDocuments()); |
| 694 EXPECT_TRUE(RunFileSystemExtensionApiTest( | 709 EXPECT_TRUE(RunFileSystemExtensionApiTest( |
| 695 "file_browser/multi_profile_copy", | 710 "file_browser/multi_profile_copy", |
| 696 FILE_PATH_LITERAL("manifest.json"), | 711 FILE_PATH_LITERAL("manifest.json"), |
| 697 "", | 712 "", |
| 698 FLAGS_NONE)) << message_; | 713 FLAGS_NONE)) << message_; |
| 699 } | 714 } |
| 700 | 715 |
| 701 } // namespace | 716 } // namespace |
| 702 } // namespace file_manager | 717 } // namespace file_manager |
| OLD | NEW |