scoped_chromeos_version_info.h 1.2 KB

123456789101112131415161718192021222324252627282930313233
  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. #ifndef BASE_TEST_SCOPED_CHROMEOS_VERSION_INFO_H_
  5. #define BASE_TEST_SCOPED_CHROMEOS_VERSION_INFO_H_
  6. #include "base/strings/string_piece.h"
  7. #include "base/time/time.h"
  8. namespace base {
  9. namespace test {
  10. // Test helper that temporarily overrides the cached lsb-release data.
  11. // NOTE: Must be created on the main thread before any other threads are
  12. // started. Cannot be nested.
  13. class ScopedChromeOSVersionInfo {
  14. public:
  15. // Overrides |lsb_release| and |lsb_release_time|. For example, can be used to
  16. // simulate a specific OS version. Note that |lsb_release| must contain
  17. // CHROMEOS_RELEASE_NAME to make base::SysInfo::IsRunningOnChromeOS() return
  18. // true.
  19. ScopedChromeOSVersionInfo(StringPiece lsb_release, Time lsb_release_time);
  20. ScopedChromeOSVersionInfo(const ScopedChromeOSVersionInfo&) = delete;
  21. ScopedChromeOSVersionInfo& operator=(const ScopedChromeOSVersionInfo&) =
  22. delete;
  23. ~ScopedChromeOSVersionInfo();
  24. };
  25. } // namespace test
  26. } // namespace base
  27. #endif // BASE_TEST_SCOPED_CHROMEOS_VERSION_INFO_H_