diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 03:09:15 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 03:09:15 +0000 |
commit | 1b4b23a7d82fce6e0637ed96b124af229fc21f22 (patch) | |
tree | 90b18864cb147acbdaa87142d6bfef91da82f3b8 | |
parent | b4cd02bb4488b1bc9dc7e0be22e136c9bb1c70c9 (diff) | |
download | chromium_src-1b4b23a7d82fce6e0637ed96b124af229fc21f22.zip chromium_src-1b4b23a7d82fce6e0637ed96b124af229fc21f22.tar.gz chromium_src-1b4b23a7d82fce6e0637ed96b124af229fc21f22.tar.bz2 |
linux: implement some SysInfo bits to reduce NOTIMPL spew
Also added basic tests for these functions.
BUG=21732
Review URL: http://codereview.chromium.org/384070
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31762 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/sys_info_posix.cc | 23 | ||||
-rw-r--r-- | base/sys_info_unittest.cc | 13 |
2 files changed, 29 insertions, 7 deletions
diff --git a/base/sys_info_posix.cc b/base/sys_info_posix.cc index ffbc204b7..34d9df3 100644 --- a/base/sys_info_posix.cc +++ b/base/sys_info_posix.cc @@ -10,6 +10,10 @@ #include <sys/utsname.h> #include <unistd.h> +#if !defined(OS_MACOSX) +#include <gdk/gdk.h> +#endif + #if defined(OS_OPENBSD) #include <sys/param.h> #include <sys/sysctl.h> @@ -126,19 +130,24 @@ std::string SysInfo::CPUArchitecture() { #if !defined(OS_MACOSX) // static void SysInfo::GetPrimaryDisplayDimensions(int* width, int* height) { - // TODO(port): http://crbug.com/21732 - NOTIMPLEMENTED(); + // Note that Bad Things Happen if this isn't called from the UI thread, + // but also that there's no way to check that from here. :( + GdkScreen* screen = gdk_screen_get_default(); if (width) - *width = 0; + *width = gdk_screen_get_width(screen); if (height) - *height = 0; + *height = gdk_screen_get_height(screen); } // static int SysInfo::DisplayCount() { - // TODO(port): http://crbug.com/21732 - NOTIMPLEMENTED(); - return 1; + // Note that Bad Things Happen if this isn't called from the UI thread, + // but also that there's no way to check that from here. :( + + // This query is kinda bogus for Linux -- do we want number of X screens? + // The number of monitors Xinerama has? We'll just use whatever GDK uses. + GdkScreen* screen = gdk_screen_get_default(); + return gdk_screen_get_n_monitors(screen); } #endif diff --git a/base/sys_info_unittest.cc b/base/sys_info_unittest.cc index 31f314f..40caf72 100644 --- a/base/sys_info_unittest.cc +++ b/base/sys_info_unittest.cc @@ -52,6 +52,19 @@ TEST_F(SysInfoTest, OperatingSystemVersionNumbers) { } #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; |