mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
During quit, close unloaded windows
Released under CC0.
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user