Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: base/sys_info_unittest.cc

Issue 1498003003: Remove kint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: INT64_MAX Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/sys_info_posix.cc ('k') | base/sys_info_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 TEST_F(SysInfoTest, AmountOfFreeDiskSpace) { 36 TEST_F(SysInfoTest, AmountOfFreeDiskSpace) {
37 // We aren't actually testing that it's correct, just that it's sane. 37 // We aren't actually testing that it's correct, just that it's sane.
38 FilePath tmp_path; 38 FilePath tmp_path;
39 ASSERT_TRUE(base::GetTempDir(&tmp_path)); 39 ASSERT_TRUE(base::GetTempDir(&tmp_path));
40 EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path), 0) 40 EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path), 0)
41 << tmp_path.value(); 41 << tmp_path.value();
42 } 42 }
43 43
44 #if defined(OS_WIN) || defined(OS_MACOSX) 44 #if defined(OS_WIN) || defined(OS_MACOSX)
45 TEST_F(SysInfoTest, OperatingSystemVersionNumbers) { 45 TEST_F(SysInfoTest, OperatingSystemVersionNumbers) {
46 int32 os_major_version = -1; 46 int32_t os_major_version = -1;
47 int32 os_minor_version = -1; 47 int32_t os_minor_version = -1;
48 int32 os_bugfix_version = -1; 48 int32_t os_bugfix_version = -1;
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 base::TimeDelta 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 base::TimeDelta up_time_2 = base::SysInfo::Uptime(); 63 base::TimeDelta up_time_2 = base::SysInfo::Uptime();
64 EXPECT_GT(up_time_1.InMicroseconds(), 0); 64 EXPECT_GT(up_time_1.InMicroseconds(), 0);
65 EXPECT_GT(up_time_2.InMicroseconds(), up_time_1.InMicroseconds()); 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)
76 76
77 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) { 77 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) {
78 int32 os_major_version = -1; 78 int32_t os_major_version = -1;
79 int32 os_minor_version = -1; 79 int32_t os_minor_version = -1;
80 int32 os_bugfix_version = -1; 80 int32_t os_bugfix_version = -1;
81 const char kLsbRelease[] = 81 const char kLsbRelease[] =
82 "FOO=1234123.34.5\n" 82 "FOO=1234123.34.5\n"
83 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"; 83 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n";
84 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 84 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
85 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, 85 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
86 &os_minor_version, 86 &os_minor_version,
87 &os_bugfix_version); 87 &os_bugfix_version);
88 EXPECT_EQ(1, os_major_version); 88 EXPECT_EQ(1, os_major_version);
89 EXPECT_EQ(2, os_minor_version); 89 EXPECT_EQ(2, os_minor_version);
90 EXPECT_EQ(3, os_bugfix_version); 90 EXPECT_EQ(3, os_bugfix_version);
91 } 91 }
92 92
93 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) { 93 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) {
94 int32 os_major_version = -1; 94 int32_t os_major_version = -1;
95 int32 os_minor_version = -1; 95 int32_t os_minor_version = -1;
96 int32 os_bugfix_version = -1; 96 int32_t os_bugfix_version = -1;
97 const char kLsbRelease[] = 97 const char kLsbRelease[] =
98 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n" 98 "CHROMEOS_RELEASE_VERSION=1.2.3.4\n"
99 "FOO=1234123.34.5\n"; 99 "FOO=1234123.34.5\n";
100 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 100 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
101 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, 101 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
102 &os_minor_version, 102 &os_minor_version,
103 &os_bugfix_version); 103 &os_bugfix_version);
104 EXPECT_EQ(1, os_major_version); 104 EXPECT_EQ(1, os_major_version);
105 EXPECT_EQ(2, os_minor_version); 105 EXPECT_EQ(2, os_minor_version);
106 EXPECT_EQ(3, os_bugfix_version); 106 EXPECT_EQ(3, os_bugfix_version);
107 } 107 }
108 108
109 TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) { 109 TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) {
110 int32 os_major_version = -1; 110 int32_t os_major_version = -1;
111 int32 os_minor_version = -1; 111 int32_t os_minor_version = -1;
112 int32 os_bugfix_version = -1; 112 int32_t os_bugfix_version = -1;
113 const char kLsbRelease[] = "FOO=1234123.34.5\n"; 113 const char kLsbRelease[] = "FOO=1234123.34.5\n";
114 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time()); 114 base::SysInfo::SetChromeOSVersionInfoForTest(kLsbRelease, base::Time());
115 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, 115 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
116 &os_minor_version, 116 &os_minor_version,
117 &os_bugfix_version); 117 &os_bugfix_version);
118 EXPECT_EQ(0, os_major_version); 118 EXPECT_EQ(0, os_major_version);
119 EXPECT_EQ(0, os_minor_version); 119 EXPECT_EQ(0, os_minor_version);
120 EXPECT_EQ(0, os_bugfix_version); 120 EXPECT_EQ(0, os_bugfix_version);
121 } 121 }
122 122
(...skipping 23 matching lines...) Expand all
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
OLDNEW
« no previous file with comments | « base/sys_info_posix.cc ('k') | base/sys_info_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698