chrome_paths_lacros_unittest.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2020 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.
  4. #include "chrome/common/chrome_paths_internal.h"
  5. #include "base/files/file_path.h"
  6. #include "base/path_service.h"
  7. #include "base/test/scoped_path_override.h"
  8. #include "base/test/scoped_running_on_chromeos.h"
  9. #include "chrome/common/chrome_paths.h"
  10. #include "testing/gtest/include/gtest/gtest.h"
  11. namespace chrome {
  12. namespace {
  13. TEST(ChromePaths, UserDataDirectoryIsInsideEncryptedPartition) {
  14. // Force paths to behave like they do on device.
  15. base::test::ScopedRunningOnChromeOS running_on_chromeos;
  16. base::FilePath user_data_dir;
  17. ASSERT_TRUE(GetDefaultUserDataDirectory(&user_data_dir));
  18. // The Lacros user data directory contains profile information, including
  19. // credentials. It must be inside the encrypted system user partition.
  20. base::FilePath home_chronos_user("/home/chronos/user");
  21. EXPECT_TRUE(home_chronos_user.IsParent(user_data_dir));
  22. }
  23. TEST(ChromePaths, DownloadsDirectoryRestoredAfterScopedPathOverride) {
  24. base::FilePath original_path;
  25. base::PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &original_path);
  26. {
  27. // Override with a temp directory.
  28. base::ScopedPathOverride override(chrome::DIR_DEFAULT_DOWNLOADS);
  29. base::FilePath new_path;
  30. base::PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &new_path);
  31. EXPECT_NE(original_path, new_path);
  32. }
  33. // Original path is restored.
  34. base::FilePath restored_path;
  35. base::PathService::Get(chrome::DIR_DEFAULT_DOWNLOADS, &restored_path);
  36. EXPECT_EQ(original_path, restored_path);
  37. }
  38. } // namespace
  39. } // namespace chrome