From ef7357dedcdd8cd04ac8668a8be0c124f4e714dd Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Tue, 28 Nov 2017 02:29:37 +0100 Subject: [PATCH] update tests for menu closed event and call cancel on closePopup --- atom/browser/api/atom_api_menu_views.cc | 2 ++ spec/api-menu-spec.js | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_menu_views.cc b/atom/browser/api/atom_api_menu_views.cc index 7a53d5d55307..62a785519fc9 100644 --- a/atom/browser/api/atom_api_menu_views.cc +++ b/atom/browser/api/atom_api_menu_views.cc @@ -60,6 +60,8 @@ void MenuViews::PopupAt(Window* window, int x, int y, int positioning_item) { } void MenuViews::ClosePopupAt(int32_t window_id) { + if (menu_runners_[window_id]) + menu_runners_[window_id]->Cancel(); menu_runners_.erase(window_id); } diff --git a/spec/api-menu-spec.js b/spec/api-menu-spec.js index dc73bf4bd9fb..f607e2b8773a 100644 --- a/spec/api-menu-spec.js +++ b/spec/api-menu-spec.js @@ -329,25 +329,30 @@ describe('Menu module', () => { let w = null let menu - beforeEach(() => { + beforeEach((done) => { w = new BrowserWindow({show: false, width: 200, height: 200}) menu = Menu.buildFromTemplate([ { label: '1' } ]) - menu.popup(w, {x: 100, y: 100, async: true}) - menu.closePopup(w) + + w.loadURL('data:text/html,teszt') + w.webContents.on('dom-ready', () => { + done() + }) }) afterEach(() => { return closeWindow(w).then(() => { w = null }) }) - it('emits closed event', () => { + it('emits closed event', (done) => { + menu.popup(w, {x: 100, y: 100, async: true}) menu.on('closed', () => { done() }) + menu.closePopup(w) }) })