Title: [252295] tags/Safari-609.1.10.1/Tools
Revision
252295
Author
alanc...@apple.com
Date
2019-11-08 16:52:36 -0800 (Fri, 08 Nov 2019)

Log Message

Cherry-pick r252023. rdar://problem/55854631

    Add Googletest assertion support for CGRect and NSRect
    https://bugs.webkit.org/show_bug.cgi?id=203817

    Reviewed by Myles C. Maxfield.

    Add operator== and operator<< overloads for CGRect and NSRect so that these types can be
    passed to EXPECT_EQ() and other Googletest assertions.

    To make use of these overloads Cocoa tests should include #import "TestCocoa.h" instead of
    "Test.h". TestCocoa.h imports Test.h. With these overloads an assertion like this:

        EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects[0].CGRectValue);

    will produce output like this when it fails:

        Expected equality of these values:
          CGRectMake(138, 0, 23, 24)
            Which is: (origin = (x = 138, y = 0), size = (width = 23, height = 24))
          rects.firstObject.CGRectValue
            Which is: (origin = (x = 96, y = 0), size = (width = 16, height = 17))

    * TestWebKitAPI/SourcesCocoa.txt:
    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
    Add source files.

    * TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
    * TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:
    Write in terms of EXPECT_EQ() now that it just works when passed CGRects.

    * TestWebKitAPI/cocoa/TestCocoa.h: Added.
    * TestWebKitAPI/cocoa/TestCocoa.mm: Added.
    (ostreamRectCommon):
    (operator<<):
    (operator==):

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252023 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: tags/Safari-609.1.10.1/Tools/ChangeLog (252294 => 252295)


--- tags/Safari-609.1.10.1/Tools/ChangeLog	2019-11-09 00:52:33 UTC (rev 252294)
+++ tags/Safari-609.1.10.1/Tools/ChangeLog	2019-11-09 00:52:36 UTC (rev 252295)
@@ -1,3 +1,81 @@
+2019-11-08  Alan Coon  <alanc...@apple.com>
+
+        Cherry-pick r252023. rdar://problem/55854631
+
+    Add Googletest assertion support for CGRect and NSRect
+    https://bugs.webkit.org/show_bug.cgi?id=203817
+    
+    Reviewed by Myles C. Maxfield.
+    
+    Add operator== and operator<< overloads for CGRect and NSRect so that these types can be
+    passed to EXPECT_EQ() and other Googletest assertions.
+    
+    To make use of these overloads Cocoa tests should include #import "TestCocoa.h" instead of
+    "Test.h". TestCocoa.h imports Test.h. With these overloads an assertion like this:
+    
+        EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects[0].CGRectValue);
+    
+    will produce output like this when it fails:
+    
+        Expected equality of these values:
+          CGRectMake(138, 0, 23, 24)
+            Which is: (origin = (x = 138, y = 0), size = (width = 23, height = 24))
+          rects.firstObject.CGRectValue
+            Which is: (origin = (x = 96, y = 0), size = (width = 16, height = 17))
+    
+    * TestWebKitAPI/SourcesCocoa.txt:
+    * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+    Add source files.
+    
+    * TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
+    * TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:
+    Write in terms of EXPECT_EQ() now that it just works when passed CGRects.
+    
+    * TestWebKitAPI/cocoa/TestCocoa.h: Added.
+    * TestWebKitAPI/cocoa/TestCocoa.mm: Added.
+    (ostreamRectCommon):
+    (operator<<):
+    (operator==):
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@252023 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-11-04  Daniel Bates  <daba...@apple.com>
+
+            Add Googletest assertion support for CGRect and NSRect
+            https://bugs.webkit.org/show_bug.cgi?id=203817
+
+            Reviewed by Myles C. Maxfield.
+
+            Add operator== and operator<< overloads for CGRect and NSRect so that these types can be
+            passed to EXPECT_EQ() and other Googletest assertions.
+
+            To make use of these overloads Cocoa tests should include #import "TestCocoa.h" instead of
+            "Test.h". TestCocoa.h imports Test.h. With these overloads an assertion like this:
+
+                EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects[0].CGRectValue);
+
+            will produce output like this when it fails:
+
+                Expected equality of these values:
+                  CGRectMake(138, 0, 23, 24)
+                    Which is: (origin = (x = 138, y = 0), size = (width = 23, height = 24))
+                  rects.firstObject.CGRectValue
+                    Which is: (origin = (x = 96, y = 0), size = (width = 16, height = 17))
+
+            * TestWebKitAPI/SourcesCocoa.txt:
+            * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+            Add source files.
+
+            * TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:
+            * TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm:
+            Write in terms of EXPECT_EQ() now that it just works when passed CGRects.
+
+            * TestWebKitAPI/cocoa/TestCocoa.h: Added.
+            * TestWebKitAPI/cocoa/TestCocoa.mm: Added.
+            (ostreamRectCommon):
+            (operator<<):
+            (operator==):
+
 2019-11-07  Alan Coon  <alanc...@apple.com>
 
         Cherry-pick r252172. rdar://problem/56580680

Modified: tags/Safari-609.1.10.1/Tools/TestWebKitAPI/SourcesCocoa.txt (252294 => 252295)


--- tags/Safari-609.1.10.1/Tools/TestWebKitAPI/SourcesCocoa.txt	2019-11-09 00:52:33 UTC (rev 252294)
+++ tags/Safari-609.1.10.1/Tools/TestWebKitAPI/SourcesCocoa.txt	2019-11-09 00:52:36 UTC (rev 252295)
@@ -25,6 +25,7 @@
 WKWebViewConfigurationExtras.mm
 
 cocoa/PlatformUtilitiesCocoa.mm
+cocoa/TestCocoa.mm
 cocoa/TestNavigationDelegate.mm
 cocoa/TestProtocol.mm
 cocoa/TestWKWebView.mm

Modified: tags/Safari-609.1.10.1/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (252294 => 252295)


--- tags/Safari-609.1.10.1/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-11-09 00:52:33 UTC (rev 252294)
+++ tags/Safari-609.1.10.1/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-11-09 00:52:36 UTC (rev 252295)
@@ -2436,6 +2436,8 @@
 		CE449E1021AE0F7200E7ADA1 /* WKWebViewFindString.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewFindString.mm; sourceTree = "<group>"; };
 		CE4D5DE51F6743BA0072CFC6 /* StringWithDirection.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StringWithDirection.cpp; sourceTree = "<group>"; };
 		CE50D8C81C8665CE0072EA5A /* OptionSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionSet.cpp; sourceTree = "<group>"; };
+		CE640CA52370A4F300C5CAA4 /* TestCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TestCocoa.h; path = cocoa/TestCocoa.h; sourceTree = "<group>"; };
+		CE640CA62370A4F300C5CAA4 /* TestCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = TestCocoa.mm; path = cocoa/TestCocoa.mm; sourceTree = "<group>"; };
 		CE6E819F20A6935F00E2C80F /* SetTimeoutFunction.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SetTimeoutFunction.mm; sourceTree = "<group>"; };
 		CE6E81A320A933B800E2C80F /* set-timeout-function.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; name = "set-timeout-function.html"; path = "ios/set-timeout-function.html"; sourceTree = SOURCE_ROOT; };
 		CE78705C2107AB8C0053AC67 /* MoveOnlyLifecycleLogger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MoveOnlyLifecycleLogger.h; sourceTree = "<group>"; };
@@ -2732,6 +2734,8 @@
 				F44A530D21B8976900DBB99C /* InstanceMethodSwizzler.h */,
 				F44A531021B8976900DBB99C /* InstanceMethodSwizzler.mm */,
 				0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */,
+				CE640CA52370A4F300C5CAA4 /* TestCocoa.h */,
+				CE640CA62370A4F300C5CAA4 /* TestCocoa.mm */,
 				5CE7594822A883A500C12409 /* TestContextMenuDriver.h */,
 				5CE7594722A883A500C12409 /* TestContextMenuDriver.mm */,
 				2D1C04A51D76298B000A6816 /* TestNavigationDelegate.h */,

Modified: tags/Safari-609.1.10.1/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm (252294 => 252295)


--- tags/Safari-609.1.10.1/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm	2019-11-09 00:52:33 UTC (rev 252294)
+++ tags/Safari-609.1.10.1/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm	2019-11-09 00:52:36 UTC (rev 252295)
@@ -28,7 +28,7 @@
 #if PLATFORM(IOS_FAMILY) && HAVE(UI_WK_DOCUMENT_CONTEXT)
 
 #import "PlatformUtilities.h"
-#import "Test.h"
+#import "TestCocoa.h"
 #import "TestNavigationDelegate.h"
 #import "TestWKWebView.h"
 #import "UIKitSPI.h"
@@ -46,12 +46,6 @@
     EXPECT_TRUE([actual isKindOfClass:[NSAttributedString class]]); \
     EXPECT_WK_STREQ(expected, [(NSAttributedString *)actual string]);
 
-#define EXPECT_RECT_EQ(xExpected, yExpected, widthExpected, heightExpected, rect) \
-    EXPECT_DOUBLE_EQ(xExpected, rect.origin.x); \
-    EXPECT_DOUBLE_EQ(yExpected, rect.origin.y); \
-    EXPECT_DOUBLE_EQ(widthExpected, rect.size.width); \
-    EXPECT_DOUBLE_EQ(heightExpected, rect.size.height);
-
 @interface WKContentView ()
 - (void)requestDocumentContext:(UIWKDocumentRequest *)request completionHandler:(void (^)(UIWKDocumentContext *))completionHandler;
 - (void)adjustSelectionWithDelta:(NSRange)deltaRange completionHandler:(void (^)(void))completionHandler;
@@ -210,10 +204,10 @@
         return [@(a.CGRectValue.origin.x) compare:@(b.CGRectValue.origin.x)];
     }];
     EXPECT_EQ(4UL, rects.count);
-    EXPECT_RECT_EQ(0, 0, 23, 24, rects[0].CGRectValue);
-    EXPECT_RECT_EQ(23, 0, 23, 24, rects[1].CGRectValue);
-    EXPECT_RECT_EQ(46, 0, 23, 24, rects[2].CGRectValue);
-    EXPECT_RECT_EQ(69, 0, 23, 24, rects[3].CGRectValue);
+    EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects[0].CGRectValue);
+    EXPECT_EQ(CGRectMake(23, 0, 23, 24), rects[1].CGRectValue);
+    EXPECT_EQ(CGRectMake(46, 0, 23, 24), rects[2].CGRectValue);
+    EXPECT_EQ(CGRectMake(69, 0, 23, 24), rects[3].CGRectValue);
     rects = [context characterRectsForCharacterRange:NSMakeRange(5, 1)];
     EXPECT_EQ(0UL, rects.count);
 
@@ -221,16 +215,16 @@
     EXPECT_NSSTRING_EQ(" MMM", context.contextAfter);
     rects = [context characterRectsForCharacterRange:NSMakeRange(0, 1)];
     EXPECT_EQ(1UL, rects.count);
-    EXPECT_RECT_EQ(0, 0, 23, 24, rects.firstObject.CGRectValue);
+    EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects.firstObject.CGRectValue);
     rects = [context characterRectsForCharacterRange:NSMakeRange(6, 1)];
     EXPECT_EQ(1UL, rects.count);
-    EXPECT_RECT_EQ(138, 0, 23, 24, rects.firstObject.CGRectValue);
+    EXPECT_EQ(CGRectMake(138, 0, 23, 24), rects.firstObject.CGRectValue);
 
     // Text Input Context
     [webView synchronouslyLoadHTMLString:applyStyle(@"<input type='text' style='width: 50px; height: 50px;' value='hello, world'>")];
     NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(1UL, textInputContexts.count);
-    EXPECT_RECT_EQ(0, 0, 50, 50, textInputContexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 0, 50, 50), textInputContexts[0].boundingRect);
 
     context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText, UITextGranularityWord, 0, CGRectZero, textInputContexts[0])];
     EXPECT_NSSTRING_EQ("hello,", context.contextBefore);

Modified: tags/Safari-609.1.10.1/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm (252294 => 252295)


--- tags/Safari-609.1.10.1/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm	2019-11-09 00:52:33 UTC (rev 252294)
+++ tags/Safari-609.1.10.1/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm	2019-11-09 00:52:36 UTC (rev 252295)
@@ -26,7 +26,7 @@
 #import "config.h"
 
 #import "PlatformUtilities.h"
-#import "Test.h"
+#import "TestCocoa.h"
 #import "TestNavigationDelegate.h"
 #import "TestWKWebView.h"
 #import <WebKit/WKPreferencesRefPrivate.h>
@@ -35,12 +35,6 @@
 #import <WebKit/_WKTextInputContext.h>
 #import <wtf/RetainPtr.h>
 
-#define EXPECT_RECT_EQ(xExpected, yExpected, widthExpected, heightExpected, rect) \
-    EXPECT_DOUBLE_EQ(xExpected, rect.origin.x); \
-    EXPECT_DOUBLE_EQ(yExpected, rect.origin.y); \
-    EXPECT_DOUBLE_EQ(widthExpected, rect.size.width); \
-    EXPECT_DOUBLE_EQ(heightExpected, rect.size.height);
-
 @implementation WKWebView (SynchronousTextInputContext)
 
 - (NSArray<_WKTextInputContext *> *)synchronouslyRequestTextInputContextsInRect:(CGRect)rect
@@ -92,17 +86,17 @@
     [webView synchronouslyLoadHTMLString:applyStyle(@"<input type='text' style='width: 50px; height: 50px;'>")];
     contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(1UL, contexts.count);
-    EXPECT_RECT_EQ(0, 0, 50, 50, contexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 0, 50, 50), contexts[0].boundingRect);
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<textarea style='width: 100px; height: 100px;'></textarea>")];
     contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(1UL, contexts.count);
-    EXPECT_RECT_EQ(0, 0, 100, 100, contexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 0, 100, 100), contexts[0].boundingRect);
 
     [webView synchronouslyLoadHTMLString:applyStyle(@"<div contenteditable style='width: 100px; height: 100px;'></div>")];
     contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(1UL, contexts.count);
-    EXPECT_RECT_EQ(0, 0, 100, 100, contexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 0, 100, 100), contexts[0].boundingRect);
 
     // Basic inputs inside subframe.
 
@@ -109,17 +103,17 @@
     [webView synchronouslyLoadHTMLString:applyIframe(@"<input type='text' style='width: 50px; height: 50px;'>")];
     contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(1UL, contexts.count);
-    EXPECT_RECT_EQ(0, 200, 50, 50, contexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 200, 50, 50), contexts[0].boundingRect);
 
     [webView synchronouslyLoadHTMLString:applyIframe(@"<textarea style='width: 100px; height: 100px;'></textarea>")];
     contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(1UL, contexts.count);
-    EXPECT_RECT_EQ(0, 200, 100, 100, contexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 200, 100, 100), contexts[0].boundingRect);
 
     [webView synchronouslyLoadHTMLString:applyIframe(@"<div contenteditable style='width: 100px; height: 100px;'></div>")];
     contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(1UL, contexts.count);
-    EXPECT_RECT_EQ(0, 200, 100, 100, contexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 200, 100, 100), contexts[0].boundingRect);
 
     // Read only inputs; should not be included.
 
@@ -158,7 +152,7 @@
 #endif
     contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(1UL, contexts.count);
-    EXPECT_RECT_EQ(0, 0, 50, 50, contexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 0, 50, 50), contexts[0].boundingRect);
 
     // Multiple inputs.
 
@@ -165,9 +159,9 @@
     [webView synchronouslyLoadHTMLString:applyStyle(@"<input type='text' style='width: 50px; height: 50px;'><br/><input type='text' style='width: 50px; height: 50px;'><br/><input type='text' style='width: 50px; height: 50px;'>")];
     contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(3UL, contexts.count);
-    EXPECT_RECT_EQ(0, 0, 50, 50, contexts[0].boundingRect);
-    EXPECT_RECT_EQ(0, 50, 50, 50, contexts[1].boundingRect);
-    EXPECT_RECT_EQ(0, 100, 50, 50, contexts[2].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 0, 50, 50), contexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 50, 50, 50), contexts[1].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 100, 50, 50), contexts[2].boundingRect);
 
     // Nested <input>-inside-contenteditable. Only the contenteditable is considered.
 
@@ -174,7 +168,7 @@
     [webView synchronouslyLoadHTMLString:applyStyle(@"<div contenteditable style='width: 100px; height: 100px;'><input type='text' style='width: 50px; height: 50px;'></div>")];
     contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]];
     EXPECT_EQ(1UL, contexts.count);
-    EXPECT_RECT_EQ(0, 0, 100, 100, contexts[0].boundingRect);
+    EXPECT_EQ(CGRectMake(0, 0, 100, 100), contexts[0].boundingRect);
 }
 
 TEST(WebKit, DISABLED_FocusTextInputContext)

Added: tags/Safari-609.1.10.1/Tools/TestWebKitAPI/cocoa/TestCocoa.h (0 => 252295)


--- tags/Safari-609.1.10.1/Tools/TestWebKitAPI/cocoa/TestCocoa.h	                        (rev 0)
+++ tags/Safari-609.1.10.1/Tools/TestWebKitAPI/cocoa/TestCocoa.h	2019-11-09 00:52:36 UTC (rev 252295)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#import "Test.h"
+
+#if USE(CG)
+
+std::ostream& operator<<(std::ostream&, const CGRect&);
+bool operator==(const CGRect&, const CGRect&);
+
+#endif
+
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
+
+std::ostream& operator<<(std::ostream&, const NSRect&);
+bool operator==(const NSRect&, const NSRect&);
+
+#endif

Added: tags/Safari-609.1.10.1/Tools/TestWebKitAPI/cocoa/TestCocoa.mm (0 => 252295)


--- tags/Safari-609.1.10.1/Tools/TestWebKitAPI/cocoa/TestCocoa.mm	                        (rev 0)
+++ tags/Safari-609.1.10.1/Tools/TestWebKitAPI/cocoa/TestCocoa.mm	2019-11-09 00:52:36 UTC (rev 252295)
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2019 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "TestCocoa.h"
+
+template<typename T>
+static inline std::ostream& ostreamRectCommon(std::ostream& os, const T& rect)
+{
+    return os << "(origin = (x = " << rect.origin.x << ", y = " << rect.origin.y << "), size = (width = " << rect.size.width << ", height = " << rect.size.height << "))";
+}
+
+#if USE(CG)
+
+std::ostream& operator<<(std::ostream& os, const CGRect& rect)
+{
+    return ostreamRectCommon(os, rect);
+}
+
+bool operator==(const CGRect& a, const CGRect& b)
+{
+    return CGRectEqualToRect(a, b);
+}
+
+#endif
+
+#if PLATFORM(MAC) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
+
+std::ostream& operator<<(std::ostream& os, const NSRect& rect)
+{
+    return ostreamRectCommon(os, rect);
+}
+
+bool operator==(const NSRect& a, const NSRect& b)
+{
+    return NSEqualRects(a, b);
+}
+
+#endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to