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