During quit, close unloaded windows

Released under CC0.
This commit is contained in:
Stepan Hruda
2018-08-14 17:44:11 -04:00
parent 4dd4123aa1
commit 12c4e596b9
2 changed files with 33 additions and 1 deletions

View File

@@ -606,6 +606,8 @@ describe('AtomApplication', function () {
assert(!electron.app.didQuit())
await Promise.all([window1.lastPrepareToUnloadPromise, window2.lastPrepareToUnloadPromise])
assert(!electron.app.didQuit())
await atomApplication.lastBeforeQuitPromise
await new Promise(process.nextTick)
assert(electron.app.didQuit())
})
@@ -634,6 +636,29 @@ describe('AtomApplication', function () {
assert(electron.app.didQuit())
})
it('closes successfully unloaded windows when quitting', async () => {
const atomApplication = buildAtomApplication()
const [window1] = await atomApplication.launch(parseCommandLine([]))
const [window2] = await atomApplication.launch(parseCommandLine([]))
await Promise.all([window1.loadedPromise, window2.loadedPromise])
await evalInWebContents(window1.browserWindow.webContents, sendBackToMainProcess => {
atom.workspace.getActiveTextEditor().insertText('unsaved text')
sendBackToMainProcess()
})
// Choosing "Cancel"
mockElectronShowMessageBox({response: 1})
electron.app.quit()
await atomApplication.lastBeforeQuitPromise
assert(atomApplication.getAllWindows().length === 1)
// Choosing "Don't save"
mockElectronShowMessageBox({response: 2})
electron.app.quit()
await atomApplication.lastBeforeQuitPromise
assert(atomApplication.getAllWindows().length === 0)
})
function buildAtomApplication (params = {}) {
const atomApplication = new AtomApplication(Object.assign({
resourcePath: ATOM_RESOURCE_PATH,