Changeset 209892 in webkit
- Timestamp:
- Dec 15, 2016 5:14:40 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r209889 r209892 1 2016-12-15 Megan Gardner <megan_gardner@apple.com> 2 3 Add coordinate space to event streams and streamline tests 4 https://bugs.webkit.org/show_bug.cgi?id=165119 5 6 Reviewed by Simon Fraser. 7 8 Streamline tests. Make them more readable and only use one function for drags. 9 Update for new content coordinate space. 10 11 * fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html: 12 * fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html: 13 1 14 2016-12-15 Ryan Haddad <ryanhaddad@apple.com> 2 15 -
trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html
r208934 r209892 18 18 })();` 19 19 } 20 21 function getDrag DownOneScript()20 21 function getDragScript(startX, startY, endX, endY) 22 22 { 23 23 return ` … … 28 28 interpolate : "linear", 29 29 timestep: 0.1, 30 coordinateSpace : "global", 30 31 startEvent : { 31 32 inputType : "hand", … … 36 37 phase : "began", 37 38 id : 1, 38 x : 72,39 y : 140,39 x : ${startX}, 40 y : ${startY}, 40 41 pressure : 0 41 42 } … … 50 51 phase : "moved", 51 52 id : 1, 52 x : 72,53 y : 150,53 x : ${endX}, 54 y : ${endY}, 54 55 pressure : 0 55 56 } … … 61 62 uiController.uiScriptComplete(); 62 63 })();` 63 }64 65 function getDragDownTwoScript()66 {67 return `68 (function() {69 var eventStream = {70 events : [71 {72 interpolate : "linear",73 timestep: 0.1,74 startEvent : {75 inputType : "hand",76 timeOffset : 0,77 touches : [78 {79 inputType : "finger",80 phase : "began",81 id : 1,82 x : 72,83 y : 150,84 pressure : 085 }86 ]87 },88 endEvent : {89 inputType : "hand",90 timeOffset : 0.5,91 touches : [92 {93 inputType : "finger",94 phase : "moved",95 id : 1,96 x : 72,97 y : 170,98 pressure : 099 }100 ]101 }102 }]};103 104 uiController.sendEventStream(JSON.stringify(eventStream), function() {});105 uiController.uiScriptComplete();106 })();`107 }108 function getDragUpOneScript()109 {110 return `111 (function() {112 var eventStream = {113 events : [114 {115 interpolate : "linear",116 timestep: 0.1,117 startEvent : {118 inputType : "hand",119 timeOffset : 0,120 touches : [121 {122 inputType : "finger",123 phase : "began",124 id : 1,125 x : 72,126 y : 170,127 pressure : 0128 }129 ]130 },131 endEvent : {132 inputType : "hand",133 timeOffset : 0.5,134 touches : [135 {136 inputType : "finger",137 phase : "moved",138 id : 1,139 x : 72,140 y : 150,141 pressure : 0142 }143 ]144 }145 }]};146 147 uiController.sendEventStream(JSON.stringify(eventStream), function() {});148 uiController.uiScriptComplete();149 })();`150 }151 function getDragUpTwoScript()152 {153 return `154 (function() {155 var eventStream = {156 events : [157 {158 interpolate : "linear",159 timestep: 0.1,160 startEvent : {161 inputType : "hand",162 timeOffset : 0,163 touches : [164 {165 inputType : "finger",166 phase : "began",167 id : 1,168 x : 72,169 y : 150,170 pressure : 0171 }172 ]173 },174 endEvent : {175 inputType : "hand",176 timeOffset : 0.5,177 touches : [178 {179 inputType : "finger",180 phase : "moved",181 id : 1,182 x : 72,183 y : 135,184 pressure : 0185 }186 ]187 }188 }]};189 190 uiController.sendEventStream(JSON.stringify(eventStream), function() {});191 uiController.uiScriptComplete();192 })();`193 }194 function getDragUpPastScript()195 {196 return `197 (function() {198 var eventStream = {199 events : [200 {201 interpolate : "linear",202 timestep: 0.1,203 startEvent : {204 inputType : "hand",205 timeOffset : 0,206 touches : [207 {208 inputType : "finger",209 phase : "began",210 id : 1,211 x : 72,212 y : 140,213 pressure : 0214 }215 ]216 },217 endEvent : {218 inputType : "hand",219 timeOffset : 0.5,220 touches : [221 {222 inputType : "finger",223 phase : "moved",224 id : 1,225 x : 72,226 y : 100,227 pressure : 0228 }229 ]230 }231 }]};232 233 uiController.sendEventStream(JSON.stringify(eventStream), function() {});234 uiController.uiScriptComplete();235 })();`236 64 } 237 65 … … 252 80 output += '<br>'; 253 81 254 testRunner.runUIScript(getDrag DownOneScript(), function(result) {82 testRunner.runUIScript(getDragScript(72, 120, 72, 140), function(result) { 255 83 if (document.getSelection().toString() == "Ut enim ad minim veniam, q") 256 84 output += 'PASS: Correct Selection'; … … 259 87 output += '<br>'; 260 88 261 testRunner.runUIScript(getDrag DownTwoScript(), function(result) {89 testRunner.runUIScript(getDragScript(72, 140, 72, 160), function(result) { 262 90 if (document.getSelection().toString() == "Ut enim ad minim veniam, quis nostrud exercitati") 263 91 output += 'PASS: Correct Selection'; … … 266 94 output += '<br>'; 267 95 268 testRunner.runUIScript(getDrag UpOneScript(), function(result) {96 testRunner.runUIScript(getDragScript(72, 160, 72, 140), function(result) { 269 97 if (document.getSelection().toString() == "Ut enim ad minim veniam, q") 270 98 output += 'PASS: Correct Selection'; … … 273 101 output += '<br>'; 274 102 275 testRunner.runUIScript(getDrag UpTwoScript(), function(result) {103 testRunner.runUIScript(getDragScript(72, 140, 72, 115), function(result) { 276 104 if (document.getSelection().toString() == "Ut") 277 105 output += 'PASS: Correct Selection'; … … 280 108 output += '<br>'; 281 109 282 testRunner.runUIScript(getDrag UpPastScript(), function(result) {110 testRunner.runUIScript(getDragScript(72, 115, 72, 80), function(result) { 283 111 if (document.getSelection().toString() == "U") 284 112 output += 'PASS: Correct Selection'; -
trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html
r208934 r209892 19 19 } 20 20 21 function getDrag UpOneScript()21 function getDragScript(startX, startY, endX, endY) 22 22 { 23 23 return ` … … 28 28 interpolate : "linear", 29 29 timestep: 0.1, 30 coordinateSpace : "content", 30 31 startEvent : { 31 32 inputType : "hand", … … 36 37 phase : "began", 37 38 id : 1, 38 x : 56,39 y : 109,39 x : ${startX}, 40 y : ${startY}, 40 41 pressure : 0 41 42 } … … 50 51 phase : "moved", 51 52 id : 1, 52 x : 56,53 y : 103,53 x : ${endX}, 54 y : ${endY}, 54 55 pressure : 0 55 56 } … … 63 64 } 64 65 65 function getDragUpTwoScript()66 {67 return `68 (function() {69 var eventStream = {70 events : [71 {72 interpolate : "linear",73 timestep: 0.1,74 startEvent : {75 inputType : "hand",76 timeOffset : 0,77 touches : [78 {79 inputType : "finger",80 phase : "began",81 id : 1,82 x : 56,83 y : 103,84 pressure : 085 }86 ]87 },88 endEvent : {89 inputType : "hand",90 timeOffset : 0.5,91 touches : [92 {93 inputType : "finger",94 phase : "moved",95 id : 1,96 x : 56,97 y : 84,98 pressure : 099 }100 ]101 }102 }]};103 104 uiController.sendEventStream(JSON.stringify(eventStream), function() {});105 uiController.uiScriptComplete();106 })();`107 }108 function getDragDownOneScript()109 {110 return `111 (function() {112 var eventStream = {113 events : [114 {115 interpolate : "linear",116 timestep: 0.1,117 startEvent : {118 inputType : "hand",119 timeOffset : 0,120 touches : [121 {122 inputType : "finger",123 phase : "began",124 id : 1,125 x : 56,126 y : 84,127 pressure : 0128 }129 ]130 },131 endEvent : {132 inputType : "hand",133 timeOffset : 0.5,134 touches : [135 {136 inputType : "finger",137 phase : "moved",138 id : 1,139 x : 56,140 y : 103,141 pressure : 0142 }143 ]144 }145 }]};146 147 uiController.sendEventStream(JSON.stringify(eventStream), function() {});148 uiController.uiScriptComplete();149 })();`150 }151 function getDragDownTwoScript()152 {153 return `154 (function() {155 var eventStream = {156 events : [157 {158 interpolate : "linear",159 timestep: 0.1,160 startEvent : {161 inputType : "hand",162 timeOffset : 0,163 touches : [164 {165 inputType : "finger",166 phase : "began",167 id : 1,168 x : 56,169 y : 103,170 pressure : 0171 }172 ]173 },174 endEvent : {175 inputType : "hand",176 timeOffset : 0.5,177 touches : [178 {179 inputType : "finger",180 phase : "moved",181 id : 1,182 x : 56,183 y : 112,184 pressure : 0185 }186 ]187 }188 }]};189 190 uiController.sendEventStream(JSON.stringify(eventStream), function() {});191 uiController.uiScriptComplete();192 })();`193 }194 function getDragDownPastScript()195 {196 return `197 (function() {198 var eventStream = {199 events : [200 {201 interpolate : "linear",202 timestep: 0.1,203 startEvent : {204 inputType : "hand",205 timeOffset : 0,206 touches : [207 {208 inputType : "finger",209 phase : "began",210 id : 1,211 x : 56,212 y : 112,213 pressure : 0214 }215 ]216 },217 endEvent : {218 inputType : "hand",219 timeOffset : 0.5,220 touches : [221 {222 inputType : "finger",223 phase : "moved",224 id : 1,225 x : 56,226 y : 140,227 pressure : 0228 }229 ]230 }231 }]};232 233 uiController.sendEventStream(JSON.stringify(eventStream), function() {});234 uiController.uiScriptComplete();235 })();`236 }237 238 66 function runTest() 239 67 { … … 252 80 output += '<br>'; 253 81 254 testRunner.runUIScript(getDrag UpOneScript(), function(result) {82 testRunner.runUIScript(getDragScript(56, 89, 56, 74), function(result) { 255 83 if (document.getSelection().toString() == "e et dolore magna aliqua. Ut") 256 84 output += 'PASS: Correct Selection'; … … 259 87 output += '<br>'; 260 88 261 testRunner.runUIScript(getDrag UpTwoScript(), function(result) {89 testRunner.runUIScript(getDragScript(56, 74, 56, 55), function(result) { 262 90 if (document.getSelection().toString() == "mod tempor incididunt ut labore et dolore magna aliqua. Ut") 263 91 output += 'PASS: Correct Selection'; … … 266 94 output += '<br>'; 267 95 268 testRunner.runUIScript(getDrag DownOneScript(), function(result) {96 testRunner.runUIScript(getDragScript(56, 55, 56, 74), function(result) { 269 97 if (document.getSelection().toString() == "e et dolore magna aliqua. Ut") 270 98 output += 'PASS: Correct Selection'; … … 273 101 output += '<br>'; 274 102 275 testRunner.runUIScript(getDrag DownTwoScript(), function(result) {103 testRunner.runUIScript(getDragScript(56, 74, 56, 92), function(result) { 276 104 if (document.getSelection().toString() == "Ut") 277 105 output += 'PASS: Correct Selection'; … … 280 108 output += '<br>'; 281 109 282 testRunner.runUIScript(getDrag DownPastScript(), function(result) {110 testRunner.runUIScript(getDragScript(56, 92, 56, 120), function(result) { 283 111 if (document.getSelection().toString() == "t") 284 112 output += 'PASS: Correct Selection'; … … 288 116 output += result; 289 117 document.getElementById('target').innerHTML = output; 290 //testRunner.notifyDone();118 testRunner.notifyDone(); 291 119 }); 292 120 }); -
trunk/Tools/ChangeLog
r209859 r209892 1 2016-12-15 Megan Gardner <megan_gardner@apple.com> 2 3 Add coordinate space to event streams and streamline tests 4 https://bugs.webkit.org/show_bug.cgi?id=165119 5 6 Reviewed by Simon Fraser. 7 8 Update event streams to allow for both content and global coordinate space. 9 Update example script to more accurately show all the available options. 10 11 * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: 12 * WebKitTestRunner/ios/HIDEventGenerator.h: 13 * WebKitTestRunner/ios/HIDEventGenerator.mm: 14 * WebKitTestRunner/ios/UIScriptControllerIOS.mm: 15 (WTR::convertCoordinates): 16 (WTR::UIScriptController::sendEventStream): 17 1 18 2016-12-15 Claudio Saavedra <csaavedra@igalia.com> 2 19 -
trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
r208926 r209892 60 60 // "inputType" : "hand", 61 61 // "timeOffset" : 0, 62 // "coordinateSpace" : "content", 62 63 // "touches" : [ 63 64 // { … … 70 71 // ] 71 72 // }, 73 // // This is a basic force press 72 74 // { 73 75 // "interpolate" : "linear", 74 76 // "timestep" : 0.025, 77 // "coordinateSpace" : "global", 75 78 // "startEvent" : { 76 79 // "inputType" : "hand", … … 95 98 // "phase" : "stationary", 96 99 // "id" : 1, 100 // "x" : 100, 101 // "y" : 120, 102 // "pressure" : 500 103 // } 104 // ] 105 // } 106 // }, 107 // //This is a basic drag 108 // { 109 // "interpolate" : "linear", 110 // "timestep" : 0.025, 111 // "coordinateSpace" : "content", 112 // "startEvent" : { 113 // "inputType" : "hand", 114 // "timeOffset" : 3.025, 115 // "touches" : [ 116 // { 117 // "inputType" : "finger", 118 // "phase" : "moved", 119 // "id" : 1, 120 // "x" : 100, 121 // "y" : 120, 122 // "pressure" : 0 123 // } 124 // ] 125 // }, 126 // "endEvent" : { 127 // "inputType" : "hand", 128 // "timeOffset" : 4.0, 129 // "touches" : [ 130 // { 131 // "inputType" : "finger", 132 // "phase" : "moved", 133 // "id" : 1, 97 134 // "x" : 20, 98 135 // "y" : 40, 99 // "pressure" : 500136 // "pressure" : 0 100 137 // } 101 138 // ] 102 139 // } 103 140 // }, 141 // //ending lift 104 142 // { 105 143 // "inputType" : "hand", 106 // "timeOffset" : 0.002, // seconds relative to the first event 144 // "timeOffset" : 4.025, // seconds relative to the first event 145 // "coordinateSpace" : "content", 107 146 // "touches" : [ 108 147 // { … … 110 149 // "phase" : "ended", 111 150 // "id" : 1, 112 // "x" : 100,113 // "y" : 120151 // "x" : 20, 152 // "y" : 40 114 153 // } 115 154 // ] -
trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h
r206798 r209892 32 32 extern NSString* const HIDEventInputType; 33 33 extern NSString* const HIDEventTimeOffsetKey; 34 extern NSString* const HIDEventTouchesKey; 34 35 extern NSString* const HIDEventPhaseKey; 36 extern NSString* const HIDEventInterpolateKey; 37 extern NSString* const HIDEventTimestepKey; 38 extern NSString* const HIDEventCoordinateSpaceKey; 39 extern NSString* const HIDEventStartEventKey; 40 extern NSString* const HIDEventEndEventKey; 35 41 extern NSString* const HIDEventTouchIDKey; 36 42 extern NSString* const HIDEventPressureKey; … … 40 46 extern NSString* const HIDEventMajorRadiusKey; 41 47 extern NSString* const HIDEventMinorRadiusKey; 42 extern NSString* const HIDEventTouchesKey;43 48 44 49 // Values for HIDEventInputType. … … 46 51 extern NSString* const HIDEventInputTypeFinger; 47 52 extern NSString* const HIDEventInputTypeStylus; 53 54 // Values for HIDEventCoordinateSpaceKey. 55 extern NSString* const HIDEventCoordinateSpaceTypeGlobal; 56 extern NSString* const HIDEventCoordinateSpaceTypeContent; 57 58 extern NSString* const HIDEventInterpolationTypeLinear; 59 extern NSString* const HIDEventInterpolationTypeSimpleCurve; 48 60 49 61 // Values for HIDEventPhaseKey. -
trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm
r207153 r209892 45 45 NSString* const HIDEventInterpolateKey = @"interpolate"; 46 46 NSString* const HIDEventTimestepKey = @"timestep"; 47 NSString* const HIDEventCoordinateSpaceKey = @"coordinateSpace"; 47 48 NSString* const HIDEventStartEventKey = @"startEvent"; 48 49 NSString* const HIDEventEndEventKey = @"endEvent"; … … 58 59 NSString* const HIDEventInputTypeFinger = @"finger"; 59 60 NSString* const HIDEventInputTypeStylus = @"stylus"; 61 62 NSString* const HIDEventCoordinateSpaceTypeGlobal = @"global"; 63 NSString* const HIDEventCoordinateSpaceTypeContent = @"content"; 60 64 61 65 NSString* const HIDEventInterpolationTypeLinear = @"linear"; -
trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
r208985 r209892 204 204 }]; 205 205 } 206 207 void convertCoordinates(NSMutableDictionary *event) 208 { 209 if (event[HIDEventTouchesKey]) { 210 for (NSMutableDictionary *touch in event[HIDEventTouchesKey]) { 211 auto location = globalToContentCoordinates(TestController::singleton().mainWebView()->platformView(), (long)[touch[HIDEventXKey] doubleValue], (long)[touch[HIDEventYKey]doubleValue]); 212 touch[HIDEventXKey] = @(location.x); 213 touch[HIDEventYKey] = @(location.y); 214 } 215 } 216 } 206 217 207 218 void UIScriptController::sendEventStream(JSStringRef eventsJSON, JSValueRef callback) … … 210 221 211 222 String jsonString = eventsJSON->string(); 212 auto eventInfo = dynamic_objc_cast<NSDictionary>([NSJSONSerialization JSONObjectWithData:[(NSString *)jsonString dataUsingEncoding:NSUTF8StringEncoding] options:0 error:nil]); 223 auto eventInfo = dynamic_objc_cast<NSDictionary>([NSJSONSerialization JSONObjectWithData:[(NSString *)jsonString dataUsingEncoding:NSUTF8StringEncoding] options:NSJSONReadingMutableContainers | NSJSONReadingMutableLeaves error:nil]); 224 225 for (NSMutableDictionary *event in eventInfo[TopLevelEventInfoKey]) { 226 if (![event[HIDEventCoordinateSpaceKey] isEqualToString:HIDEventCoordinateSpaceTypeContent]) 227 continue; 228 229 if (event[HIDEventStartEventKey]) 230 convertCoordinates(event[HIDEventStartEventKey]); 231 232 if (event[HIDEventEndEventKey]) 233 convertCoordinates(event[HIDEventEndEventKey]); 234 235 if (event[HIDEventTouchesKey]) 236 convertCoordinates(event); 237 } 238 213 239 if (!eventInfo || ![eventInfo isKindOfClass:[NSDictionary class]]) { 214 240 WTFLogAlways("JSON is not convertible to a dictionary");
Note: See TracChangeset
for help on using the changeset viewer.