| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/mac/mac_util.h" | 7 #include "base/mac/mac_util.h" |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
| 12 #include "base/mac/scoped_cftyperef.h" | 12 #include "base/mac/scoped_cftyperef.h" |
| 13 #include "base/memory/scoped_nsobject.h" | 13 #include "base/memory/scoped_nsobject.h" |
| 14 #include "base/scoped_temp_dir.h" | 14 #include "base/scoped_temp_dir.h" |
| 15 #include "base/sys_info.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
| 17 | 18 |
| 18 namespace base { | 19 namespace base { |
| 19 namespace mac { | 20 namespace mac { |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 typedef PlatformTest MacUtilTest; | 24 typedef PlatformTest MacUtilTest; |
| 24 | 25 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 scoped_nsobject<NSArray> array([[NSArray alloc] initWithObjects:@"foo", nil]); | 154 scoped_nsobject<NSArray> array([[NSArray alloc] initWithObjects:@"foo", nil]); |
| 154 EXPECT_EQ(1U, [array retainCount]); | 155 EXPECT_EQ(1U, [array retainCount]); |
| 155 | 156 |
| 156 NSObjectRetain(array); | 157 NSObjectRetain(array); |
| 157 EXPECT_EQ(2U, [array retainCount]); | 158 EXPECT_EQ(2U, [array retainCount]); |
| 158 | 159 |
| 159 NSObjectRelease(array); | 160 NSObjectRelease(array); |
| 160 EXPECT_EQ(1U, [array retainCount]); | 161 EXPECT_EQ(1U, [array retainCount]); |
| 161 } | 162 } |
| 162 | 163 |
| 164 TEST_F(MacUtilTest, IsOSEllipsis) { |
| 165 int32 major, minor, bugfix; |
| 166 base::SysInfo::OperatingSystemVersionNumbers(&major, &minor, &bugfix); |
| 167 |
| 168 if (major == 10) { |
| 169 if (minor == 5) { |
| 170 EXPECT_TRUE(IsOSLeopard()); |
| 171 EXPECT_TRUE(IsOSLeopardOrEarlier()); |
| 172 EXPECT_FALSE(IsOSSnowLeopard()); |
| 173 EXPECT_TRUE(IsOSSnowLeopardOrEarlier()); |
| 174 EXPECT_FALSE(IsOSSnowLeopardOrLater()); |
| 175 EXPECT_FALSE(IsOSLion()); |
| 176 EXPECT_FALSE(IsOSLionOrLater()); |
| 177 EXPECT_FALSE(IsOSLaterThanLion()); |
| 178 } else if (minor == 6) { |
| 179 EXPECT_FALSE(IsOSLeopard()); |
| 180 EXPECT_FALSE(IsOSLeopardOrEarlier()); |
| 181 EXPECT_TRUE(IsOSSnowLeopard()); |
| 182 EXPECT_TRUE(IsOSSnowLeopardOrEarlier()); |
| 183 EXPECT_TRUE(IsOSSnowLeopardOrLater()); |
| 184 EXPECT_FALSE(IsOSLion()); |
| 185 EXPECT_FALSE(IsOSLionOrLater()); |
| 186 EXPECT_FALSE(IsOSLaterThanLion()); |
| 187 } else if (minor == 7) { |
| 188 EXPECT_FALSE(IsOSLeopard()); |
| 189 EXPECT_FALSE(IsOSLeopardOrEarlier()); |
| 190 EXPECT_FALSE(IsOSSnowLeopard()); |
| 191 EXPECT_FALSE(IsOSSnowLeopardOrEarlier()); |
| 192 EXPECT_TRUE(IsOSSnowLeopardOrLater()); |
| 193 EXPECT_TRUE(IsOSLion()); |
| 194 EXPECT_TRUE(IsOSLionOrLater()); |
| 195 EXPECT_FALSE(IsOSLaterThanLion()); |
| 196 } else { |
| 197 // Not five, six, or seven. Ah, ah, ah. |
| 198 EXPECT_TRUE(false); |
| 199 } |
| 200 } else { |
| 201 // Not ten. What you gonna do? |
| 202 EXPECT_FALSE(true); |
| 203 } |
| 204 } |
| 205 |
| 163 } // namespace | 206 } // namespace |
| 164 | 207 |
| 165 } // namespace mac | 208 } // namespace mac |
| 166 } // namespace base | 209 } // namespace base |
| OLD | NEW |