diff options
author | Patrick Scott <phanna@android.com> | 2010-02-04 10:37:17 -0500 |
---|---|---|
committer | Patrick Scott <phanna@android.com> | 2010-02-04 10:39:42 -0500 |
commit | c7f5f8508d98d5952d42ed7648c2a8f30a4da156 (patch) | |
tree | dd51dbfbf6670daa61279b3a19e7b1835b301dbf /base/sys_info_unittest.cc | |
parent | 139d8152182f9093f03d9089822b688e49fa7667 (diff) | |
download | external_chromium-c7f5f8508d98d5952d42ed7648c2a8f30a4da156.zip external_chromium-c7f5f8508d98d5952d42ed7648c2a8f30a4da156.tar.gz external_chromium-c7f5f8508d98d5952d42ed7648c2a8f30a4da156.tar.bz2 |
Initial source checkin.
The source files were determined by building net_unittests in chromium's source
tree. Some of the obvious libraries were left out (v8, gmock, gtest).
The Android.mk file has all the sources (minus unittests and tools) that were
used during net_unittests compilation. Nothing builds yet because of STL but
that is the next task. The .cpp files will most likely not compile anyways
because of the LOCAL_CPP_EXTENSION mod. I will have to break this into multiple
projects to get around that limitation.
Diffstat (limited to 'base/sys_info_unittest.cc')
-rw-r--r-- | base/sys_info_unittest.cc | 115 |
1 files changed, 115 insertions, 0 deletions
diff --git a/base/sys_info_unittest.cc b/base/sys_info_unittest.cc new file mode 100644 index 0000000..4339b6a --- /dev/null +++ b/base/sys_info_unittest.cc @@ -0,0 +1,115 @@ +// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/file_util.h" +#include "base/sys_info.h" +#include "testing/gtest/include/gtest/gtest.h" +#include "testing/platform_test.h" + +typedef PlatformTest SysInfoTest; + +TEST_F(SysInfoTest, NumProcs) { + // We aren't actually testing that it's correct, just that it's sane. + EXPECT_GE(base::SysInfo::NumberOfProcessors(), 1); +} + +TEST_F(SysInfoTest, AmountOfMem) { + // We aren't actually testing that it's correct, just that it's sane. + EXPECT_GT(base::SysInfo::AmountOfPhysicalMemory(), 0); + EXPECT_GT(base::SysInfo::AmountOfPhysicalMemoryMB(), 0); +} + +TEST_F(SysInfoTest, AmountOfFreeDiskSpace) { + // We aren't actually testing that it's correct, just that it's sane. + FilePath tmp_path; + ASSERT_TRUE(file_util::GetTempDir(&tmp_path)); + EXPECT_GT(base::SysInfo::AmountOfFreeDiskSpace(tmp_path), 0) + << tmp_path.value(); +} + +TEST_F(SysInfoTest, GetEnvVar) { + // Every setup should have non-empty PATH... + EXPECT_NE(base::SysInfo::GetEnvVar(L"PATH"), L""); +} + +TEST_F(SysInfoTest, HasEnvVar) { + // Every setup should have PATH... + EXPECT_TRUE(base::SysInfo::HasEnvVar(L"PATH")); +} + +#if defined(OS_WIN) || defined(OS_MACOSX) || defined(OS_CHROMEOS) +TEST_F(SysInfoTest, OperatingSystemVersionNumbers) { + int32 os_major_version = -1; + int32 os_minor_version = -1; + int32 os_bugfix_version = -1; + base::SysInfo::OperatingSystemVersionNumbers(&os_major_version, + &os_minor_version, + &os_bugfix_version); + EXPECT_GT(os_major_version, -1); + EXPECT_GT(os_minor_version, -1); + EXPECT_GT(os_bugfix_version, -1); +} +#endif + +TEST_F(SysInfoTest, GetPrimaryDisplayDimensions) { + // We aren't actually testing that it's correct, just that it's sane. + int width, height; + base::SysInfo::GetPrimaryDisplayDimensions(&width, &height); + EXPECT_GE(width, 10); + EXPECT_GE(height, 10); +} + +TEST_F(SysInfoTest, DisplayCount) { + // We aren't actually testing that it's correct, just that it's sane. + EXPECT_GE(base::SysInfo::DisplayCount(), 1); +} + +#if defined(OS_CHROMEOS) +TEST_F(SysInfoTest, GoogleChromeOSVersionNumbers) { + int32 os_major_version = -1; + int32 os_minor_version = -1; + int32 os_bugfix_version = -1; + std::string lsb_release("FOO=1234123.34.5\n"); + lsb_release.append(base::SysInfo::GetLinuxStandardBaseVersionKey()); + lsb_release.append("=1.2.3.4\n"); + base::SysInfo::ParseLsbRelease(lsb_release, + &os_major_version, + &os_minor_version, + &os_bugfix_version); + EXPECT_EQ(1, os_major_version); + EXPECT_EQ(2, os_minor_version); + EXPECT_EQ(3, os_bugfix_version); +} + +TEST_F(SysInfoTest, GoogleChromeOSVersionNumbersFirst) { + int32 os_major_version = -1; + int32 os_minor_version = -1; + int32 os_bugfix_version = -1; + std::string lsb_release(base::SysInfo::GetLinuxStandardBaseVersionKey()); + lsb_release.append("=1.2.3.4\n"); + lsb_release.append("FOO=1234123.34.5\n"); + base::SysInfo::ParseLsbRelease(lsb_release, + &os_major_version, + &os_minor_version, + &os_bugfix_version); + EXPECT_EQ(1, os_major_version); + EXPECT_EQ(2, os_minor_version); + EXPECT_EQ(3, os_bugfix_version); +} + +TEST_F(SysInfoTest, GoogleChromeOSNoVersionNumbers) { + int32 os_major_version = -1; + int32 os_minor_version = -1; + int32 os_bugfix_version = -1; + std::string lsb_release("FOO=1234123.34.5\n"); + base::SysInfo::ParseLsbRelease(lsb_release, + &os_major_version, + &os_minor_version, + &os_bugfix_version); + EXPECT_EQ(-1, os_major_version); + EXPECT_EQ(-1, os_minor_version); + EXPECT_EQ(-1, os_bugfix_version); +} + +#endif // OS_CHROMEOS |