1 // Copyright 2020 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef BASE_TEST_SCOPED_CHROMEOS_VERSION_INFO_H_ 6 #define BASE_TEST_SCOPED_CHROMEOS_VERSION_INFO_H_ 7 8 #include <string_view> 9 10 #include "base/time/time.h" 11 12 namespace base { 13 namespace test { 14 15 // Test helper that temporarily overrides the cached lsb-release data. 16 // NOTE: Must be created on the main thread before any other threads are 17 // started. Cannot be nested. 18 class ScopedChromeOSVersionInfo { 19 public: 20 // Overrides |lsb_release| and |lsb_release_time|. For example, can be used to 21 // simulate a specific OS version. Note that |lsb_release| must contain 22 // CHROMEOS_RELEASE_NAME to make base::SysInfo::IsRunningOnChromeOS() return 23 // true. 24 ScopedChromeOSVersionInfo(std::string_view lsb_release, 25 Time lsb_release_time); 26 ScopedChromeOSVersionInfo(const ScopedChromeOSVersionInfo&) = delete; 27 ScopedChromeOSVersionInfo& operator=(const ScopedChromeOSVersionInfo&) = 28 delete; 29 ~ScopedChromeOSVersionInfo(); 30 }; 31 32 } // namespace test 33 } // namespace base 34 35 #endif // BASE_TEST_SCOPED_CHROMEOS_VERSION_INFO_H_ 36