Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1968)

Unified Diff: Source/platform/mac/VersionUtilMacTest.mm

Issue 1288823004: Reland #1: Fix the mechanism by which Blink determines OSX version number. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix logic error in unit test. Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/mac/VersionUtilMac.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/mac/VersionUtilMacTest.mm
diff --git a/Source/platform/mac/VersionUtilMacTest.mm b/Source/platform/mac/VersionUtilMacTest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..c74a8a2fb8780c09ce8dc604d0745eff004109d3
--- /dev/null
+++ b/Source/platform/mac/VersionUtilMacTest.mm
@@ -0,0 +1,57 @@
+// Copyright 2015 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.
+
+#import "config.h"
+#import "platform/mac/VersionUtilMac.h"
+
+#include <AppKit/AppKit.h>
+#include <gtest/gtest.h>
+
+#ifndef NSAppKitVersionNumber10_7
+#define NSAppKitVersionNumber10_7 1138
+#endif
+
+#ifndef NSAppKitVersionNumber10_9
+#define NSAppKitVersionNumber10_9 1265
+#endif
+
+#ifndef NSAppKitVersionNumber10_10
+#define NSAppKitVersionNumber10_10 1343
+#endif
+
+// This number was determined by writing a tiny Cocoa App on 10.10.4.
+#define NSAppKitVersionNumber10_10Max 1348
+
+// AppKit version is loosely correlated to OSX version. It's still useful as a
+// sanity check in unit tests, though we don't want to rely on it in production
+// code.
+TEST(VersionUtilMac, AppKitVersions)
+{
+ if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_7) {
+ EXPECT_TRUE(blink::IsOSLionOrEarlier());
+ EXPECT_TRUE(blink::IsOSMavericksOrEarlier());
+ EXPECT_FALSE(blink::IsOSMavericks());
+ return;
+ }
+
+ if (floor(NSAppKitVersionNumber) < NSAppKitVersionNumber10_9) {
+ EXPECT_FALSE(blink::IsOSLionOrEarlier());
+ EXPECT_TRUE(blink::IsOSMavericksOrEarlier());
+ EXPECT_FALSE(blink::IsOSMavericks());
+ return;
+ }
+ if (floor(NSAppKitVersionNumber) == NSAppKitVersionNumber10_9) {
+ EXPECT_FALSE(blink::IsOSLionOrEarlier());
+ EXPECT_TRUE(blink::IsOSMavericksOrEarlier());
+ EXPECT_TRUE(blink::IsOSMavericks());
+ return;
+ }
+ if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_10Max &&
+ floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_10) {
+ EXPECT_FALSE(blink::IsOSLionOrEarlier());
+ EXPECT_FALSE(blink::IsOSMavericksOrEarlier());
+ EXPECT_FALSE(blink::IsOSMavericks());
+ return;
+ }
+}
« no previous file with comments | « Source/platform/mac/VersionUtilMac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698