@@ -7,7 +7,9 @@ import mockfs from 'mock-fs';
77import fs from 'fs-extra' ;
88import path from 'path' ;
99import VirtualBoxInstall from 'browser/model/virtualbox' ;
10+ import { VirtualBoxInstallWindows } from 'browser/model/virtualbox' ;
1011import Logger from 'browser/services/logger' ;
12+ import Platform from 'browser/services/platform' ;
1113import Downloader from 'browser/model/helpers/downloader' ;
1214import Installer from 'browser/model/helpers/installer' ;
1315import Hash from 'browser/model/helpers/hash' ;
@@ -139,40 +141,101 @@ describe('Virtualbox installer', function() {
139141 describe ( 'installation' , function ( ) {
140142 let downloadedFile = path . join ( 'tempDirectory' , 'virtualbox.exe' ) ;
141143
142- it ( 'should execute the silent extract' , function ( ) {
143- sandbox . stub ( child_process , 'execFile' ) . yields ( 'done' ) ;
144+ describe ( 'on windows' , function ( ) {
145+ let installer ;
146+ beforeEach ( function ( ) {
147+ sandbox . stub ( Platform , 'getOS' ) . returns ( 'win32' ) ;
148+ installer = new VirtualBoxInstallWindows ( version , revision , installerDataSvc , downloadUrl , null ) ;
149+ installer . ipcRenderer = { on : function ( ) { } } ;
150+ } )
151+
152+ it ( 'should execute the silent extract' , function ( ) {
153+ sandbox . stub ( child_process , 'execFile' ) . yields ( 'done' ) ;
154+
155+ let data = [
156+ '--extract' ,
157+ '-path' ,
158+ installerDataSvc . tempDir ( ) ,
159+ '--silent'
160+ ] ;
144161
145- let data = [
146- '--extract' ,
147- '-path' ,
148- installerDataSvc . tempDir ( ) ,
149- '--silent'
150- ] ;
162+ let spy = sandbox . spy ( Installer . prototype , 'execFile' ) ;
163+ let item2 = new InstallableItem ( 'jdk' , 1000 , 'url' , 'installFile' , 'targetFolderName' , installerDataSvc ) ;
164+ item2 . setInstallComplete ( ) ;
165+ item2 . thenInstall ( installer ) ;
166+ installer . install ( fakeProgress , success , failure ) ;
151167
152- let spy = sandbox . spy ( Installer . prototype , 'execFile' ) ;
153- let item2 = new InstallableItem ( 'jdk' , 1000 , 'url' , 'installFile' , 'targetFolderName' , installerDataSvc ) ;
154- item2 . setInstallComplete ( ) ;
155- item2 . thenInstall ( installer ) ;
156- installer . install ( fakeProgress , success , failure ) ;
168+ expect ( spy ) . to . have . been . called ;
169+ expect ( spy ) . calledWith ( downloadedFile , data ) ;
170+ } ) ;
157171
158- expect ( spy ) . to . have . been . called ;
159- expect ( spy ) . calledWith ( downloadedFile , data ) ;
160- } ) ;
172+ it ( 'setup should wait for all downloads to complete' , function ( ) {
173+ let helper = new Installer ( 'virtualbox' , fakeProgress ) ;
174+ let spy = sandbox . spy ( installer , 'installMsi' ) ;
175+
176+ installerDataSvc . downloading = true ;
161177
162- it ( 'setup should wait for all downloads to complete' , function ( ) {
163- let helper = new Installer ( 'virtualbox' , fakeProgress ) ;
164- let spy = sandbox . spy ( installer , 'installMsi' ) ;
178+ installer . configure ( helper ) ;
165179
166- installerDataSvc . downloading = true ;
180+ expect ( fakeProgress . setStatus ) . calledWith ( 'Waiting for all downloads to finish' ) ;
181+ expect ( spy ) . not . called ;
182+ } ) ;
167183
168- installer . configure ( helper ) ;
184+ describe ( 'configure' , function ( ) {
185+ it ( 'should call installMsi if all downloads have finished' , function ( ) {
186+ let helper = new Installer ( 'virtualbox' , fakeProgress ) ;
187+ let spy = sandbox . spy ( installer , 'installMsi' ) ;
188+ sandbox . stub ( child_process , 'execFile' ) . yields ( ) ;
169189
170- expect ( fakeProgress . setStatus ) . calledWith ( 'Waiting for all downloads to finish' ) ;
171- expect ( spy ) . not . called ;
172- } ) ;
190+ installerDataSvc . downloading = false ;
191+
192+ installer . configure ( helper ) ;
193+ expect ( spy ) . calledOnce ;
194+ } ) ;
195+ } ) ;
196+
197+ describe ( 'installMsi' , function ( ) {
198+ let helper , resolve , reject ;
199+
200+ beforeEach ( function ( ) {
201+ helper = new Installer ( 'virtualbox' , fakeProgress , success , failure ) ;
202+ sandbox . stub ( child_process , 'execFile' ) . yields ( ) ;
203+ resolve = ( argument ) => { Promise . resolve ( argument ) ; } ;
204+ reject = ( argument ) => { Promise . reject ( argument ) ; } ;
205+ } ) ;
206+
207+ it ( 'should set progress to "Installing"' , function ( ) {
208+ installer . installMsi ( helper , resolve , reject ) ;
209+
210+ expect ( fakeProgress . setStatus ) . to . have . been . calledOnce ;
211+ expect ( fakeProgress . setStatus ) . to . have . been . calledWith ( 'Installing' ) ;
212+ } ) ;
213+
214+ it ( 'should execute the msi installer' , function ( ) {
215+ let spy = sandbox . spy ( Installer . prototype , 'execFile' ) ;
216+
217+ let msiFile = path . join ( installerDataSvc . tempDir ( ) , 'VirtualBox-' + version + '-r' + revision + '-MultiArch_amd64.msi' ) ;
218+ let opts = [
219+ '/i' ,
220+ msiFile ,
221+ 'INSTALLDIR=' + installerDataSvc . virtualBoxDir ( ) ,
222+ '/qn' ,
223+ '/norestart' ,
224+ '/Liwe' ,
225+ path . join ( installerDataSvc . installDir ( ) , 'vbox.log' )
226+ ] ;
227+
228+ installer . installMsi ( helper , resolve , reject ) ;
229+
230+ expect ( spy ) . to . have . been . calledOnce ;
231+ expect ( spy ) . to . have . been . calledWith ( 'msiexec' , opts ) ;
232+ } ) ;
233+ } ) ;
234+ } )
173235
174236 it ( 'should catch errors during the installation' , function ( done ) {
175237 sandbox . stub ( child_process , 'execFile' ) . yields ( new Error ( 'critical error' ) ) ;
238+ sandbox . stub ( child_process , 'exec' ) . yields ( new Error ( 'critical error' ) ) ;
176239 let item2 = new InstallableItem ( 'jdk' , 1000 , 'url' , 'installFile' , 'targetFolderName' , installerDataSvc ) ;
177240 item2 . setInstallComplete ( ) ;
178241 item2 . thenInstall ( installer ) ;
@@ -195,57 +258,6 @@ describe('Virtualbox installer', function() {
195258
196259 expect ( spy ) . to . have . not . been . called ;
197260 } ) ;
198-
199- describe ( 'configure' , function ( ) {
200- it ( 'should call installMsi if all downloads have finished' , function ( ) {
201- let helper = new Installer ( 'virtualbox' , fakeProgress ) ;
202- let spy = sandbox . spy ( installer , 'installMsi' ) ;
203- sandbox . stub ( child_process , 'execFile' ) . yields ( ) ;
204-
205- installerDataSvc . downloading = false ;
206-
207- installer . configure ( helper ) ;
208- expect ( spy ) . calledOnce ;
209- } ) ;
210- } ) ;
211-
212- describe ( 'installMsi' , function ( ) {
213- let helper , resolve , reject ;
214-
215- beforeEach ( function ( ) {
216- helper = new Installer ( 'virtualbox' , fakeProgress , success , failure ) ;
217- sandbox . stub ( child_process , 'execFile' ) . yields ( ) ;
218- resolve = ( argument ) => { Promise . resolve ( argument ) ; } ;
219- reject = ( argument ) => { Promise . reject ( argument ) ; } ;
220- } ) ;
221-
222- it ( 'should set progress to "Installing"' , function ( ) {
223- installer . installMsi ( helper , resolve , reject ) ;
224-
225- expect ( fakeProgress . setStatus ) . to . have . been . calledOnce ;
226- expect ( fakeProgress . setStatus ) . to . have . been . calledWith ( 'Installing' ) ;
227- } ) ;
228-
229- it ( 'should execute the msi installer' , function ( ) {
230- let spy = sandbox . spy ( Installer . prototype , 'execFile' ) ;
231-
232- let msiFile = path . join ( installerDataSvc . tempDir ( ) , 'VirtualBox-' + version + '-r' + revision + '-MultiArch_amd64.msi' ) ;
233- let opts = [
234- '/i' ,
235- msiFile ,
236- 'INSTALLDIR=' + installerDataSvc . virtualBoxDir ( ) ,
237- '/qn' ,
238- '/norestart' ,
239- '/Liwe' ,
240- path . join ( installerDataSvc . installDir ( ) , 'vbox.log' )
241- ] ;
242-
243- installer . installMsi ( helper , resolve , reject ) ;
244-
245- expect ( spy ) . to . have . been . calledOnce ;
246- expect ( spy ) . to . have . been . calledWith ( 'msiexec' , opts ) ;
247- } ) ;
248- } ) ;
249261 } ) ;
250262
251263 describe ( 'detection' , function ( ) {
0 commit comments