Index: chrome/browser/chromeos/drive/file_system_core_util_unittest.cc |
diff --git a/chrome/browser/chromeos/drive/file_system_util_unittest.cc b/chrome/browser/chromeos/drive/file_system_core_util_unittest.cc |
similarity index 63% |
copy from chrome/browser/chromeos/drive/file_system_util_unittest.cc |
copy to chrome/browser/chromeos/drive/file_system_core_util_unittest.cc |
index e18101ee178afddd1858c285f1189efdf852f125..4a73825f246d8e25ca3b4b19fc8206173b75463e 100644 |
--- a/chrome/browser/chromeos/drive/file_system_util_unittest.cc |
+++ b/chrome/browser/chromeos/drive/file_system_core_util_unittest.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/chromeos/drive/file_system_util.h" |
+#include "chrome/browser/chromeos/drive/file_system_core_util.h" |
#include <vector> |
@@ -12,10 +12,8 @@ |
#include "base/single_thread_task_runner.h" |
#include "base/strings/utf_string_conversions.h" |
#include "base/thread_task_runner_handle.h" |
-#include "chrome/browser/chromeos/profiles/profile_helper.h" |
-#include "chrome/test/base/testing_browser_process.h" |
+#include "chrome/browser/chromeos/drive/file_system_util.h" |
#include "chrome/test/base/testing_profile.h" |
-#include "chrome/test/base/testing_profile_manager.h" |
#include "content/public/test/test_browser_thread_bundle.h" |
#include "content/public/test/test_file_system_options.h" |
#include "google_apis/drive/test_util.h" |
@@ -29,55 +27,6 @@ |
namespace drive { |
namespace util { |
-namespace { |
- |
-// Sets up ProfileManager for testing and marks the current thread as UI by |
-// TestBrowserThreadBundle. We need the thread since Profile objects must be |
-// touched from UI and hence has CHECK/DCHECKs for it. |
-class ProfileRelatedFileSystemUtilTest : public testing::Test { |
- protected: |
- ProfileRelatedFileSystemUtilTest() |
- : testing_profile_manager_(TestingBrowserProcess::GetGlobal()) { |
- } |
- |
- void SetUp() override { ASSERT_TRUE(testing_profile_manager_.SetUp()); } |
- |
- TestingProfileManager& testing_profile_manager() { |
- return testing_profile_manager_; |
- } |
- |
- private: |
- content::TestBrowserThreadBundle thread_bundle_; |
- TestingProfileManager testing_profile_manager_; |
-}; |
- |
-} // namespace |
- |
-TEST_F(ProfileRelatedFileSystemUtilTest, GetDriveMountPointPath) { |
- Profile* profile = testing_profile_manager().CreateTestingProfile("user1"); |
- const std::string user_id_hash = |
- chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1"); |
- EXPECT_EQ(base::FilePath::FromUTF8Unsafe("/special/drive-" + user_id_hash), |
- GetDriveMountPointPath(profile)); |
-} |
- |
-TEST_F(ProfileRelatedFileSystemUtilTest, ExtractProfileFromPath) { |
- Profile* profile1 = testing_profile_manager().CreateTestingProfile("user1"); |
- Profile* profile2 = testing_profile_manager().CreateTestingProfile("user2"); |
- const std::string user1_id_hash = |
- chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user1"); |
- const std::string user2_id_hash = |
- chromeos::ProfileHelper::GetUserIdHashByUserIdForTesting("user2"); |
- EXPECT_EQ(profile1, |
- ExtractProfileFromPath(base::FilePath::FromUTF8Unsafe( |
- "/special/drive-" + user1_id_hash))); |
- EXPECT_EQ(profile2, |
- ExtractProfileFromPath(base::FilePath::FromUTF8Unsafe( |
- "/special/drive-" + user2_id_hash + "/root/xxx"))); |
- EXPECT_EQ(NULL, ExtractProfileFromPath( |
- base::FilePath::FromUTF8Unsafe("/special/non-drive-path"))); |
-} |
- |
class FileSystemUtilTest : public testing::Test { |
content::TestBrowserThreadBundle thread_bundle_; |
}; |
@@ -90,8 +39,8 @@ TEST_F(FileSystemUtilTest, IsUnderDriveMountPoint) { |
EXPECT_FALSE(IsUnderDriveMountPoint( |
base::FilePath::FromUTF8Unsafe("special/drive/foo.txt"))); |
- EXPECT_TRUE(IsUnderDriveMountPoint( |
- base::FilePath::FromUTF8Unsafe("/special/drive"))); |
+ EXPECT_TRUE( |
+ IsUnderDriveMountPoint(base::FilePath::FromUTF8Unsafe("/special/drive"))); |
EXPECT_TRUE(IsUnderDriveMountPoint( |
base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); |
EXPECT_TRUE(IsUnderDriveMountPoint( |
@@ -101,16 +50,15 @@ TEST_F(FileSystemUtilTest, IsUnderDriveMountPoint) { |
} |
TEST_F(FileSystemUtilTest, ExtractDrivePath) { |
- EXPECT_EQ(base::FilePath(), |
- ExtractDrivePath( |
- base::FilePath::FromUTF8Unsafe("/wherever/foo.txt"))); |
- EXPECT_EQ(base::FilePath(), |
- ExtractDrivePath( |
- base::FilePath::FromUTF8Unsafe("/special/foo.txt"))); |
+ EXPECT_EQ( |
+ base::FilePath(), |
+ ExtractDrivePath(base::FilePath::FromUTF8Unsafe("/wherever/foo.txt"))); |
+ EXPECT_EQ( |
+ base::FilePath(), |
+ ExtractDrivePath(base::FilePath::FromUTF8Unsafe("/special/foo.txt"))); |
EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive"), |
- ExtractDrivePath( |
- base::FilePath::FromUTF8Unsafe("/special/drive"))); |
+ ExtractDrivePath(base::FilePath::FromUTF8Unsafe("/special/drive"))); |
EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo.txt"), |
ExtractDrivePath( |
base::FilePath::FromUTF8Unsafe("/special/drive/foo.txt"))); |
@@ -134,8 +82,7 @@ TEST_F(FileSystemUtilTest, ExtractDrivePathFromFileSystemUrl) { |
scoped_refptr<storage::FileSystemContext> context( |
new storage::FileSystemContext( |
base::ThreadTaskRunnerHandle::Get().get(), |
- base::ThreadTaskRunnerHandle::Get().get(), |
- mount_points.get(), |
+ base::ThreadTaskRunnerHandle::Get().get(), mount_points.get(), |
NULL, // special_storage_policy |
NULL, // quota_manager_proxy, |
ScopedVector<storage::FileSystemBackend>(), |
@@ -146,20 +93,17 @@ TEST_F(FileSystemUtilTest, ExtractDrivePathFromFileSystemUrl) { |
// Type:"external" + virtual_path:"drive/foo/bar" resolves to "drive/foo/bar". |
const std::string& drive_mount_name = |
GetDriveMountPointPath(&profile).BaseName().AsUTF8Unsafe(); |
- mount_points->RegisterFileSystem(drive_mount_name, |
- storage::kFileSystemTypeDrive, |
- storage::FileSystemMountOption(), |
- GetDriveMountPointPath(&profile)); |
- EXPECT_EQ( |
- base::FilePath::FromUTF8Unsafe("drive/foo/bar"), |
- ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( |
- "filesystem:chrome-extension://dummy-id/external/" + |
- drive_mount_name + "/foo/bar")))); |
+ mount_points->RegisterFileSystem( |
+ drive_mount_name, storage::kFileSystemTypeDrive, |
+ storage::FileSystemMountOption(), GetDriveMountPointPath(&profile)); |
+ EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/foo/bar"), |
+ ExtractDrivePathFromFileSystemUrl(context->CrackURL( |
+ GURL("filesystem:chrome-extension://dummy-id/external/" + |
+ drive_mount_name + "/foo/bar")))); |
// Virtual mount name should not affect the extracted path. |
mount_points->RevokeFileSystem(drive_mount_name); |
- mount_points->RegisterFileSystem("drive2", |
- storage::kFileSystemTypeDrive, |
+ mount_points->RegisterFileSystem("drive2", storage::kFileSystemTypeDrive, |
storage::FileSystemMountOption(), |
GetDriveMountPointPath(&profile)); |
EXPECT_EQ( |
@@ -168,10 +112,9 @@ TEST_F(FileSystemUtilTest, ExtractDrivePathFromFileSystemUrl) { |
"filesystem:chrome-extension://dummy-id/external/drive2/foo/bar")))); |
// Type:"external" + virtual_path:"Downloads/foo" is not a Drive path. |
- mount_points->RegisterFileSystem("Downloads", |
- storage::kFileSystemTypeNativeLocal, |
- storage::FileSystemMountOption(), |
- temp_dir_.path()); |
+ mount_points->RegisterFileSystem( |
+ "Downloads", storage::kFileSystemTypeNativeLocal, |
+ storage::FileSystemMountOption(), temp_dir_.path()); |
EXPECT_EQ( |
base::FilePath(), |
ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( |
@@ -181,15 +124,13 @@ TEST_F(FileSystemUtilTest, ExtractDrivePathFromFileSystemUrl) { |
std::string isolated_name; |
std::string isolated_id = |
storage::IsolatedContext::GetInstance()->RegisterFileSystemForPath( |
- storage::kFileSystemTypeNativeForPlatformApp, |
- std::string(), |
+ storage::kFileSystemTypeNativeForPlatformApp, std::string(), |
GetDriveMountPointPath(&profile).AppendASCII("bar/buz"), |
&isolated_name); |
- EXPECT_EQ( |
- base::FilePath::FromUTF8Unsafe("drive/bar/buz"), |
- ExtractDrivePathFromFileSystemUrl(context->CrackURL(GURL( |
- "filesystem:chrome-extension://dummy-id/isolated/" + |
- isolated_id + "/" + isolated_name)))); |
+ EXPECT_EQ(base::FilePath::FromUTF8Unsafe("drive/bar/buz"), |
+ ExtractDrivePathFromFileSystemUrl(context->CrackURL( |
+ GURL("filesystem:chrome-extension://dummy-id/isolated/" + |
+ isolated_id + "/" + isolated_name)))); |
} |
TEST_F(FileSystemUtilTest, EscapeUnescapeCacheFileName) { |
@@ -217,19 +158,13 @@ TEST_F(FileSystemUtilTest, NormalizeFileName) { |
EXPECT_EQ("._", NormalizeFileName("./")); |
} |
-TEST_F(FileSystemUtilTest, GetCacheRootPath) { |
- TestingProfile profile; |
- base::FilePath profile_path = profile.GetPath(); |
- EXPECT_EQ(profile_path.AppendASCII("GCache/v1"), |
- util::GetCacheRootPath(&profile)); |
-} |
- |
TEST_F(FileSystemUtilTest, GDocFile) { |
base::ScopedTempDir temp_dir; |
ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
- GURL url("https://docs.google.com/document/d/" |
- "1YsCnrMxxgp7LDdtlFDt-WdtEIth89vA9inrILtvK-Ug/edit"); |
+ GURL url( |
+ "https://docs.google.com/document/d/" |
+ "1YsCnrMxxgp7LDdtlFDt-WdtEIth89vA9inrILtvK-Ug/edit"); |
std::string resource_id("1YsCnrMxxgp7LDdtlFDt-WdtEIth89vA9inrILtvK-Ug"); |
// Read and write gdoc. |