1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/file_manager/path_util.h"
7 #include "base/files/file_path.h"
8 #include "chrome/browser/download/download_prefs.h"
9 #include "chrome/test/base/testing_profile.h"
10 #include "testing/gtest/include/gtest/gtest.h"
12 namespace file_manager
{
16 TEST(FileManagerPathUtilTest
, MultiProfileDownloadsFolderMigration
) {
17 TestingProfile profile
;
19 // This looks like "/home/chronos/u-hash/Downloads" in the production
21 const base::FilePath kDownloads
= GetDownloadsFolderForProfile(&profile
);
22 const base::FilePath kOldDownloads
=
23 DownloadPrefs::GetDefaultDownloadDirectory();
27 EXPECT_TRUE(MigratePathFromOldFormat(&profile
, kOldDownloads
, &path
));
28 EXPECT_EQ(kDownloads
, path
);
30 EXPECT_TRUE(MigratePathFromOldFormat(
32 kOldDownloads
.AppendASCII("a/b"),
34 EXPECT_EQ(kDownloads
.AppendASCII("a/b"), path
);
36 // Path already in the new format is not converted.
37 EXPECT_FALSE(MigratePathFromOldFormat(
39 kDownloads
.AppendASCII("a/b"),
42 // Only the "Downloads" path is converted.
43 EXPECT_FALSE(MigratePathFromOldFormat(
45 base::FilePath::FromUTF8Unsafe("/home/chronos/user/dl"),
51 } // namespace file_manager