Add a stat to the smoothness benchmark for avg number of missing tiles.
[chromium-blink-merge.git] / base / sys_info_unittest.cc
blob55f96018d1f98cf5adef385d71f79bbed6a7c62c
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
3 // found in the LICENSE file.
5 #include "base/file_util.h"
6 #include "base/sys_info.h"
7 #include "base/threading/platform_thread.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/platform_test.h"
11 typedef PlatformTest SysInfoTest;
13 #if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(OS_ANDROID)
14 TEST_F(SysInfoTest, MaxSharedMemorySize) {
15 // We aren't actually testing that it's correct, just that it's sane.
16 EXPECT_GT(base::SysInfo::MaxSharedMemorySize(), 0u);
18 #endif
20 TEST_F(SysInfoTest, NumProcs) {
21 // We aren't actually testing that it's correct, just that it's sane.
22 EXPECT_GE(base::SysInfo::NumberOfProcessors(), 1);
25 TEST_F(SysInfoTest, AmountOfMem) {
26 // We aren't actually testing that it's correct, just that it's sane.
27 EXPECT_GT(base::SysInfo::AmountOfPhysicalMemory(), 0);
28 EXPECT_GT(base::SysInfo::AmountOfPhysicalMemoryMB(), 0);
31 TEST_F(SysInfoTest, AmountOfFreeDiskSpace) {
32 // We aren't actually testing that it's correct, just that it's sane.
33 FilePath tmp_path;
34 ASSERT_TRUE(file_util::GetTempDir(&tmp_path));
35 EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path), 0)
36 << tmp_path.value();
39 #if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS)
40 TEST_F(SysInfoTest, OperatingSystemVersionNumbers) {
41 int32 os_major_version = -1;
42 int32 os_minor_version = -1;
43 int32 os_bugfix_version = -1;
44 base::SysInfo::OperatingSystemVersionNumbers(&os_major_version,
45 &os_minor_version,
46 &os_bugfix_version);
47 EXPECT_GT(os_major_version, -1);
48 EXPECT_GT(os_minor_version, -1);
49 EXPECT_GT(os_bugfix_version, -1);
51 #endif
53 TEST_F(SysInfoTest, Uptime) {
54 int64 up_time_1 = base::SysInfo::Uptime();
55 // UpTime() is implemented internally using TimeTicks::Now(), which documents
56 // system resolution as being 1-15ms. Sleep a little longer than that.
57 base::PlatformThread::Sleep(base::TimeDelta::FromMilliseconds(20));
58 int64 up_time_2 = base::SysInfo::Uptime();
59 EXPECT_GT(up_time_1, 0);
60 EXPECT_GT(up_time_2, up_time_1);
63 #if defined(OS_CHROMEOS)
64 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) {
65 int32 os_major_version = -1;
66 int32 os_minor_version = -1;
67 int32 os_bugfix_version = -1;
68 std::string lsb_release("FOO=1234123.34.5\n");
69 lsb_release.append(base::SysInfo::GetLinuxStandardBaseVersionKey());
70 lsb_release.append("=1.2.3.4\n");
71 base::SysInfo::ParseLsbRelease(lsb_release,
72 &os_major_version,
73 &os_minor_version,
74 &os_bugfix_version);
75 EXPECT_EQ(1, os_major_version);
76 EXPECT_EQ(2, os_minor_version);
77 EXPECT_EQ(3, os_bugfix_version);
80 TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) {
81 int32 os_major_version = -1;
82 int32 os_minor_version = -1;
83 int32 os_bugfix_version = -1;
84 std::string lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey());
85 lsb_release.append("=1.2.3.4\n");
86 lsb_release.append("FOO=1234123.34.5\n");
87 base::SysInfo::ParseLsbRelease(lsb_release,
88 &os_major_version,
89 &os_minor_version,
90 &os_bugfix_version);
91 EXPECT_EQ(1, os_major_version);
92 EXPECT_EQ(2, os_minor_version);
93 EXPECT_EQ(3, os_bugfix_version);
96 TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) {
97 int32 os_major_version = -1;
98 int32 os_minor_version = -1;
99 int32 os_bugfix_version = -1;
100 std::string lsb_release("FOO=1234123.34.5\n");
101 base::SysInfo::ParseLsbRelease(lsb_release,
102 &os_major_version,
103 &os_minor_version,
104 &os_bugfix_version);
105 EXPECT_EQ(-1, os_major_version);
106 EXPECT_EQ(-1, os_minor_version);
107 EXPECT_EQ(-1, os_bugfix_version);
110 #endif // OS_CHROMEOS