🎨 code comments and test for getMenuBarHeight function

This commit is contained in:
Shubham 2017-05-30 17:26:02 -04:00
parent 793d5fd191
commit 62d9bf9bae
4 changed files with 21 additions and 6 deletions

View file

@ -120,9 +120,9 @@ void Screen::BuildPrototype(
.SetMethod("getPrimaryDisplay", &Screen::GetPrimaryDisplay)
.SetMethod("getAllDisplays", &Screen::GetAllDisplays)
.SetMethod("getDisplayNearestPoint", &Screen::GetDisplayNearestPoint)
#if defined(OS_MACOSX)
#if defined(OS_MACOSX)
.SetMethod("getMenuBarHeight", &Screen::getMenuBarHeight)
#endif
#endif
.SetMethod("getDisplayMatching", &Screen::GetDisplayMatching);
}

View file

@ -1,3 +1,7 @@
// Copyright (c) 2017 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#import "atom/browser/api/atom_api_screen.h"
#import <Cocoa/Cocoa.h>
@ -5,11 +9,10 @@
namespace atom {
namespace api {
#if defined(OS_MACOSX)
int Screen::getMenuBarHeight(){
int Screen::getMenuBarHeight() {
return [[NSApp mainMenu] menuBarHeight];
}
#endif
}// namespace api
}// namespace atom

View file

@ -135,9 +135,9 @@
'atom/browser/api/atom_api_protocol.h',
'atom/browser/api/atom_api_render_process_preferences.cc',
'atom/browser/api/atom_api_render_process_preferences.h',
'atom/browser/api/atom_api_screen_mac.mm',
'atom/browser/api/atom_api_screen.cc',
'atom/browser/api/atom_api_screen.h',
'atom/browser/api/atom_api_screen_mac.mm',
'atom/browser/api/atom_api_session.cc',
'atom/browser/api/atom_api_session.h',
'atom/browser/api/atom_api_system_preferences.cc',

View file

@ -18,4 +18,16 @@ describe('screen module', function () {
assert(display.size.height > 0)
})
})
describe('screen.getMenuBarHeight()', function () {
if (process.platform !== 'darwin') {
return
}
it('returns an integer', function () {
var screenHeight = screen.getMenuBarHeight()
assert.equal(typeof screenHeight, 'number')
})
})
})