@@ -2,50 +2,99 @@ import { expect } from 'chai';
2
2
import { InputBox , Workbench } from 'vscode-extension-tester' ;
3
3
4
4
describe ( 'Debug Configuration Test' , ( ) => {
5
- let input : InputBox ;
5
+ let workbench : Workbench = null ;
6
+ let activeInput : InputBox = null ;
7
+ let debugStarted : boolean = false ;
6
8
7
- const attachConfigText :string = 'AutoLISP Debug: Attach' ;
8
- const launchConfigText :string = 'AutoLISP Debug: Launch' ;
9
- const startDebugCmd :string = 'workbench.action.debug.start' ;
10
-
11
- before ( async ( ) => {
12
- } ) ;
9
+ const attachConfigText : string = 'AutoLISP Debug: Attach' ;
10
+ const launchConfigText : string = 'AutoLISP Debug: Launch' ;
11
+
12
+ const startDebugCmd : string = 'workbench.action.debug.start' ;
13
+ const stopDebugCmd : string = 'workbench.action.debug.stop' ;
13
14
14
- after ( async ( ) => {
15
- await input . cancel ( ) ;
16
- } ) ;
15
+ const expectedAttachHint = 'Pick the process to attach.' ;
16
+ const expectedLaunchHint = 'Specify the absolute path for the product.' ;
17
17
18
- // to verify that the Attach and Launch config items show up when starting to debug via. VS Code
19
- it ( 'should show debug config items on F5' , async function ( ) {
20
- this . timeout ( 15000 ) ;
18
+ beforeEach ( async ( ) => {
19
+ activeInput = null ;
20
+ debugStarted = false ;
21
21
22
- const workbench = new Workbench ( ) ;
22
+ workbench = new Workbench ( ) ;
23
23
await workbench . executeCommand ( startDebugCmd ) ;
24
+ } ) ;
24
25
25
- input = await InputBox . create ( ) ;
26
- expect ( await input . isDisplayed ( ) ) . is . true ;
26
+ afterEach ( async ( ) => {
27
+ if ( activeInput ) {
28
+ if ( await activeInput . isDisplayed ( ) )
29
+ await activeInput . cancel ( ) ;
30
+ }
27
31
28
- const picks = await input . getQuickPicks ( ) ;
32
+ if ( debugStarted ) {
33
+ await workbench . executeCommand ( stopDebugCmd ) ;
34
+ }
35
+ } ) ;
29
36
30
- const attachCfg :InputBox [ ] = await findAll ( picks , async ( x :InputBox ) => { return attachConfigText === await x . getText ( ) ; } ) ;
37
+ // to verify that the config item named "Attach" is really for attach mode
38
+ it ( 'should show debug config items on F5' , async function ( ) {
39
+ const cmdInput = await getActiveInputBox ( ) ;
40
+ expect ( await cmdInput . isDisplayed ( ) ) . is . true ;
41
+
42
+ const picks = await cmdInput . getQuickPicks ( ) ;
43
+
44
+ const attachCfg : InputBox [ ] = await findAll ( picks , async ( x : InputBox ) => { return attachConfigText === await x . getText ( ) ; } ) ;
31
45
expect ( attachCfg . length ) . equals ( 1 ) ;
32
46
33
- const launchCfg :InputBox [ ] = await findAll ( picks , async ( x :InputBox ) => { return launchConfigText === await x . getText ( ) ; } ) ;
47
+ const launchCfg : InputBox [ ] = await findAll ( picks , async ( x : InputBox ) => { return launchConfigText === await x . getText ( ) ; } ) ;
34
48
expect ( launchCfg . length ) . equals ( 1 ) ;
35
49
} ) ;
36
50
37
- async function findAll ( array , callbackFind ) : Promise < Array < InputBox > > {
38
- let ret :Array < InputBox > = [ ] ;
51
+ // to verify that the "Attach" config item is bound to attach mode
52
+ it ( 'should debug in attach mode after selecting Debug: Attach' , async function ( ) {
53
+ const cmdInput = await getActiveInputBox ( ) ;
54
+ expect ( await cmdInput . isDisplayed ( ) ) . is . true ;
55
+
56
+ await cmdInput . setText ( attachConfigText ) ;
57
+ await cmdInput . confirm ( ) ;
58
+
59
+ debugStarted = true ;
60
+
61
+ const procInput = await getActiveInputBox ( ) ;
62
+ expect ( ( await procInput . getPlaceHolder ( ) ) . startsWith ( expectedAttachHint ) ) . true ;
63
+ } ) ;
64
+
65
+ // to verify that the config item named "Launch" is really for launch mode
66
+ it ( 'should debug in launch mode after selecting Debug: Launch' , async function ( ) {
67
+ const cmdInput = await getActiveInputBox ( ) ;
68
+ expect ( await cmdInput . isDisplayed ( ) ) . is . true ;
69
+
70
+ await cmdInput . setText ( launchConfigText ) ;
71
+ await cmdInput . confirm ( ) ;
72
+
73
+ debugStarted = true ;
74
+
75
+ const pathInput = await getActiveInputBox ( ) ;
76
+ expect ( ( await pathInput . getPlaceHolder ( ) ) . startsWith ( expectedLaunchHint ) ) . true ;
77
+ } ) ;
39
78
40
- for ( const item of array ) {
79
+ async function findAll ( array , callbackFind ) : Promise < Array < InputBox > > {
80
+ let ret : Array < InputBox > = [ ] ;
81
+
82
+ for ( const item of array ) {
41
83
const matched : boolean = await callbackFind ( item ) ;
42
- if ( ! matched )
84
+ if ( ! matched )
43
85
continue ;
44
-
86
+
45
87
ret . push ( item ) ;
46
88
}
47
89
48
90
return ret ;
49
91
}
50
92
93
+ async function getActiveInputBox ( ) : Promise < InputBox > {
94
+ let input = await InputBox . create ( ) ;
95
+ activeInput = input ;
96
+
97
+ return activeInput ;
98
+ }
99
+
51
100
} ) ;
0 commit comments