Chromium Code Reviews| 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) | |
| 69 TEST_F(SysInfoTest, HardwareModelName) { | |
| 70 std::string hardware_model = | |
| 71 base::SysInfo::HardwareModelName(); | |
|
Mark Mentovai
2014/11/04 14:36:37
This would definitely fit on one line.
jeremy
2014/11/05 05:38:06
Done.
| |
| 72 EXPECT_GT(hardware_model.length(), 0U); | |
|
Mark Mentovai
2014/11/04 14:36:37
You can just EXPECT_FALSE(hardware_model.empty()).
jeremy
2014/11/05 05:38:06
Done.
| |
| 73 } | |
| 74 #endif | |
| 75 | |
| 68 #if defined(OS_CHROMEOS) | 76 #if defined(OS_CHROMEOS) |
| 69 | 77 |
| 70 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) { | 78 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) { |
| 71 int32 os_major_version = -1; | 79 int32 os_major_version = -1; |
| 72 int32 os_minor_version = -1; | 80 int32 os_minor_version = -1; |
| 73 int32 os_bugfix_version = -1; | 81 int32 os_bugfix_version = -1; |
| 74 const char kLsbRelease[] = | 82 const char kLsbRelease[] = |
| 75 "FOO=1234123.34.5\n" | 83 "FOO=1234123.34.5\n" |
| 76 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; | 84 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; |
| 77 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); | 85 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()); | 147 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease2, base::Time()); |
| 140 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); | 148 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); |
| 141 | 149 |
| 142 const char kLsbRelease3[] = | 150 const char kLsbRelease3[] = |
| 143 "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | 151 "CHROMEOS_RELEASE_NAME=Chromium OS\n"; |
| 144 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease3, base::Time()); | 152 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease3, base::Time()); |
| 145 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); | 153 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); |
| 146 } | 154 } |
| 147 | 155 |
| 148 #endif // OS_CHROMEOS | 156 #endif // OS_CHROMEOS |
| OLD | NEW |