Commit 481569c8 authored by Luciano Pacheco's avatar Luciano Pacheco Committed by Commit Bot

Fix Downloads path when MyFilesVolume is enabled

When MyFilesVolume is enabled and the its volume is already mounted
|GetDownloadsFolderForProfile| was returning actually MyFiles path
instead of MyFiles/Downloads path, this CL fixes this.

Bug: 873539
Change-Id: I099f788a6d067dce4857a6b4946808559799b45d
Reviewed-on: https://chromium-review.googlesource.com/c/1352070Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Luciano Pacheco <lucmult@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611504}
parent 18f6587b
...@@ -115,8 +115,12 @@ base::FilePath GetDownloadsFolderForProfile(Profile* profile) { ...@@ -115,8 +115,12 @@ base::FilePath GetDownloadsFolderForProfile(Profile* profile) {
storage::ExternalMountPoints* const mount_points = storage::ExternalMountPoints* const mount_points =
storage::ExternalMountPoints::GetSystemInstance(); storage::ExternalMountPoints::GetSystemInstance();
base::FilePath path; base::FilePath path;
if (mount_points->GetRegisteredPath(mount_point_name, &path)) if (mount_points->GetRegisteredPath(mount_point_name, &path)) {
if (base::FeatureList::IsEnabled(chromeos::features::kMyFilesVolume))
return path.AppendASCII(kFolderNameDownloads);
return path; return path;
}
// Return $HOME/Downloads as Download folder. // Return $HOME/Downloads as Download folder.
if (ShouldMountPrimaryUserDownloads(profile)) if (ShouldMountPrimaryUserDownloads(profile))
......
...@@ -87,10 +87,6 @@ TEST(FileManagerPathUtilTest, GetMyFilesFolderForProfile) { ...@@ -87,10 +87,6 @@ TEST(FileManagerPathUtilTest, GetMyFilesFolderForProfile) {
base::test::ScopedFeatureList feature_list; base::test::ScopedFeatureList feature_list;
feature_list.InitAndEnableFeature(chromeos::features::kMyFilesVolume); feature_list.InitAndEnableFeature(chromeos::features::kMyFilesVolume);
base::FilePath myfiles_path = profile_path.AppendASCII("MyFiles");
base::FilePath myfiles_downloads_path =
myfiles_path.AppendASCII("Downloads");
EXPECT_EQ("/home/chronos/u-0123456789abcdef/MyFiles", EXPECT_EQ("/home/chronos/u-0123456789abcdef/MyFiles",
GetMyFilesFolderForProfile(&profile).value()); GetMyFilesFolderForProfile(&profile).value());
EXPECT_EQ("/home/chronos/u-0123456789abcdef/MyFiles/Downloads", EXPECT_EQ("/home/chronos/u-0123456789abcdef/MyFiles/Downloads",
...@@ -102,10 +98,39 @@ TEST(FileManagerPathUtilTest, GetMyFilesFolderForProfile) { ...@@ -102,10 +98,39 @@ TEST(FileManagerPathUtilTest, GetMyFilesFolderForProfile) {
storage::kFileSystemTypeNativeLocal, storage::FileSystemMountOption(), storage::kFileSystemTypeNativeLocal, storage::FileSystemMountOption(),
profile_path.Append("MyFiles")); profile_path.Append("MyFiles"));
// When returning from the mount_point Downloads should still point to
// MyFiles/Downloads.
EXPECT_EQ("/home/chronos/u-0123456789abcdef/MyFiles/Downloads",
GetDownloadsFolderForProfile(&profile).value());
// Still the same: /home/u-{hash}/MyFiles. // Still the same: /home/u-{hash}/MyFiles.
EXPECT_EQ("/home/chronos/u-0123456789abcdef/MyFiles", EXPECT_EQ("/home/chronos/u-0123456789abcdef/MyFiles",
GetMyFilesFolderForProfile(&profile).value()); GetMyFilesFolderForProfile(&profile).value());
} }
{
// Remove mount configured to MyFiles in the previous test.
storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem(
GetDownloadsMountPointName(&profile));
// Add mount point for Downloads instead of MyFiles.
storage::ExternalMountPoints::GetSystemInstance()->RegisterFileSystem(
GetDownloadsMountPointName(&profile),
storage::kFileSystemTypeNativeLocal, storage::FileSystemMountOption(),
profile_path.Append("Downloads"));
// Disable MyFilesVolume again to test returning from the mount_point.
base::test::ScopedFeatureList feature_list;
feature_list.InitAndDisableFeature(chromeos::features::kMyFilesVolume);
// When MyFilesVolume feature is disabled it will return the same as
// Downloads.
EXPECT_EQ(GetDownloadsFolderForProfile(&profile),
GetMyFilesFolderForProfile(&profile));
EXPECT_EQ("/home/chronos/u-0123456789abcdef/Downloads",
GetDownloadsFolderForProfile(&profile).value());
// Unmount Downloads because it was interfering with other tests.
storage::ExternalMountPoints::GetSystemInstance()->RevokeFileSystem(
GetDownloadsMountPointName(&profile));
}
} }
TEST(FileManagerPathUtilTest, GetPathDisplayTextForSettings) { TEST(FileManagerPathUtilTest, GetPathDisplayTextForSettings) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment