forked from highcharts/highcharts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-controller.d.ts
497 lines (497 loc) · 15.7 KB
/
test-controller.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
/*!*
*
* Copyright (c) Highsoft AS. All rights reserved.
*
*!*/
/**
* Contains x and y position relative to the chart.
*/
declare type TestControllerPoint = [number, number];
/**
* SVG clip paths
*/
interface ClipPaths {
elements: Array<Element>;
values: Array<string>;
}
/**
* Chart position of a controller instance
*/
interface TestControllerPosition extends Highcharts.PositionObject {
relatedTarget: (Element | null);
}
/**
* Page coordinates of a controller instance
*/
interface TestControllerTouchPosition {
pageX: number;
pageY: number;
}
/**
* Touch coordinates
*/
interface TestControllerTouchPositions extends Array<TestControllerTouchPosition> {
[index: number]: TestControllerTouchPosition;
item?: (index: number) => TestControllerTouchPosition;
}
/**
* The test controller makes it easy to emulate mouse and touch stuff on the
* chart.
*
* @example
* // Instanciate
* var controller = new TestController(chart);
*
* // Simulate a panning operation
* controller.pan([200, 100], [150, 100], { shiftKey: true });
*/
declare class TestController {
/**
* Mock a TochList element with required internal methods.
*
* @param arr
* The list of touches.
*/
private static createTouchList;
/**
* Returns all points between a movement.
*
* @param a
* First point as [x, y] tuple.
*
* @param b
* Second point as [x, y] tuple.
*
* @param interval
* The distance between points.
*/
private static getPointsBetween;
/**
* The test controller makes it easy to emulate mouse and touch stuff on the
* chart.
*
* @param chart
* Chart to control
*/
constructor(chart: Highcharts.Chart);
private chart;
private mouseEnterStack;
private positionX;
private positionY;
private relatedTarget;
/**
* Simulates a mouse click.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
click(chartX?: number, chartY?: number, extra?: any, debug?: boolean): void;
createEvent(type: string, chartX?: number, chartY?: number, extra?: any): Event;
/**
* Get the element from a point on the chart.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*/
elementFromPoint(chartX?: number, chartY?: number, useMSWorkaround?: boolean): (Element | undefined);
elementsFromPoint(chartX?: number, chartY?: number, useMSWorkaround?: boolean): (Array<Element>);
/**
* Get the current position of the cursor.
*/
getPosition(): TestControllerPosition;
/**
* Triggers an event.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
mouseDown(chartX?: number, chartY?: number, extra?: any, debug?: boolean): void;
/**
* Triggers mouse enter event on all necessary elements.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
mouseEnter(newPosition: TestControllerPoint, oldPosition: TestControllerPoint, extra?: any, debug?: boolean): void;
/**
* Triggers mouse enter event on all elements, that are missing on the
* provided new position.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
mouseLeave(newPosition: TestControllerPoint, oldPosition: TestControllerPoint, extra?: any, debug?: boolean): void;
/**
* Triggers an event.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
mouseMove(chartX?: number, chartY?: number, extra?: any, debug?: boolean): void;
/**
* Triggers an event.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
mouseOut(chartX?: number, chartY?: number, extra?: any, debug?: boolean): void;
/**
* Triggers an event.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
mouseOver(chartX?: number, chartY?: number, extra?: any, debug?: boolean): void;
/**
* Triggers an event.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
mouseUp(chartX?: number, chartY?: number, extra?: any, debug?: boolean): void;
/**
* Move the cursor from current position to a new one. Fire a series of
* mousemoves, also mouseout and mouseover if new targets are found.
*
* @param chartX
* New x position on the chart.
*
* @param chartY
* New y position on the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
moveTo(chartX: number, chartY: number, extra?: any, debug?: boolean): void;
/**
* Simulates a mouse pan action between two points.
*
* @param startPoint
* Starting point with x and y values relative to the chart.
*
* @param endPoint
* Ending point with x any y values relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
pan(startPoint?: TestControllerPoint, endPoint?: TestControllerPoint, extra?: any, debug?: boolean): void;
/**
* Simulates a pinch gesture.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param distance
* Distance between the two fingers. Negative values indicate, that the
* fingers move to each other.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
pinch(chartX?: number, chartY?: number, distance?: number, debug?: boolean): void;
/**
* Leave marks for debugging purposes.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*/
setDebugMark(chartX?: number, chartY?: number, type?: TestController.DebugMarkTypes): Highcharts.SVGElement;
/**
* Move the cursor position to a new position, without firing events.
*
* @param chartX
* New x position on the chart.
*
* @param chartY
* New y position on the chart.
*
* @param useMSWorkaround
* Whether to do additional operations to work around IE problems.
*/
setPosition(chartX?: number, chartY?: number, useMSWorkaround?: boolean): void;
/**
* Edge and IE are unable to get elementFromPoint when the group has a
* clip path. It reports the first underlying element with no clip path.
*/
private setUpMSWorkaround;
/**
* Simulates a slide gesture between two points.
*
* @param startPoint
* Starting point on the chart with x and y value.
*
* @param endPoint
* Ending point on the chart with x any y value.
*
* @param twoFingers
* Whether to use one or two fingers for the gesture.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
slide(startPoint?: TestControllerPoint, endPoint?: TestControllerPoint, twoFingers?: boolean, debug?: boolean): void;
/**
* Simulates a tap action with a finger.
*
* @param chartX
* X position to tab on.
*
* @param chartY
* Y position to tab on.
*
* @param twoFingers
* Whether to use one or two fingers for the gesture.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
tap(chartX?: number, chartY?: number, twoFingers?: boolean, debug?: boolean): void;
/**
* Undo the workaround for Edge and IE.
*
* @param clipPaths
* The clip paths that were returned from the `setUpMSWorkaround` function.
*/
private tearDownMSWorkaround;
/**
* Triggers touch ends events.
*
* @param chartX
* X position on the chart.
*
* @param chartY
* Y position on the chart.
*
* @param twoFingers
* Whether to use one or two fingers for the gesture.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
touchEnd(chartX?: number, chartY?: number, twoFingers?: boolean, extra?: any, debug?: boolean): void;
/**
* Triggers touch move events.
*
* @param chartX
* X position on the chart.
*
* @param chartY
* Y position on the chart.
*
* @param twoFingers
* Whether to use one or two fingers for the gesture.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
touchMove(chartX?: number, chartY?: number, twoFingers?: boolean, extra?: any, debug?: boolean): void;
/**
* Triggers touch starts events.
*
* @param chartX
* X position on the chart.
*
* @param chartY
* Y position on the chart.
*
* @param twoFingers
* Whether to use one or two fingers for the gesture.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
touchStart(chartX?: number, chartY?: number, twoFingers?: boolean, extra?: any, debug?: boolean): void;
/**
* Trigger an event. The target element will be found based on the chart
* coordinates. This function is called behind the shorthand functions
* like .click() and .mousemove().
*
* @param type
* Event type.
*
* @param chartX
* X relative to the chart.
*
* @param chartY
* Y relative to the chart.
*
* @param extra
* Extra properties for the event arguments, for example
* `{ shiftKey: true }` to emulate that the shift key has been pressed in a
* mouse event.
*
* @param debug
* Add marks where the event was triggered. Should not be enabled in
* production, as it slows down the test and also leaves an element that
* might catch events and mess up the test result.
*/
triggerEvent(type: string, chartX?: number, chartY?: number, extra?: any, debug?: boolean): void;
}
declare namespace TestController {
enum DebugMarkTypes {
activation = 0,
movement = 1,
normal = 2
}
enum MouseButtons {
left = 0,
middle = 1,
right = 2
}
const MouseButtonsBitMap: Record<number, number>;
}