Changeset 252023 in webkit
- Timestamp:
- Nov 4, 2019 3:55:15 PM (4 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r252017 r252023 1 2019-11-04 Daniel Bates <dabates@apple.com> 2 3 Add Googletest assertion support for CGRect and NSRect 4 https://bugs.webkit.org/show_bug.cgi?id=203817 5 6 Reviewed by Myles C. Maxfield. 7 8 Add operator== and operator<< overloads for CGRect and NSRect so that these types can be 9 passed to EXPECT_EQ() and other Googletest assertions. 10 11 To make use of these overloads Cocoa tests should include #import "TestCocoa.h" instead of 12 "Test.h". TestCocoa.h imports Test.h. With these overloads an assertion like this: 13 14 EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects[0].CGRectValue); 15 16 will produce output like this when it fails: 17 18 Expected equality of these values: 19 CGRectMake(138, 0, 23, 24) 20 Which is: (origin = (x = 138, y = 0), size = (width = 23, height = 24)) 21 rects.firstObject.CGRectValue 22 Which is: (origin = (x = 96, y = 0), size = (width = 16, height = 17)) 23 24 * TestWebKitAPI/SourcesCocoa.txt: 25 * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: 26 Add source files. 27 28 * TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm: 29 * TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm: 30 Write in terms of EXPECT_EQ() now that it just works when passed CGRects. 31 32 * TestWebKitAPI/cocoa/TestCocoa.h: Added. 33 * TestWebKitAPI/cocoa/TestCocoa.mm: Added. 34 (ostreamRectCommon): 35 (operator<<): 36 (operator==): 37 1 38 2019-11-04 Aakash Jain <aakash_jain@apple.com> 2 39 -
trunk/Tools/TestWebKitAPI/SourcesCocoa.txt
r249684 r252023 26 26 27 27 cocoa/PlatformUtilitiesCocoa.mm 28 cocoa/TestCocoa.mm 28 29 cocoa/TestNavigationDelegate.mm 29 30 cocoa/TestProtocol.mm -
trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
r251976 r252023 2434 2434 CE4D5DE51F6743BA0072CFC6 /* StringWithDirection.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = StringWithDirection.cpp; sourceTree = "<group>"; }; 2435 2435 CE50D8C81C8665CE0072EA5A /* OptionSet.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OptionSet.cpp; sourceTree = "<group>"; }; 2436 CE640CA52370A4F300C5CAA4 /* TestCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = TestCocoa.h; path = cocoa/TestCocoa.h; sourceTree = "<group>"; }; 2437 CE640CA62370A4F300C5CAA4 /* TestCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = TestCocoa.mm; path = cocoa/TestCocoa.mm; sourceTree = "<group>"; }; 2436 2438 CE6E819F20A6935F00E2C80F /* SetTimeoutFunction.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SetTimeoutFunction.mm; sourceTree = "<group>"; }; 2437 2439 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; }; … … 2730 2732 F44A531021B8976900DBB99C /* InstanceMethodSwizzler.mm */, 2731 2733 0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */, 2734 CE640CA52370A4F300C5CAA4 /* TestCocoa.h */, 2735 CE640CA62370A4F300C5CAA4 /* TestCocoa.mm */, 2732 2736 5CE7594822A883A500C12409 /* TestContextMenuDriver.h */, 2733 2737 5CE7594722A883A500C12409 /* TestContextMenuDriver.mm */, -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm
r244955 r252023 29 29 30 30 #import "PlatformUtilities.h" 31 #import "Test .h"31 #import "TestCocoa.h" 32 32 #import "TestNavigationDelegate.h" 33 33 #import "TestWKWebView.h" … … 47 47 EXPECT_WK_STREQ(expected, [(NSAttributedString *)actual string]); 48 48 49 #define EXPECT_RECT_EQ(xExpected, yExpected, widthExpected, heightExpected, rect) \50 EXPECT_DOUBLE_EQ(xExpected, rect.origin.x); \51 EXPECT_DOUBLE_EQ(yExpected, rect.origin.y); \52 EXPECT_DOUBLE_EQ(widthExpected, rect.size.width); \53 EXPECT_DOUBLE_EQ(heightExpected, rect.size.height);54 55 49 @interface WKContentView () 56 50 - (void)requestDocumentContext:(UIWKDocumentRequest *)request completionHandler:(void (^)(UIWKDocumentContext *))completionHandler; … … 211 205 }]; 212 206 EXPECT_EQ(4UL, rects.count); 213 EXPECT_ RECT_EQ(0, 0, 23, 24, rects[0].CGRectValue);214 EXPECT_ RECT_EQ(23, 0, 23, 24, rects[1].CGRectValue);215 EXPECT_ RECT_EQ(46, 0, 23, 24, rects[2].CGRectValue);216 EXPECT_ RECT_EQ(69, 0, 23, 24, rects[3].CGRectValue);207 EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects[0].CGRectValue); 208 EXPECT_EQ(CGRectMake(23, 0, 23, 24), rects[1].CGRectValue); 209 EXPECT_EQ(CGRectMake(46, 0, 23, 24), rects[2].CGRectValue); 210 EXPECT_EQ(CGRectMake(69, 0, 23, 24), rects[3].CGRectValue); 217 211 rects = [context characterRectsForCharacterRange:NSMakeRange(5, 1)]; 218 212 EXPECT_EQ(0UL, rects.count); … … 222 216 rects = [context characterRectsForCharacterRange:NSMakeRange(0, 1)]; 223 217 EXPECT_EQ(1UL, rects.count); 224 EXPECT_ RECT_EQ(0, 0, 23, 24, rects.firstObject.CGRectValue);218 EXPECT_EQ(CGRectMake(0, 0, 23, 24), rects.firstObject.CGRectValue); 225 219 rects = [context characterRectsForCharacterRange:NSMakeRange(6, 1)]; 226 220 EXPECT_EQ(1UL, rects.count); 227 EXPECT_ RECT_EQ(138, 0, 23, 24, rects.firstObject.CGRectValue);221 EXPECT_EQ(CGRectMake(138, 0, 23, 24), rects.firstObject.CGRectValue); 228 222 229 223 // Text Input Context … … 231 225 NSArray<_WKTextInputContext *> *textInputContexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 232 226 EXPECT_EQ(1UL, textInputContexts.count); 233 EXPECT_ RECT_EQ(0, 0, 50, 50, textInputContexts[0].boundingRect);227 EXPECT_EQ(CGRectMake(0, 0, 50, 50), textInputContexts[0].boundingRect); 234 228 235 229 context = [webView synchronouslyRequestDocumentContext:makeRequest(UIWKDocumentRequestText, UITextGranularityWord, 0, CGRectZero, textInputContexts[0])]; -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/RequestTextInputContext.mm
r243915 r252023 27 27 28 28 #import "PlatformUtilities.h" 29 #import "Test .h"29 #import "TestCocoa.h" 30 30 #import "TestNavigationDelegate.h" 31 31 #import "TestWKWebView.h" … … 35 35 #import <WebKit/_WKTextInputContext.h> 36 36 #import <wtf/RetainPtr.h> 37 38 #define EXPECT_RECT_EQ(xExpected, yExpected, widthExpected, heightExpected, rect) \39 EXPECT_DOUBLE_EQ(xExpected, rect.origin.x); \40 EXPECT_DOUBLE_EQ(yExpected, rect.origin.y); \41 EXPECT_DOUBLE_EQ(widthExpected, rect.size.width); \42 EXPECT_DOUBLE_EQ(heightExpected, rect.size.height);43 37 44 38 @implementation WKWebView (SynchronousTextInputContext) … … 93 87 contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 94 88 EXPECT_EQ(1UL, contexts.count); 95 EXPECT_ RECT_EQ(0, 0, 50, 50, contexts[0].boundingRect);89 EXPECT_EQ(CGRectMake(0, 0, 50, 50), contexts[0].boundingRect); 96 90 97 91 [webView synchronouslyLoadHTMLString:applyStyle(@"<textarea style='width: 100px; height: 100px;'></textarea>")]; 98 92 contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 99 93 EXPECT_EQ(1UL, contexts.count); 100 EXPECT_ RECT_EQ(0, 0, 100, 100, contexts[0].boundingRect);94 EXPECT_EQ(CGRectMake(0, 0, 100, 100), contexts[0].boundingRect); 101 95 102 96 [webView synchronouslyLoadHTMLString:applyStyle(@"<div contenteditable style='width: 100px; height: 100px;'></div>")]; 103 97 contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 104 98 EXPECT_EQ(1UL, contexts.count); 105 EXPECT_ RECT_EQ(0, 0, 100, 100, contexts[0].boundingRect);99 EXPECT_EQ(CGRectMake(0, 0, 100, 100), contexts[0].boundingRect); 106 100 107 101 // Basic inputs inside subframe. … … 110 104 contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 111 105 EXPECT_EQ(1UL, contexts.count); 112 EXPECT_ RECT_EQ(0, 200, 50, 50, contexts[0].boundingRect);106 EXPECT_EQ(CGRectMake(0, 200, 50, 50), contexts[0].boundingRect); 113 107 114 108 [webView synchronouslyLoadHTMLString:applyIframe(@"<textarea style='width: 100px; height: 100px;'></textarea>")]; 115 109 contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 116 110 EXPECT_EQ(1UL, contexts.count); 117 EXPECT_ RECT_EQ(0, 200, 100, 100, contexts[0].boundingRect);111 EXPECT_EQ(CGRectMake(0, 200, 100, 100), contexts[0].boundingRect); 118 112 119 113 [webView synchronouslyLoadHTMLString:applyIframe(@"<div contenteditable style='width: 100px; height: 100px;'></div>")]; 120 114 contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 121 115 EXPECT_EQ(1UL, contexts.count); 122 EXPECT_ RECT_EQ(0, 200, 100, 100, contexts[0].boundingRect);116 EXPECT_EQ(CGRectMake(0, 200, 100, 100), contexts[0].boundingRect); 123 117 124 118 // Read only inputs; should not be included. … … 159 153 contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 160 154 EXPECT_EQ(1UL, contexts.count); 161 EXPECT_ RECT_EQ(0, 0, 50, 50, contexts[0].boundingRect);155 EXPECT_EQ(CGRectMake(0, 0, 50, 50), contexts[0].boundingRect); 162 156 163 157 // Multiple inputs. … … 166 160 contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 167 161 EXPECT_EQ(3UL, contexts.count); 168 EXPECT_ RECT_EQ(0, 0, 50, 50, contexts[0].boundingRect);169 EXPECT_ RECT_EQ(0, 50, 50, 50, contexts[1].boundingRect);170 EXPECT_ RECT_EQ(0, 100, 50, 50, contexts[2].boundingRect);162 EXPECT_EQ(CGRectMake(0, 0, 50, 50), contexts[0].boundingRect); 163 EXPECT_EQ(CGRectMake(0, 50, 50, 50), contexts[1].boundingRect); 164 EXPECT_EQ(CGRectMake(0, 100, 50, 50), contexts[2].boundingRect); 171 165 172 166 // Nested <input>-inside-contenteditable. Only the contenteditable is considered. … … 175 169 contexts = [webView synchronouslyRequestTextInputContextsInRect:[webView frame]]; 176 170 EXPECT_EQ(1UL, contexts.count); 177 EXPECT_ RECT_EQ(0, 0, 100, 100, contexts[0].boundingRect);171 EXPECT_EQ(CGRectMake(0, 0, 100, 100), contexts[0].boundingRect); 178 172 } 179 173
Note: See TracChangeset
for help on using the changeset viewer.