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 5 #include "chrome/common/chrome_paths_internal.h" 6 7 #include "base/files/file_path.h" 8 #include "base/system/sys_info.h" 9 #include "base/time/time.h" 10 #include "chromeos/crosapi/cpp/crosapi_constants.h" 11 #include "testing/gtest/include/gtest/gtest.h" 12 13 namespace chrome { 14 namespace { 15 16 const char kLsbRelease[] = 17 "CHROMEOS_RELEASE_NAME=Chrome OS\n" 18 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; 19 20 // Overrides base::SysInfo::IsRunningOnChromeOS() to return true. 21 class ScopedIsRunningOnChromeOS { 22 public: ScopedIsRunningOnChromeOS()23 ScopedIsRunningOnChromeOS() { 24 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 25 } ~ScopedIsRunningOnChromeOS()26 ~ScopedIsRunningOnChromeOS() { 27 base::SysInfo::SetChromeOSVersionInfoForTest("", base::Time()); 28 } 29 }; 30 TEST(ChromePaths,UserDataDirectoryIsInsideEncryptedPartition)31TEST(ChromePaths, UserDataDirectoryIsInsideEncryptedPartition) { 32 // Force paths to behave like they do on device. 33 ScopedIsRunningOnChromeOS is_running_on_chromeos; 34 base::FilePath user_data_dir; 35 ASSERT_TRUE(GetDefaultUserDataDirectory(&user_data_dir)); 36 // The Lacros user data directory contains profile information, including 37 // credentials. It must be inside the encrypted system user partition. 38 base::FilePath home_chronos_user(crosapi::kHomeChronosUserPath); 39 EXPECT_TRUE(home_chronos_user.IsParent(user_data_dir)); 40 } 41 42 } // namespace 43 } // namespace chrome 44