| 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" |
| 11 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
| 12 | 12 |
| 13 #if defined(OS_WIN) |
| 14 #include "base/win/windows_version.h" |
| 15 #endif |
| 16 |
| 13 typedef PlatformTest SysInfoTest; | 17 typedef PlatformTest SysInfoTest; |
| 14 using base::FilePath; | 18 using base::FilePath; |
| 15 | 19 |
| 16 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) | 20 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID) |
| 17 TEST_F(SysInfoTest, MaxSharedMemorySize) { | 21 TEST_F(SysInfoTest, MaxSharedMemorySize) { |
| 18 // We aren't actually testing that it's correct, just that it's sane. | 22 // We aren't actually testing that it's correct, just that it's sane. |
| 19 EXPECT_GT(base::SysInfo::MaxSharedMemorySize(), 0u); | 23 EXPECT_GT(base::SysInfo::MaxSharedMemorySize(), 0u); |
| 20 } | 24 } |
| 21 #endif | 25 #endif |
| 22 | 26 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 34 } | 38 } |
| 35 | 39 |
| 36 TEST_F(SysInfoTest, AmountOfFreeDiskSpace) { | 40 TEST_F(SysInfoTest, AmountOfFreeDiskSpace) { |
| 37 // We aren't actually testing that it's correct, just that it's sane. | 41 // We aren't actually testing that it's correct, just that it's sane. |
| 38 FilePath tmp_path; | 42 FilePath tmp_path; |
| 39 ASSERT_TRUE(base::GetTempDir(&tmp_path)); | 43 ASSERT_TRUE(base::GetTempDir(&tmp_path)); |
| 40 EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path), 0) | 44 EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path), 0) |
| 41 << tmp_path.value(); | 45 << tmp_path.value(); |
| 42 } | 46 } |
| 43 | 47 |
| 48 TEST_F(SysInfoTest, HasSeekPenalty) { |
| 49 FilePath tmp_path; |
| 50 ASSERT_TRUE(base::GetTempDir(&tmp_path)); |
| 51 |
| 52 bool unused; |
| 53 bool success = base::SysInfo::HasSeekPenalty(tmp_path, &unused); |
| 54 #if defined(OS_WIN) |
| 55 EXPECT_EQ(base::win::GetVersion() >= base::win::VERSION_WIN7, success); |
| 56 #else |
| 57 EXPECT_FALSE(success) << "Update if this gets implemented elsewhere."; |
| 58 #endif |
| 59 } |
| 60 |
| 44 #if defined(OS_WIN) || defined(OS_MACOSX) | 61 #if defined(OS_WIN) || defined(OS_MACOSX) |
| 45 TEST_F(SysInfoTest, OperatingSystemVersionNumbers) { | 62 TEST_F(SysInfoTest, OperatingSystemVersionNumbers) { |
| 46 int32 os_major_version = -1; | 63 int32 os_major_version = -1; |
| 47 int32 os_minor_version = -1; | 64 int32 os_minor_version = -1; |
| 48 int32 os_bugfix_version = -1; | 65 int32 os_bugfix_version = -1; |
| 49 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, | 66 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, |
| 50 &os_minor_version, | 67 &os_minor_version, |
| 51 &os_bugfix_version); | 68 &os_bugfix_version); |
| 52 EXPECT_GT(os_major_version, -1); | 69 EXPECT_GT(os_major_version, -1); |
| 53 EXPECT_GT(os_minor_version, -1); | 70 EXPECT_GT(os_minor_version, -1); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease2, base::Time()); | 163 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease2, base::Time()); |
| 147 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); | 164 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); |
| 148 | 165 |
| 149 const char kLsbRelease3[] = | 166 const char kLsbRelease3[] = |
| 150 "CHROMEOS_RELEASE_NAME=Chromium OS\n"; | 167 "CHROMEOS_RELEASE_NAME=Chromium OS\n"; |
| 151 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease3, base::Time()); | 168 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease3, base::Time()); |
| 152 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); | 169 EXPECT_TRUE(base::SysInfo::IsRunningOnChromeOS()); |
| 153 } | 170 } |
| 154 | 171 |
| 155 #endif // OS_CHROMEOS | 172 #endif // OS_CHROMEOS |
| OLD | NEW |