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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 TEST_F(SysInfoTest, Uptime) { | 58 TEST_F(SysInfoTest, Uptime) { |
59 int64 up_time_1 = base::SysInfo::Uptime(); | 59 int64 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 int64 up_time_2 = base::SysInfo::Uptime(); |
64 EXPECT_GT(up_time_1, 0); | 64 EXPECT_GT(up_time_1, 0); |
65 EXPECT_GT(up_time_2, up_time_1); | 65 EXPECT_GT(up_time_2, up_time_1); |
66 } | 66 } |
67 | 67 |
| 68 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 69 TEST_F(SysInfoTest, HardwareModelName) { |
| 70 std::string hardware_model = base::SysInfo::HardwareModelName(); |
| 71 EXPECT_FALSE(hardware_model.empty()); |
| 72 } |
| 73 #endif |
| 74 |
68 #if defined(OS_CHROMEOS) | 75 #if defined(OS_CHROMEOS) |
69 | 76 |
70 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) { | 77 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) { |
71 int32 os_major_version = -1; | 78 int32 os_major_version = -1; |
72 int32 os_minor_version = -1; | 79 int32 os_minor_version = -1; |
73 int32 os_bugfix_version = -1; | 80 int32 os_bugfix_version = -1; |
74 const char kLsbRelease[] = | 81 const char kLsbRelease[] = |
75 "FOO=1234123.34.5\n" | 82 "FOO=1234123.34.5\n" |
76 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; | 83 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; |
77 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | 84 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease2, base::Time()); | 146 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease2, base::Time()); |
140 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); | 147 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); |
141 | 148 |
142 const char kLsbRelease3[] = | 149 const char kLsbRelease3[] = |
143 "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | 150 "CHROMEOS_RELEASE_NAME=Chromium OS\n"; |
144 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease3, base::Time()); | 151 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease3, base::Time()); |
145 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); | 152 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); |
146 } | 153 } |
147 | 154 |
148 #endif // OS_CHROMEOS | 155 #endif // OS_CHROMEOS |
OLD | NEW |