Index: chrome/browser/chromeos/login/hwid_checker_unittest.cc |
diff --git a/chrome/browser/chromeos/login/hwid_checker_unittest.cc b/chrome/browser/chromeos/login/hwid_checker_unittest.cc |
index e7d8e1389bf861753dd18ee7cb97ea09568b5df2..6badad83bc89429acd35b4758db576c6e0cdae63 100644 |
--- a/chrome/browser/chromeos/login/hwid_checker_unittest.cc |
+++ b/chrome/browser/chromeos/login/hwid_checker_unittest.cc |
@@ -2,14 +2,14 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/chromeos/login/hwid_checker.h" |
#include "base/sys_info.h" |
#include "base/test/scoped_command_line.h" |
#include "base/time/time.h" |
-#include "chrome/browser/chromeos/scoped_set_running_on_chromeos_for_testing.h" |
+#include "chrome/browser/chromeos/login/hwid_checker.h" |
#include "chromeos/system/fake_statistics_provider.h" |
#include "content/public/common/content_switches.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+ |
namespace chromeos { |
@@ -128,9 +128,14 @@ |
} |
#if defined(GOOGLE_CHROME_BUILD) |
-const char kLsbRelease[] = |
- "CHROMEOS_RELEASE_NAME=Chrome OS\n" |
- "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; |
+ |
+// Sets a valid Chrome OS version info so IsRunningOnChromeOS() returns true. |
+void SetRunningOnChromeOS() { |
+ const char kLsbRelease[] = |
+ "CHROMEOS_RELEASE_NAME=Chrome OS\n" |
+ "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; |
+ base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
+} |
// Test logic for command line "test-type" switch. |
TEST(MachineHWIDCheckerTest, TestSwitch) { |
@@ -141,7 +146,7 @@ |
// THEN IsMachineHWIDCorrect() is always true. |
EXPECT_TRUE(IsMachineHWIDCorrect()); |
- ScopedSetRunningOnChromeOSForTesting fake_release(kLsbRelease, base::Time()); |
+ SetRunningOnChromeOS(); |
EXPECT_TRUE(IsMachineHWIDCorrect()); |
system::ScopedFakeStatisticsProvider fake_statistics_provider; |
@@ -155,7 +160,7 @@ |
// Test logic when not running on Chrome OS. |
TEST(MachineHWIDCheckerTest, NotOnChromeOS) { |
// GIVEN the OS is not Chrome OS. |
- ScopedSetRunningOnChromeOSForTesting fake_release("", base::Time()); |
+ base::SysInfo::SetChromeOSVersionInfoForTest("", base::Time()); |
// THEN IsMachineHWIDCorrect() is always true. |
EXPECT_TRUE(IsMachineHWIDCorrect()); |
@@ -171,7 +176,7 @@ |
// Test logic when running on Chrome OS but the HWID is not present. |
TEST(MachineHWIDCheckerTest, OnCrosNoHWID) { |
// GIVEN the OS is Chrome OS. |
- ScopedSetRunningOnChromeOSForTesting fake_release(kLsbRelease, base::Time()); |
+ SetRunningOnChromeOS(); |
// GIVEN the HWID is not present. |
system::ScopedFakeStatisticsProvider fake_statistics_provider; |
@@ -199,7 +204,7 @@ |
"DELL HORIZON MAGENTA DVT 4770"); |
// THEN IsMachineHWIDCorrect() is always true. |
- ScopedSetRunningOnChromeOSForTesting fake_release(kLsbRelease, base::Time()); |
+ SetRunningOnChromeOS(); |
EXPECT_TRUE(IsMachineHWIDCorrect()); |
fake_statistics_provider.SetMachineStatistic(system::kIsVmKey, |
system::kIsVmValueFalse); |
@@ -217,7 +222,7 @@ |
system::kIsVmValueTrue); |
// GIVEN the OS is Chrome OS. |
- ScopedSetRunningOnChromeOSForTesting fake_release(kLsbRelease, base::Time()); |
+ SetRunningOnChromeOS(); |
// THEN IsMachineHWIDCorrect() is always true. |
fake_statistics_provider.SetMachineStatistic(system::kHardwareClassKey, |
"INVALID_HWID"); |
@@ -234,7 +239,7 @@ |
// Test logic when HWID is invalid and we're not in a VM. |
TEST(MachineHWIDCheckerTest, InvalidHWIDInVMNotTrue) { |
// GIVEN the OS is Chrome OS. |
- ScopedSetRunningOnChromeOSForTesting fake_release(kLsbRelease, base::Time()); |
+ SetRunningOnChromeOS(); |
// GIVEN the HWID is invalid. |
system::ScopedFakeStatisticsProvider fake_statistics_provider; |