1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/file_util.h"
6 #include "base/sys_info.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "testing/platform_test.h"
10 typedef PlatformTest SysInfoTest
;
12 TEST_F(SysInfoTest
, NumProcs
) {
13 // We aren't actually testing that it's correct, just that it's sane.
14 EXPECT_GE(base::SysInfo::NumberOfProcessors(), 1);
17 TEST_F(SysInfoTest
, AmountOfMem
) {
18 // We aren't actually testing that it's correct, just that it's sane.
19 EXPECT_GT(base::SysInfo::AmountOfPhysicalMemory(), 0);
20 EXPECT_GT(base::SysInfo::AmountOfPhysicalMemoryMB(), 0);
23 TEST_F(SysInfoTest
, AmountOfFreeDiskSpace
) {
24 // We aren't actually testing that it's correct, just that it's sane.
26 ASSERT_TRUE(file_util::GetTempDir(&tmp_path
));
27 EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path
), 0)
31 TEST_F(SysInfoTest
, GetEnvVar
) {
32 // Every setup should have non-empty PATH...
33 EXPECT_NE(base::SysInfo::GetEnvVar(L
"PATH"), L
"");
36 TEST_F(SysInfoTest
, HasEnvVar
) {
37 // Every setup should have PATH...
38 EXPECT_TRUE(base::SysInfo::HasEnvVar(L
"PATH"));
41 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
42 TEST_F(SysInfoTest
, OperatingSystemVersionNumbers
) {
43 int32 os_major_version
= -1;
44 int32 os_minor_version
= -1;
45 int32 os_bugfix_version
= -1;
46 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version
,
49 EXPECT_GT(os_major_version
, -1);
50 EXPECT_GT(os_minor_version
, -1);
51 EXPECT_GT(os_bugfix_version
, -1);
55 TEST_F(SysInfoTest
, GetPrimaryDisplayDimensions
) {
56 // We aren't actually testing that it's correct, just that it's sane.
58 base::SysInfo::GetPrimaryDisplayDimensions(&width
, &height
);
60 EXPECT_GE(height
, 10);
63 TEST_F(SysInfoTest
, DisplayCount
) {
64 // We aren't actually testing that it's correct, just that it's sane.
65 EXPECT_GE(base::SysInfo::DisplayCount(), 1);
68 #if defined(OS_CHROMEOS)
69 TEST_F(SysInfoTest
, GoogleChromeOSVersionNumbers
) {
70 int32 os_major_version
= -1;
71 int32 os_minor_version
= -1;
72 int32 os_bugfix_version
= -1;
73 std::string
lsb_release("FOO=1234123.34.5\n");
74 lsb_release
.append(base::SysInfo::GetLinuxStandardBaseVersionKey());
75 lsb_release
.append("=1.2.3.4\n");
76 base::SysInfo::ParseLsbRelease(lsb_release
,
80 EXPECT_EQ(1, os_major_version
);
81 EXPECT_EQ(2, os_minor_version
);
82 EXPECT_EQ(3, os_bugfix_version
);
85 TEST_F(SysInfoTest
, GoogleChromeOSVersionNumbersFirst
) {
86 int32 os_major_version
= -1;
87 int32 os_minor_version
= -1;
88 int32 os_bugfix_version
= -1;
89 std::string
lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey());
90 lsb_release
.append("=1.2.3.4\n");
91 lsb_release
.append("FOO=1234123.34.5\n");
92 base::SysInfo::ParseLsbRelease(lsb_release
,
96 EXPECT_EQ(1, os_major_version
);
97 EXPECT_EQ(2, os_minor_version
);
98 EXPECT_EQ(3, os_bugfix_version
);
101 TEST_F(SysInfoTest
, GoogleChromeOSNoVersionNumbers
) {
102 int32 os_major_version
= -1;
103 int32 os_minor_version
= -1;
104 int32 os_bugfix_version
= -1;
105 std::string
lsb_release("FOO=1234123.34.5\n");
106 base::SysInfo::ParseLsbRelease(lsb_release
,
110 EXPECT_EQ(-1, os_major_version
);
111 EXPECT_EQ(-1, os_minor_version
);
112 EXPECT_EQ(-1, os_bugfix_version
);
115 #endif // OS_CHROMEOS