@@ -14,6 +14,8 @@ export class Application {
1414 private app : ElectronApplication | null = null ;
1515 private mainPage : Page | null = null ;
1616 private extension : Extension | null = null ;
17+ private vscodeExecutablePath : string | null = null ;
18+ private isExtensionActivited : boolean = false ;
1719 private extensionDirectory = path . join ( __dirname , ".." , ".." , ".vscode-test" , "extensions" ) ;
1820 private userDataDirectory = path . join ( __dirname , ".." , ".." , ".vscode-test" , "temp-user-data" ) ;
1921 private vsixDirectory = path . join ( __dirname , ".." , ".." , "resources" , "extension" ) ;
@@ -27,8 +29,11 @@ export class Application {
2729 async launch ( ) : Promise < Page > {
2830 if ( this . mainPage ) return this . mainPage ;
2931
30- const vscodeExecutablePath = await this . downloadVSCodeExecutable ( ) ;
32+ if ( ! this . vscodeExecutablePath ) {
33+ throw new Error ( "VSCode has not been downloaded yet." ) ;
34+ }
3135
36+ const vscodeExecutablePath = this . vscodeExecutablePath ;
3237 const [ ...args ] = resolveCliArgsFromVSCodeExecutablePath ( vscodeExecutablePath ) ;
3338 args . push ( "--disable-workspace-trust" ) ;
3439 args . push ( "--no-sandbox" ) ;
@@ -59,14 +64,6 @@ export class Application {
5964 SmokeTestLogger . info ( "Cannot clean up user data, will try it again in test setup." ) ;
6065 }
6166
62- try {
63- await this . cleanExtensionData ( ) ;
64- } catch {
65- SmokeTestLogger . info (
66- "Cannot clean up extension data, will try it again in test setup." ,
67- ) ;
68- }
69-
7067 if ( this . app ) {
7168 await this . app . close ( ) ;
7269 this . app = null ;
@@ -91,8 +88,9 @@ export class Application {
9188 utilities . spawnSync ( cliPath , args , { stdio : "inherit" } ) ;
9289 }
9390
94- this . extension = new Extension ( ) ;
95- return this . extension ;
91+ const extension = new Extension ( ) ;
92+ this . extension = extension ;
93+ return extension ;
9694 }
9795
9896 getMainPage ( ) : Page {
@@ -102,6 +100,28 @@ export class Application {
102100 return this . mainPage ;
103101 }
104102
103+ getExtension ( ) : Extension {
104+ if ( ! this . extension ) {
105+ throw new Error ( "VSCode has not been launched yet." ) ;
106+ }
107+ return this . extension ;
108+ }
109+
110+ setVSCodeExecutablePath ( vscodeExecutablePath : string ) {
111+ this . vscodeExecutablePath = vscodeExecutablePath ;
112+ }
113+
114+ setExtensionStatus ( isActivited : boolean ) {
115+ this . isExtensionActivited = isActivited ;
116+ }
117+
118+ getExtensionStatus ( ) : boolean {
119+ if ( ! this . isExtensionActivited ) {
120+ throw new Error ( "Cannot get extension status." ) ;
121+ }
122+ return this . isExtensionActivited ;
123+ }
124+
105125 async cleanUserData ( ) : Promise < void > {
106126 if ( fs . existsSync ( this . userDataDirectory ) ) {
107127 SmokeTestLogger . info (
0 commit comments