diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-14 18:18:38 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-14 18:18:38 +0000 |
commit | ba64e2bae9b1d00777a81231148e0f69909a840c (patch) | |
tree | 8d8168983abb8635bfd5e9471169febbc397d3f4 /base/mac/mac_util_unittest.mm | |
parent | 7bf10b0e47e51d9c6d0a5f39a9d0bfad1d78eef4 (diff) | |
download | chromium_src-ba64e2bae9b1d00777a81231148e0f69909a840c.zip chromium_src-ba64e2bae9b1d00777a81231148e0f69909a840c.tar.gz chromium_src-ba64e2bae9b1d00777a81231148e0f69909a840c.tar.bz2 |
Improve and unify Mac OS X run-time version checks.
Don't use base::SysInfo::OperatingSystemVersionNumbers, because it calls
Gestalt, which has a few bad properties. Introduce new functions that perform
specific version checks.
BUG=85972
TEST=base_unittests MacUtilTest.IsOSEllipsis
Review URL: http://codereview.chromium.org/7144007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89028 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/mac/mac_util_unittest.mm')
-rw-r--r-- | base/mac/mac_util_unittest.mm | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/base/mac/mac_util_unittest.mm b/base/mac/mac_util_unittest.mm index 92a6001..dd860a6 100644 --- a/base/mac/mac_util_unittest.mm +++ b/base/mac/mac_util_unittest.mm @@ -12,6 +12,7 @@ #include "base/mac/scoped_cftyperef.h" #include "base/memory/scoped_nsobject.h" #include "base/scoped_temp_dir.h" +#include "base/sys_info.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -160,6 +161,48 @@ TEST_F(MacUtilTest, NSObjectRetainRelease) { EXPECT_EQ(1U, [array retainCount]); } +TEST_F(MacUtilTest, IsOSEllipsis) { + int32 major, minor, bugfix; + base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); + + if (major == 10) { + if (minor == 5) { + EXPECT_TRUE(IsOSLeopard()); + EXPECT_TRUE(IsOSLeopardOrEarlier()); + EXPECT_FALSE(IsOSSnowLeopard()); + EXPECT_TRUE(IsOSSnowLeopardOrEarlier()); + EXPECT_FALSE(IsOSSnowLeopardOrLater()); + EXPECT_FALSE(IsOSLion()); + EXPECT_FALSE(IsOSLionOrLater()); + EXPECT_FALSE(IsOSLaterThanLion()); + } else if (minor == 6) { + EXPECT_FALSE(IsOSLeopard()); + EXPECT_FALSE(IsOSLeopardOrEarlier()); + EXPECT_TRUE(IsOSSnowLeopard()); + EXPECT_TRUE(IsOSSnowLeopardOrEarlier()); + EXPECT_TRUE(IsOSSnowLeopardOrLater()); + EXPECT_FALSE(IsOSLion()); + EXPECT_FALSE(IsOSLionOrLater()); + EXPECT_FALSE(IsOSLaterThanLion()); + } else if (minor == 7) { + EXPECT_FALSE(IsOSLeopard()); + EXPECT_FALSE(IsOSLeopardOrEarlier()); + EXPECT_FALSE(IsOSSnowLeopard()); + EXPECT_FALSE(IsOSSnowLeopardOrEarlier()); + EXPECT_TRUE(IsOSSnowLeopardOrLater()); + EXPECT_TRUE(IsOSLion()); + EXPECT_TRUE(IsOSLionOrLater()); + EXPECT_FALSE(IsOSLaterThanLion()); + } else { + // Not five, six, or seven. Ah, ah, ah. + EXPECT_TRUE(false); + } + } else { + // Not ten. What you gonna do? + EXPECT_FALSE(true); + } +} + } // namespace } // namespace mac |