[iOS] Multiple select appearance doesn't update when selecting or deselecting rows...
[WebKit-https.git] / LayoutTests / resources / basic-gestures.js
1 function didShowKeyboard()
2 {
3     return new Promise(resolve => {
4         testRunner.runUIScript(`
5             (function() {
6                 uiController.didShowKeyboardCallback = function() {
7                     uiController.uiScriptComplete();
8                 }
9             })();`, resolve);
10     });
11 }
12
13 function longPressAtPoint(x, y)
14 {
15     return new Promise(resolve => {
16         testRunner.runUIScript(`
17             (function() {
18                 uiController.longPressAtPoint(${x}, ${y}, function() {
19                     uiController.uiScriptComplete();
20                 });
21             })();`, resolve);
22     });
23 }
24
25 function liftUpAtPoint(x, y)
26 {
27     return new Promise(resolve => {
28         testRunner.runUIScript(`
29             (function() {
30                 uiController.liftUpAtPoint(${x}, ${y}, 1, function() {
31                     uiController.uiScriptComplete();
32                 });
33             })();`, resolve);
34     });
35 }
36
37 function longPressAndHoldAtPoint(x, y)
38 {
39     return new Promise(resolve => {
40         testRunner.runUIScript(`
41             (function() {
42             var eventStream = {
43             events : [
44                 {
45                     interpolate : "linear",
46                     timestep: 0.1,
47                     coordinateSpace : "content",
48                     startEvent : {
49                         inputType : "hand",
50                         timeOffset : 0,
51                         touches : [
52                             {
53                                 inputType : "finger",
54                                 phase : "began",
55                                 id : 1,
56                                 x : ${x},
57                                 y : ${y},
58                                 pressure : 0
59                             }
60                         ]
61                     },
62                     endEvent : {
63                         inputType : "hand",
64                         timeOffset : 2.0,
65                         touches : [
66                             {
67                                 inputType : "finger",
68                                 phase : "moved",
69                                 id : 1,
70                                 x : ${x},
71                                 y : ${y},
72                                 pressure : 0
73                             }
74                         ]
75                     }
76             }]};
77
78             uiController.sendEventStream(JSON.stringify(eventStream), function() {});
79                 uiController.uiScriptComplete();
80             })();`, resolve);
81     });
82 }
83
84 function tapAtPoint(x, y)
85 {
86     return new Promise(resolve => {
87         testRunner.runUIScript(`
88             (function() {
89                 uiController.singleTapAtPoint(${x}, ${y}, function() {
90                     uiController.uiScriptComplete();
91                 });
92             })();`, resolve);
93     });
94 }
95
96 function touchAndDragFromPointToPoint(startX, startY, endX, endY)
97 {
98     return new Promise(resolve => {
99         testRunner.runUIScript(`
100             (function() {
101             var eventStream = {
102             events : [
103                 {
104                     interpolate : "linear",
105                     timestep: 0.1,
106                     coordinateSpace : "content",
107                     startEvent : {
108                         inputType : "hand",
109                         timeOffset : 0,
110                         touches : [
111                             {
112                                 inputType : "finger",
113                                 phase : "began",
114                                 id : 1,
115                                 x : ${startX},
116                                 y : ${startY},
117                                 pressure : 0
118                             }
119                         ]
120                     },
121                     endEvent : {
122                         inputType : "hand",
123                         timeOffset : 0.5,
124                         touches : [
125                             {
126                                 inputType : "finger",
127                                 phase : "moved",
128                                 id : 1,
129                                 x : ${endX},
130                                 y : ${endY},
131                                 pressure : 0
132                             }
133                         ]
134                     }
135             }]};
136
137             uiController.sendEventStream(JSON.stringify(eventStream), function() {});
138                 uiController.uiScriptComplete();
139             })();`, resolve);
140     });
141 }
142
143 function selectFormAccessoryPickerRow(rowIndex)
144 {
145     const selectRowScript = `(() => uiController.selectFormAccessoryPickerRow(${rowIndex}))()`;
146     return new Promise(resolve => testRunner.runUIScript(selectRowScript, resolve));
147 }
148
149 function holdAtPoint(x, y)
150 {
151     return new Promise(resolve => {
152         testRunner.runUIScript(`
153             (function() {
154             var eventStream = {
155             events : [
156                 {
157                     interpolate : "linear",
158                     timestep: 0.1,
159                     coordinateSpace : "content",
160                     startEvent : {
161                         inputType : "hand",
162                         timeOffset : 0,
163                         touches : [
164                             {
165                                 inputType : "finger",
166                                 phase : "moved",
167                                 id : 1,
168                                 x : ${x},
169                                 y : ${y},
170                                 pressure : 0
171                             }
172                         ]
173                     },
174                     endEvent : {
175                         inputType : "hand",
176                         timeOffset : 5.0,
177                         touches : [
178                             {
179                                 inputType : "finger",
180                                 phase : "moved",
181                                 id : 1,
182                                 x : ${x},
183                                 y : ${y},
184                                 pressure : 0
185                             }
186                         ]
187                     }
188             }]};
189
190             uiController.sendEventStream(JSON.stringify(eventStream), function() {});
191                 uiController.uiScriptComplete();
192             })();`, resolve);
193     });
194 }
195
196 function continueTouchAndDragFromPointToPoint(startX, startY, endX, endY)
197 {
198     return new Promise(resolve => {
199         testRunner.runUIScript(`
200             (function() {
201              var eventStream = {
202              events : [
203                        {
204                        interpolate : "linear",
205                        timestep: 0.1,
206                        coordinateSpace : "content",
207                        startEvent : {
208                            inputType : "hand",
209                            timeOffset : 0,
210                            touches : [
211                                {
212                                    inputType : "finger",
213                                    phase : "moved",
214                                    id : 1,
215                                    x : ${startX},
216                                    y : ${startY},
217                                    pressure : 0
218                                }
219                            ]
220                        },
221                        endEvent : {
222                            inputType : "hand",
223                            timeOffset : 0.5,
224                            touches : [
225                                {
226                                    inputType : "finger",
227                                    phase : "moved",
228                                    id : 1,
229                                    x : ${endX},
230                                    y : ${endY},
231                                    pressure : 0
232                                }
233                            ]
234                        }
235              }]};
236
237              uiController.sendEventStream(JSON.stringify(eventStream), function() {});
238                  uiController.uiScriptComplete();
239              })();`, resolve);
240     });
241 }