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 "content/public/test/test_browser_thread_bundle.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace file_manager
{
17 TEST(FileManagerPathUtilTest
, MultiProfileDownloadsFolderMigration
) {
18 content::TestBrowserThreadBundle thread_bundle
;
19 TestingProfile profile
;
21 // This looks like "/home/chronos/u-hash/Downloads" in the production
23 const base::FilePath kDownloads
= GetDownloadsFolderForProfile(&profile
);
24 const base::FilePath kOldDownloads
=
25 DownloadPrefs::GetDefaultDownloadDirectory();
29 EXPECT_TRUE(MigratePathFromOldFormat(&profile
, kOldDownloads
, &path
));
30 EXPECT_EQ(kDownloads
, path
);
32 EXPECT_TRUE(MigratePathFromOldFormat(
34 kOldDownloads
.AppendASCII("a/b"),
36 EXPECT_EQ(kDownloads
.AppendASCII("a/b"), path
);
38 // Path already in the new format is not converted.
39 EXPECT_FALSE(MigratePathFromOldFormat(
41 kDownloads
.AppendASCII("a/b"),
44 // Only the "Downloads" path is converted.
45 EXPECT_FALSE(MigratePathFromOldFormat(
47 base::FilePath::FromUTF8Unsafe("/home/chronos/user/dl"),
53 } // namespace file_manager