OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/environment.h" | 5 #include "base/environment.h" |
6 #include "base/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/sys_info.h" | 7 #include "base/sys_info.h" |
8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, | 49 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, |
50 &os_minor_version, | 50 &os_minor_version, |
51 &os_bugfix_version); | 51 &os_bugfix_version); |
52 EXPECT_GT(os_major_version, -1); | 52 EXPECT_GT(os_major_version, -1); |
53 EXPECT_GT(os_minor_version, -1); | 53 EXPECT_GT(os_minor_version, -1); |
54 EXPECT_GT(os_bugfix_version, -1); | 54 EXPECT_GT(os_bugfix_version, -1); |
55 } | 55 } |
56 #endif | 56 #endif |
57 | 57 |
58 TEST_F(SysInfoTest, Uptime) { | 58 TEST_F(SysInfoTest, Uptime) { |
59 int64 up_time_1 = base::SysInfo::Uptime(); | 59 base::TimeDelta up_time_1 = base::SysInfo::Uptime(); |
60 // UpTime() is implemented internally using TimeTicks::Now(), which documents | 60 // UpTime() is implemented internally using TimeTicks::Now(), which documents |
61 // system resolution as being 1-15ms. Sleep a little longer than that. | 61 // system resolution as being 1-15ms. Sleep a little longer than that. |
62 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20)); | 62 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20)); |
63 int64 up_time_2 = base::SysInfo::Uptime(); | 63 base::TimeDelta up_time_2 = base::SysInfo::Uptime(); |
64 EXPECT_GT(up_time_1, 0); | 64 EXPECT_GT(up_time_1.InMicroseconds(), 0); |
65 EXPECT_GT(up_time_2, up_time_1); | 65 EXPECT_GT(up_time_2.InMicroseconds(), up_time_1.InMicroseconds()); |
66 } | 66 } |
67 | 67 |
68 #if defined(OS_MACOSX) && !defined(OS_IOS) | 68 #if defined(OS_MACOSX) && !defined(OS_IOS) |
69 TEST_F(SysInfoTest, HardwareModelName) { | 69 TEST_F(SysInfoTest, HardwareModelName) { |
70 std::string hardware_model = base::SysInfo::HardwareModelName(); | 70 std::string hardware_model = base::SysInfo::HardwareModelName(); |
71 EXPECT_FALSE(hardware_model.empty()); | 71 EXPECT_FALSE(hardware_model.empty()); |
72 } | 72 } |
73 #endif | 73 #endif |
74 | 74 |
75 #if defined(OS_CHROMEOS) | 75 #if defined(OS_CHROMEOS) |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease2, base::Time()); | 146 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease2, base::Time()); |
147 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); | 147 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); |
148 | 148 |
149 const char kLsbRelease3[] = | 149 const char kLsbRelease3[] = |
150 "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | 150 "CHROMEOS_RELEASE_NAME=Chromium OS\n"; |
151 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease3, base::Time()); | 151 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease3, base::Time()); |
152 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); | 152 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); |
153 } | 153 } |
154 | 154 |
155 #endif // OS_CHROMEOS | 155 #endif // OS_CHROMEOS |
OLD | NEW |