#include "base/files/file_enumerator.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/test/test_file_util.h"
#include "base/threading/thread_restrictions.h"
#include "base/values.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/policy/policy_test_utils.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/download/public/common/download_item.h"
#include "components/policy/core/common/policy_map.h"
#include "components/policy/policy_constants.h"
#include "components/prefs/pref_service.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/download_manager.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/download_test_observer.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/ash/drive/drive_integration_service.h"
#endif
namespace policy {
namespace {
void DownloadAndVerifyFile(Browser* browser,
const base::FilePath& dir,
const base::FilePath& file) { … }
}
IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory_Drive) {
{
PolicyMap policies;
policies.Set(key::kDownloadDirectory, POLICY_LEVEL_RECOMMENDED,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
base::Value("${google_drive}/"), nullptr);
UpdateProviderPolicy(policies);
EXPECT_EQ(drive::DriveIntegrationServiceFactory::FindForProfile(
browser()->profile())
->GetMountPointPath()
.AppendASCII("root"),
DownloadPrefs(browser()->profile())
.DownloadPath()
.StripTrailingSeparators());
}
PolicyMap policies;
policies.Set(key::kDownloadDirectory, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_USER, POLICY_SOURCE_CLOUD,
base::Value("${google_drive}/Downloads"), nullptr);
UpdateProviderPolicy(policies);
EXPECT_EQ(drive::DriveIntegrationServiceFactory::FindForProfile(
browser()->profile())
->GetMountPointPath()
.AppendASCII("root/Downloads"),
DownloadPrefs(browser()->profile())
.DownloadPath()
.StripTrailingSeparators());
}
#endif
}