| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include "base/environment.h" | 7 #include "base/environment.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/process/process_metrics.h" | 9 #include "base/process/process_metrics.h" |
| 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/strings/string_split.h" |
| 10 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
| 11 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 12 #include "base/time/time.h" | 14 #include "base/time/time.h" |
| 13 #include "build/build_config.h" | 15 #include "build/build_config.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
| 16 | 18 |
| 17 namespace base { | 19 namespace base { |
| 18 | 20 |
| 19 using SysInfoTest = PlatformTest; | 21 using SysInfoTest = PlatformTest; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 TEST_F(SysInfoTest, Uptime) { | 90 TEST_F(SysInfoTest, Uptime) { |
| 89 TimeDelta up_time_1 = SysInfo::Uptime(); | 91 TimeDelta up_time_1 = SysInfo::Uptime(); |
| 90 // UpTime() is implemented internally using TimeTicks::Now(), which documents | 92 // UpTime() is implemented internally using TimeTicks::Now(), which documents |
| 91 // system resolution as being 1-15ms. Sleep a little longer than that. | 93 // system resolution as being 1-15ms. Sleep a little longer than that. |
| 92 PlatformThread::Sleep(TimeDelta::FromMilliseconds(20)); | 94 PlatformThread::Sleep(TimeDelta::FromMilliseconds(20)); |
| 93 TimeDelta up_time_2 = SysInfo::Uptime(); | 95 TimeDelta up_time_2 = SysInfo::Uptime(); |
| 94 EXPECT_GT(up_time_1.InMicroseconds(), 0); | 96 EXPECT_GT(up_time_1.InMicroseconds(), 0); |
| 95 EXPECT_GT(up_time_2.InMicroseconds(), up_time_1.InMicroseconds()); | 97 EXPECT_GT(up_time_2.InMicroseconds(), up_time_1.InMicroseconds()); |
| 96 } | 98 } |
| 97 | 99 |
| 98 #if defined(OS_MACOSX) && !defined(OS_IOS) | 100 #if defined(OS_MACOSX) |
| 99 TEST_F(SysInfoTest, HardwareModelName) { | 101 TEST_F(SysInfoTest, HardwareModelNameFormatMacAndiOS) { |
| 100 std::string hardware_model = SysInfo::HardwareModelName(); | 102 std::string hardware_model = SysInfo::HardwareModelName(); |
| 101 EXPECT_FALSE(hardware_model.empty()); | 103 ASSERT_FALSE(hardware_model.empty()); |
| 104 // Check that the model is of the expected format "Foo,Bar" where "Bar" is |
| 105 // a number. |
| 106 std::vector<StringPiece> pieces = |
| 107 SplitStringPiece(hardware_model, ",", KEEP_WHITESPACE, SPLIT_WANT_ALL); |
| 108 ASSERT_EQ(2u, pieces.size()) << hardware_model; |
| 109 int value; |
| 110 EXPECT_TRUE(StringToInt(pieces[1], &value)) << hardware_model; |
| 102 } | 111 } |
| 103 #endif | 112 #endif |
| 104 | 113 |
| 105 #if defined(OS_CHROMEOS) | 114 #if defined(OS_CHROMEOS) |
| 106 | 115 |
| 107 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) { | 116 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) { |
| 108 int32_t os_major_version = -1; | 117 int32_t os_major_version = -1; |
| 109 int32_t os_minor_version = -1; | 118 int32_t os_minor_version = -1; |
| 110 int32_t os_bugfix_version = -1; | 119 int32_t os_bugfix_version = -1; |
| 111 const char kLsbRelease[] = | 120 const char kLsbRelease[] = |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 EXPECT_EQ("glimmer", SysInfo::GetStrippedReleaseBoard()); | 197 EXPECT_EQ("glimmer", SysInfo::GetStrippedReleaseBoard()); |
| 189 | 198 |
| 190 const char* kLsbRelease2 = "CHROMEOS_RELEASE_BOARD=glimmer-signed-mp-v4keys"; | 199 const char* kLsbRelease2 = "CHROMEOS_RELEASE_BOARD=glimmer-signed-mp-v4keys"; |
| 191 SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease2, Time()); | 200 SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease2, Time()); |
| 192 EXPECT_EQ("glimmer", SysInfo::GetStrippedReleaseBoard()); | 201 EXPECT_EQ("glimmer", SysInfo::GetStrippedReleaseBoard()); |
| 193 } | 202 } |
| 194 | 203 |
| 195 #endif // OS_CHROMEOS | 204 #endif // OS_CHROMEOS |
| 196 | 205 |
| 197 } // namespace base | 206 } // namespace base |
| OLD | NEW |