1
- import * as commands from '../../../lib/commands/gestures' ;
2
- import { log } from '../../../lib/logger' ;
3
-
1
+ import { buildWdIoOptions } from '../helpers' ;
2
+ import { remote as wdio } from 'webdriverio' ;
4
3
5
4
describe ( 'winapi' , function ( ) {
6
5
let chai ;
6
+ let driver ;
7
7
8
8
before ( async function ( ) {
9
9
chai = await import ( 'chai' ) ;
10
10
const chaiAsPromised = await import ( 'chai-as-promised' ) ;
11
11
12
12
chai . should ( ) ;
13
13
chai . use ( chaiAsPromised . default ) ;
14
- commands . log = log ;
14
+
15
+ driver = await wdio ( buildWdIoOptions ( 'Root' ) ) ;
15
16
} ) ;
16
17
17
- after ( function ( ) {
18
- delete commands . log ;
18
+ after ( async function ( ) {
19
+ try {
20
+ if ( driver ) {
21
+ await driver . deleteSession ( ) ;
22
+ }
23
+ } finally {
24
+ driver = null ;
25
+ }
19
26
} ) ;
20
27
21
28
describe ( 'mouseClick' , function ( ) {
22
29
it ( 'performs single click with Shift+Ctrl' , async function ( ) {
23
- await commands . windowsClick ( {
30
+ await driver . execute ( 'windows: click' , [ {
24
31
x : 100 ,
25
32
y : 100 ,
26
33
modifierKeys : [ 'shift' , 'ctrl' ] ,
27
- } ) ;
34
+ } ] ) ;
28
35
} ) ;
29
36
30
37
it ( 'performs long click' , async function ( ) {
31
- await commands . windowsClick ( {
38
+ await driver . execute ( 'windows: click' , [ {
32
39
x : 100 ,
33
40
y : 100 ,
34
41
durationMs : 500 ,
35
- } ) ;
42
+ } ] ) ;
36
43
} ) ;
37
44
38
45
it ( 'performs double click' , async function ( ) {
39
- await commands . windowsClick ( {
46
+ await driver . execute ( 'windows: click' , [ {
40
47
x : 100 ,
41
48
y : 100 ,
42
49
times : 2 ,
43
- } ) ;
50
+ } ] ) ;
44
51
} ) ;
45
52
46
53
it ( 'performs context click' , async function ( ) {
47
- await commands . windowsClick ( {
54
+ await driver . execute ( 'windows: click' , [ {
48
55
x : 100 ,
49
56
y : 100 ,
50
57
button : 'right' ,
51
- } ) ;
58
+ } ] ) ;
52
59
} ) ;
53
60
54
61
it ( 'fails if wrong input is provided' , async function ( ) {
@@ -84,35 +91,35 @@ describe('winapi', function () {
84
91
] ;
85
92
86
93
for ( const errData of errDatas ) {
87
- await commands . windowsClick ( errData ) . should . be . rejected ;
94
+ await driver . execute ( 'windows: click' , [ errData ] ) . should . be . rejected ;
88
95
}
89
96
} ) ;
90
97
} ) ;
91
98
92
99
describe ( 'mouseScroll' , function ( ) {
93
100
it ( 'performs vertical scroll gesture with Ctrl+Alt depressed' , async function ( ) {
94
- await commands . windowsScroll ( {
101
+ await driver . execute ( 'windows: scroll' , [ {
95
102
x : 600 ,
96
103
y : 300 ,
97
104
deltaY : 200 ,
98
105
modifierKeys : [ 'ctrl' , 'alt' ] ,
99
- } ) ;
106
+ } ] ) ;
100
107
} ) ;
101
108
102
109
it ( 'performs horizontal scroll gesture' , async function ( ) {
103
- await commands . windowsScroll ( {
110
+ await driver . execute ( 'windows: scroll' , [ {
104
111
x : 600 ,
105
112
y : 300 ,
106
113
deltaX : - 200 ,
107
- } ) ;
114
+ } ] ) ;
108
115
} ) ;
109
116
110
117
it ( 'does nothing if zero delta is provided' , async function ( ) {
111
- await commands . windowsScroll ( {
118
+ await driver . execute ( 'windows: scroll' , [ {
112
119
x : 100 ,
113
120
y : 100 ,
114
121
deltaY : 0 ,
115
- } ) ;
122
+ } ] ) ;
116
123
} ) ;
117
124
118
125
it ( 'fails if wrong input is provided' , async function ( ) {
@@ -136,38 +143,38 @@ describe('winapi', function () {
136
143
] ;
137
144
138
145
for ( const errData of errDatas ) {
139
- await commands . windowsScroll ( errData ) . should . be . rejected ;
146
+ await driver . execute ( 'windows: scroll' , [ errData ] ) . should . be . rejected ;
140
147
}
141
148
} ) ;
142
149
} ) ;
143
150
144
151
describe ( 'mouseClickAndDrag' , function ( ) {
145
152
it ( 'performs drag gesture with Ctrl+Shift depressed' , async function ( ) {
146
- await commands . windowsClickAndDrag ( {
153
+ await driver . execute ( 'windows: clickAndDrag' , [ {
147
154
startX : 600 ,
148
155
startY : 300 ,
149
156
endX : 500 ,
150
157
endY : 400 ,
151
158
modifierKeys : [ 'ctrl' , 'shift' ] ,
152
- } ) ;
159
+ } ] ) ;
153
160
} ) ;
154
161
} ) ;
155
162
156
163
describe ( 'windowsHover' , function ( ) {
157
164
it ( 'performs hover gesture with Ctrl+Shift depressed' , async function ( ) {
158
- await commands . windowsHover ( {
165
+ await driver . execute ( 'windows: clickAndDrag' , [ {
159
166
startX : 600 ,
160
167
startY : 300 ,
161
168
endX : 500 ,
162
169
endY : 400 ,
163
170
modifierKeys : [ 'ctrl' , 'shift' ] ,
164
- } ) ;
171
+ } ] ) ;
165
172
} ) ;
166
173
} ) ;
167
174
168
175
describe ( 'keys' , function ( ) {
169
176
it ( 'performs complex key input' , async function ( ) {
170
- await commands . windowsKeys ( {
177
+ await driver . execute ( 'windows: keys' , [ {
171
178
actions : [
172
179
{ virtualKeyCode : 0x10 , down : true } ,
173
180
{ pause : 100 } ,
@@ -176,7 +183,7 @@ describe('winapi', function () {
176
183
{ pause : 100 } ,
177
184
{ virtualKeyCode : 0x10 , down : false } ,
178
185
]
179
- } ) ;
186
+ } ] ) ;
180
187
} ) ;
181
188
182
189
it ( 'fails if wrong input is provided' , async function ( ) {
@@ -199,7 +206,7 @@ describe('winapi', function () {
199
206
] ;
200
207
201
208
for ( const errData of errDatas ) {
202
- await commands . windowsKeys ( errData ) . should . be . rejected ;
209
+ await driver . execute ( 'windows: keys' , [ errData ] ) . should . be . rejected ;
203
210
}
204
211
} ) ;
205
212
} ) ;
0 commit comments