chore: support props/fns for BrowserWindow (#22686)

This commit is contained in:
Shelley Vohr 2020-03-16 14:03:35 -07:00 committed by GitHub
parent 20480c8ea8
commit 97d8caa1e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 322 additions and 302 deletions

View file

@ -1115,15 +1115,11 @@ Returns `Integer[]` - Contains the window's maximum width and height.
* `resizable` Boolean * `resizable` Boolean
Sets whether the window can be manually resized by user. Sets whether the window can be manually resized by the user.
**[Deprecated](modernization/property-updates.md)**
#### `win.isResizable()` #### `win.isResizable()`
Returns `Boolean` - Whether the window can be manually resized by user. Returns `Boolean` - Whether the window can be manually resized by the user.
**[Deprecated](modernization/property-updates.md)**
#### `win.setMovable(movable)` _macOS_ _Windows_ #### `win.setMovable(movable)` _macOS_ _Windows_
@ -1131,41 +1127,29 @@ Returns `Boolean` - Whether the window can be manually resized by user.
Sets whether the window can be moved by user. On Linux does nothing. Sets whether the window can be moved by user. On Linux does nothing.
**[Deprecated](modernization/property-updates.md)**
#### `win.isMovable()` _macOS_ _Windows_ #### `win.isMovable()` _macOS_ _Windows_
Returns `Boolean` - Whether the window can be moved by user. Returns `Boolean` - Whether the window can be moved by user.
On Linux always returns `true`. On Linux always returns `true`.
**[Deprecated](modernization/property-updates.md)**
#### `win.setMinimizable(minimizable)` _macOS_ _Windows_ #### `win.setMinimizable(minimizable)` _macOS_ _Windows_
* `minimizable` Boolean * `minimizable` Boolean
Sets whether the window can be manually minimized by user. On Linux does Sets whether the window can be manually minimized by user. On Linux does nothing.
nothing.
**[Deprecated](modernization/property-updates.md)**
#### `win.isMinimizable()` _macOS_ _Windows_ #### `win.isMinimizable()` _macOS_ _Windows_
Returns `Boolean` - Whether the window can be manually minimized by user Returns `Boolean` - Whether the window can be manually minimized by the user.
On Linux always returns `true`. On Linux always returns `true`.
**[Deprecated](modernization/property-updates.md)**
#### `win.setMaximizable(maximizable)` _macOS_ _Windows_ #### `win.setMaximizable(maximizable)` _macOS_ _Windows_
* `maximizable` Boolean * `maximizable` Boolean
Sets whether the window can be manually maximized by user. On Linux does Sets whether the window can be manually maximized by user. On Linux does nothing.
nothing.
**[Deprecated](modernization/property-updates.md)**
#### `win.isMaximizable()` _macOS_ _Windows_ #### `win.isMaximizable()` _macOS_ _Windows_
@ -1173,23 +1157,15 @@ Returns `Boolean` - Whether the window can be manually maximized by user.
On Linux always returns `true`. On Linux always returns `true`.
**[Deprecated](modernization/property-updates.md)**
#### `win.setFullScreenable(fullscreenable)` #### `win.setFullScreenable(fullscreenable)`
* `fullscreenable` Boolean * `fullscreenable` Boolean
Sets whether the maximize/zoom window button toggles fullscreen mode or Sets whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
maximizes the window.
**[Deprecated](modernization/property-updates.md)**
#### `win.isFullScreenable()` #### `win.isFullScreenable()`
Returns `Boolean` - Whether the maximize/zoom window button toggles fullscreen mode or Returns `Boolean` - Whether the maximize/zoom window button toggles fullscreen mode or maximizes the window.
maximizes the window.
**[Deprecated](modernization/property-updates.md)**
#### `win.setClosable(closable)` _macOS_ _Windows_ #### `win.setClosable(closable)` _macOS_ _Windows_
@ -1197,16 +1173,12 @@ maximizes the window.
Sets whether the window can be manually closed by user. On Linux does nothing. Sets whether the window can be manually closed by user. On Linux does nothing.
**[Deprecated](modernization/property-updates.md)**
#### `win.isClosable()` _macOS_ _Windows_ #### `win.isClosable()` _macOS_ _Windows_
Returns `Boolean` - Whether the window can be manually closed by user. Returns `Boolean` - Whether the window can be manually closed by user.
On Linux always returns `true`. On Linux always returns `true`.
**[Deprecated](modernization/property-updates.md)**
#### `win.setAlwaysOnTop(flag[, level][, relativeLevel])` #### `win.setAlwaysOnTop(flag[, level][, relativeLevel])`
* `flag` Boolean * `flag` Boolean
@ -1618,23 +1590,17 @@ This cannot be called when `titleBarStyle` is set to `customButtonsOnHover`.
Sets whether the window menu bar should hide itself automatically. Once set the Sets whether the window menu bar should hide itself automatically. Once set the
menu bar will only show when users press the single `Alt` key. menu bar will only show when users press the single `Alt` key.
If the menu bar is already visible, calling `setAutoHideMenuBar(true)` won't If the menu bar is already visible, calling `setAutoHideMenuBar(true)` won't hide it immediately.
hide it immediately.
**[Deprecated](modernization/property-updates.md)**
#### `win.isMenuBarAutoHide()` #### `win.isMenuBarAutoHide()`
Returns `Boolean` - Whether menu bar automatically hides itself. Returns `Boolean` - Whether menu bar automatically hides itself.
**[Deprecated](modernization/property-updates.md)**
#### `win.setMenuBarVisibility(visible)` _Windows_ _Linux_ #### `win.setMenuBarVisibility(visible)` _Windows_ _Linux_
* `visible` Boolean * `visible` Boolean
Sets whether the menu bar should be visible. If the menu bar is auto-hide, users Sets whether the menu bar should be visible. If the menu bar is auto-hide, users can still bring up the menu bar by pressing the single `Alt` key.
can still bring up the menu bar by pressing the single `Alt` key.
#### `win.isMenuBarVisible()` #### `win.isMenuBarVisible()`

View file

@ -72,6 +72,43 @@ BrowserWindow.prototype._init = function () {
return this.webContents.devToolsWebContents return this.webContents.devToolsWebContents
} }
}) })
// Properties
Object.defineProperty(this, 'autoHideMenuBar', {
get: () => this.isMenuBarAutoHide(),
set: (autoHide) => this.setAutoHideMenuBar(autoHide)
})
Object.defineProperty(this, 'minimizable', {
get: () => this.isMinimizable(),
set: (min) => this.setMinimizable(min)
})
Object.defineProperty(this, 'maximizable', {
get: () => this.isMaximizable(),
set: (max) => this.setMaximizable(max)
})
Object.defineProperty(this, 'resizable', {
get: () => this.isResizable(),
set: (res) => this.setResizable(res)
})
Object.defineProperty(this, 'fullScreenable', {
get: () => this.isFullScreenable(),
set: (full) => this.setFullScreenable(full)
})
Object.defineProperty(this, 'closable', {
get: () => this.isClosable(),
set: (close) => this.setClosable(close)
})
Object.defineProperty(this, 'movable', {
get: () => this.isMovable(),
set: (move) => this.setMovable(move)
})
} }
const isBrowserWindow = (win) => { const isBrowserWindow = (win) => {
@ -165,13 +202,4 @@ Object.assign(BrowserWindow.prototype, {
} }
}) })
// Deprecations
deprecate.fnToProperty(BrowserWindow.prototype, 'autoHideMenuBar', '_isMenuBarAutoHide', '_setAutoHideMenuBar')
deprecate.fnToProperty(BrowserWindow.prototype, 'minimizable', '_isMinimizable', '_setMinimizable')
deprecate.fnToProperty(BrowserWindow.prototype, 'maximizable', '_isMaximizable', '_setMaximizable')
deprecate.fnToProperty(BrowserWindow.prototype, 'resizable', '_isResizable', '_setResizable')
deprecate.fnToProperty(BrowserWindow.prototype, 'fullScreenable', '_isFullScreenable', '_setFullScreenable')
deprecate.fnToProperty(BrowserWindow.prototype, 'closable', '_isClosable', '_setClosable')
deprecate.fnToProperty(BrowserWindow.prototype, 'movable', '_isMovable', '_setMovable')
module.exports = BrowserWindow module.exports = BrowserWindow

View file

@ -1120,30 +1120,18 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setSheetOffset", &TopLevelWindow::SetSheetOffset) .SetMethod("setSheetOffset", &TopLevelWindow::SetSheetOffset)
.SetMethod("moveAbove", &TopLevelWindow::MoveAbove) .SetMethod("moveAbove", &TopLevelWindow::MoveAbove)
.SetMethod("moveTop", &TopLevelWindow::MoveTop) .SetMethod("moveTop", &TopLevelWindow::MoveTop)
.SetMethod("_setResizable", &TopLevelWindow::SetResizable) .SetMethod("setResizable", &TopLevelWindow::SetResizable)
.SetMethod("_isResizable", &TopLevelWindow::IsResizable) .SetMethod("isResizable", &TopLevelWindow::IsResizable)
.SetProperty("resizable", &TopLevelWindow::IsResizable, .SetMethod("setMovable", &TopLevelWindow::SetMovable)
&TopLevelWindow::SetResizable) .SetMethod("isMovable", &TopLevelWindow::IsMovable)
.SetMethod("_setMovable", &TopLevelWindow::SetMovable) .SetMethod("setMinimizable", &TopLevelWindow::SetMinimizable)
.SetMethod("_isMovable", &TopLevelWindow::IsMovable) .SetMethod("isMinimizable", &TopLevelWindow::IsMinimizable)
.SetProperty("movable", &TopLevelWindow::IsMovable, .SetMethod("setMaximizable", &TopLevelWindow::SetMaximizable)
&TopLevelWindow::SetMovable) .SetMethod("isMaximizable", &TopLevelWindow::IsMaximizable)
.SetMethod("_setMinimizable", &TopLevelWindow::SetMinimizable) .SetMethod("setFullScreenable", &TopLevelWindow::SetFullScreenable)
.SetMethod("_isMinimizable", &TopLevelWindow::IsMinimizable) .SetMethod("isFullScreenable", &TopLevelWindow::IsFullScreenable)
.SetProperty("minimizable", &TopLevelWindow::IsMinimizable, .SetMethod("setClosable", &TopLevelWindow::SetClosable)
&TopLevelWindow::SetMinimizable) .SetMethod("isClosable", &TopLevelWindow::IsClosable)
.SetMethod("_setMaximizable", &TopLevelWindow::SetMaximizable)
.SetMethod("_isMaximizable", &TopLevelWindow::IsMaximizable)
.SetProperty("maximizable", &TopLevelWindow::IsMaximizable,
&TopLevelWindow::SetMaximizable)
.SetMethod("_setFullScreenable", &TopLevelWindow::SetFullScreenable)
.SetMethod("_isFullScreenable", &TopLevelWindow::IsFullScreenable)
.SetProperty("fullScreenable", &TopLevelWindow::IsFullScreenable,
&TopLevelWindow::SetFullScreenable)
.SetMethod("_setClosable", &TopLevelWindow::SetClosable)
.SetMethod("_isClosable", &TopLevelWindow::IsClosable)
.SetProperty("closable", &TopLevelWindow::IsClosable,
&TopLevelWindow::SetClosable)
.SetMethod("setAlwaysOnTop", &TopLevelWindow::SetAlwaysOnTop) .SetMethod("setAlwaysOnTop", &TopLevelWindow::SetAlwaysOnTop)
.SetMethod("isAlwaysOnTop", &TopLevelWindow::IsAlwaysOnTop) .SetMethod("isAlwaysOnTop", &TopLevelWindow::IsAlwaysOnTop)
.SetMethod("center", &TopLevelWindow::Center) .SetMethod("center", &TopLevelWindow::Center)
@ -1217,10 +1205,8 @@ void TopLevelWindow::BuildPrototype(v8::Isolate* isolate,
&TopLevelWindow::IsExcludedFromShownWindowsMenu, &TopLevelWindow::IsExcludedFromShownWindowsMenu,
&TopLevelWindow::SetExcludedFromShownWindowsMenu) &TopLevelWindow::SetExcludedFromShownWindowsMenu)
#endif #endif
.SetMethod("_setAutoHideMenuBar", &TopLevelWindow::SetAutoHideMenuBar) .SetMethod("setAutoHideMenuBar", &TopLevelWindow::SetAutoHideMenuBar)
.SetMethod("_isMenuBarAutoHide", &TopLevelWindow::IsMenuBarAutoHide) .SetMethod("isMenuBarAutoHide", &TopLevelWindow::IsMenuBarAutoHide)
.SetProperty("autoHideMenuBar", &TopLevelWindow::IsMenuBarAutoHide,
&TopLevelWindow::SetAutoHideMenuBar)
.SetMethod("setMenuBarVisibility", &TopLevelWindow::SetMenuBarVisibility) .SetMethod("setMenuBarVisibility", &TopLevelWindow::SetMenuBarVisibility)
.SetMethod("isMenuBarVisible", &TopLevelWindow::IsMenuBarVisible) .SetMethod("isMenuBarVisible", &TopLevelWindow::IsMenuBarVisible)
.SetMethod("setAspectRatio", &TopLevelWindow::SetAspectRatio) .SetMethod("setAspectRatio", &TopLevelWindow::SetAspectRatio)

View file

@ -1102,15 +1102,39 @@ describe('BrowserWindow module', () => {
}) })
}) })
describe('autoHideMenuBar property', () => { describe('autoHideMenuBar state', () => {
afterEach(closeAllWindows) afterEach(closeAllWindows)
it('exists', () => {
const w = new BrowserWindow({ show: false })
expect(w).to.have.property('autoHideMenuBar')
// TODO(codebytere): remove when propertyification is complete it('for properties', () => {
expect(w.setAutoHideMenuBar).to.be.a('function') it('can be set with autoHideMenuBar constructor option', () => {
expect(w.isMenuBarAutoHide).to.be.a('function') const w = new BrowserWindow({ show: false, autoHideMenuBar: true })
expect(w.autoHideMenuBar).to.be.true('autoHideMenuBar')
})
it('can be changed', () => {
const w = new BrowserWindow({ show: false })
expect(w.autoHideMenuBar).to.be.false('autoHideMenuBar')
w.autoHideMenuBar = true
expect(w.autoHideMenuBar).to.be.true('autoHideMenuBar')
w.autoHideMenuBar = false
expect(w.autoHideMenuBar).to.be.false('autoHideMenuBar')
})
})
it('for functions', () => {
it('can be set with autoHideMenuBar constructor option', () => {
const w = new BrowserWindow({ show: false, autoHideMenuBar: true })
expect(w.isMenuBarAutoHide()).to.be.true('autoHideMenuBar')
})
it('can be changed', () => {
const w = new BrowserWindow({ show: false })
expect(w.isMenuBarAutoHide()).to.be.false('autoHideMenuBar')
w.setAutoHideMenuBar(true)
expect(w.isMenuBarAutoHide()).to.be.true('autoHideMenuBar')
w.setAutoHideMenuBar(false)
expect(w.isMenuBarAutoHide()).to.be.false('autoHideMenuBar')
})
}) })
}) })
@ -3247,32 +3271,44 @@ describe('BrowserWindow module', () => {
}) })
describe('resizable state', () => { describe('resizable state', () => {
it('can be changed with resizable option', () => { it('with properties', () => {
const w = new BrowserWindow({ show: false, resizable: false }) it('can be set with resizable constructor option', () => {
expect(w.resizable).to.be.false('resizable') const w = new BrowserWindow({ show: false, resizable: false })
expect(w.resizable).to.be.false('resizable')
if (process.platform === 'darwin') { if (process.platform === 'darwin') {
expect(w.maximizable).to.to.true('maximizable') expect(w.maximizable).to.to.true('maximizable')
} }
})
it('can be changed', () => {
const w = new BrowserWindow({ show: false })
expect(w.resizable).to.be.true('resizable')
w.resizable = false
expect(w.resizable).to.be.false('resizable')
w.resizable = true
expect(w.resizable).to.be.true('resizable')
})
}) })
// TODO(codebytere): remove when propertyification is complete it('with functions', () => {
it('can be changed with setResizable method', () => { it('can be set with resizable constructor option', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false, resizable: false })
expect(w.isResizable()).to.be.true('resizable') expect(w.isResizable()).to.be.false('resizable')
w.setResizable(false)
expect(w.isResizable()).to.be.false('resizable')
w.setResizable(true)
expect(w.isResizable()).to.be.true('resizable')
})
it('can be changed with resizable property', () => { if (process.platform === 'darwin') {
const w = new BrowserWindow({ show: false }) expect(w.isMaximizable()).to.to.true('maximizable')
expect(w.resizable).to.be.true('resizable') }
w.resizable = false })
expect(w.resizable).to.be.false('resizable')
w.resizable = true it('can be changed', () => {
expect(w.resizable).to.be.true('resizable') const w = new BrowserWindow({ show: false })
expect(w.isResizable()).to.be.true('resizable')
w.setResizable(false)
expect(w.isResizable()).to.be.false('resizable')
w.setResizable(true)
expect(w.isResizable()).to.be.true('resizable')
})
}) })
it('works for a frameless window', () => { it('works for a frameless window', () => {
@ -3361,200 +3397,203 @@ describe('BrowserWindow module', () => {
// Not implemented on Linux. // Not implemented on Linux.
afterEach(closeAllWindows) afterEach(closeAllWindows)
describe('movable state (property)', () => { describe('movable state', () => {
it('can be changed with movable option', () => { it('with properties', () => {
const w = new BrowserWindow({ show: false, movable: false }) it('can be set with movable constructor option', () => {
expect(w.movable).to.be.false('movable') const w = new BrowserWindow({ show: false, movable: false })
expect(w.movable).to.be.false('movable')
})
it('can be changed', () => {
const w = new BrowserWindow({ show: false })
expect(w.movable).to.be.true('movable')
w.movable = false
expect(w.movable).to.be.false('movable')
w.movable = true
expect(w.movable).to.be.true('movable')
})
}) })
it('can be changed with movable property', () => {
const w = new BrowserWindow({ show: false }) it('with functions', () => {
expect(w.movable).to.be.true('movable') it('can be set with movable constructor option', () => {
w.movable = false const w = new BrowserWindow({ show: false, movable: false })
expect(w.movable).to.be.false('movable') expect(w.isMovable()).to.be.false('movable')
w.movable = true })
expect(w.movable).to.be.true('movable')
it('can be changed', () => {
const w = new BrowserWindow({ show: false })
expect(w.isMovable()).to.be.true('movable')
w.setMovable(false)
expect(w.isMovable()).to.be.false('movable')
w.setMovable(true)
expect(w.isMovable()).to.be.true('movable')
})
}) })
}) })
// TODO(codebytere): remove when propertyification is complete describe('minimizable state', () => {
describe('movable state (methods)', () => { it('with properties', () => {
it('can be changed with movable option', () => { it('can be set with minimizable constructor option', () => {
const w = new BrowserWindow({ show: false, movable: false }) const w = new BrowserWindow({ show: false, minimizable: false })
expect(w.isMovable()).to.be.false('movable') expect(w.minimizable).to.be.false('minimizable')
}) })
it('can be changed with setMovable method', () => {
const w = new BrowserWindow({ show: false })
expect(w.isMovable()).to.be.true('movable')
w.setMovable(false)
expect(w.isMovable()).to.be.false('movable')
w.setMovable(true)
expect(w.isMovable()).to.be.true('movable')
})
})
describe('minimizable state (property)', () => { it('can be changed', () => {
it('can be changed with minimizable option', () => { const w = new BrowserWindow({ show: false })
const w = new BrowserWindow({ show: false, minimizable: false }) expect(w.minimizable).to.be.true('minimizable')
expect(w.minimizable).to.be.false('minimizable') w.minimizable = false
expect(w.minimizable).to.be.false('minimizable')
w.minimizable = true
expect(w.minimizable).to.be.true('minimizable')
})
}) })
it('can be changed with minimizable property', () => { it('with functions', () => {
const w = new BrowserWindow({ show: false }) it('can be set with minimizable constructor option', () => {
expect(w.minimizable).to.be.true('minimizable') const w = new BrowserWindow({ show: false, minimizable: false })
w.minimizable = false expect(w.isMinimizable()).to.be.false('movable')
expect(w.minimizable).to.be.false('minimizable') })
w.minimizable = true
expect(w.minimizable).to.be.true('minimizable')
})
})
// TODO(codebytere): remove when propertyification is complete it('can be changed', () => {
describe('minimizable state (methods)', () => { const w = new BrowserWindow({ show: false })
it('can be changed with minimizable option', () => { expect(w.isMinimizable()).to.be.true('isMinimizable')
const w = new BrowserWindow({ show: false, minimizable: false }) w.setMinimizable(false)
expect(w.isMinimizable()).to.be.false('movable') expect(w.isMinimizable()).to.be.false('isMinimizable')
}) w.setMinimizable(true)
expect(w.isMinimizable()).to.be.true('isMinimizable')
it('can be changed with setMinimizable method', () => { })
const w = new BrowserWindow({ show: false })
expect(w.isMinimizable()).to.be.true('isMinimizable')
w.setMinimizable(false)
expect(w.isMinimizable()).to.be.false('isMinimizable')
w.setMinimizable(true)
expect(w.isMinimizable()).to.be.true('isMinimizable')
}) })
}) })
describe('maximizable state (property)', () => { describe('maximizable state (property)', () => {
it('can be changed with maximizable option', () => { it('with properties', () => {
const w = new BrowserWindow({ show: false, maximizable: false }) it('can be set with maximizable constructor option', () => {
expect(w.maximizable).to.be.false('maximizable') const w = new BrowserWindow({ show: false, maximizable: false })
expect(w.maximizable).to.be.false('maximizable')
})
it('can be changed', () => {
const w = new BrowserWindow({ show: false })
expect(w.maximizable).to.be.true('maximizable')
w.maximizable = false
expect(w.maximizable).to.be.false('maximizable')
w.maximizable = true
expect(w.maximizable).to.be.true('maximizable')
})
it('is not affected when changing other states', () => {
const w = new BrowserWindow({ show: false })
w.maximizable = false
expect(w.maximizable).to.be.false('maximizable')
w.minimizable = false
expect(w.maximizable).to.be.false('maximizable')
w.closable = false
expect(w.maximizable).to.be.false('maximizable')
w.maximizable = true
expect(w.maximizable).to.be.true('maximizable')
w.closable = true
expect(w.maximizable).to.be.true('maximizable')
w.fullScreenable = false
expect(w.maximizable).to.be.true('maximizable')
})
}) })
it('can be changed with maximizable property', () => { it('with functions', () => {
const w = new BrowserWindow({ show: false }) it('can be set with maximizable constructor option', () => {
expect(w.maximizable).to.be.true('maximizable') const w = new BrowserWindow({ show: false, maximizable: false })
w.maximizable = false expect(w.isMaximizable()).to.be.false('isMaximizable')
expect(w.maximizable).to.be.false('maximizable') })
w.maximizable = true
expect(w.maximizable).to.be.true('maximizable')
})
it('is not affected when changing other states', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
w.maximizable = false expect(w.isMaximizable()).to.be.true('isMaximizable')
expect(w.maximizable).to.be.false('maximizable') w.setMaximizable(false)
w.minimizable = false expect(w.isMaximizable()).to.be.false('isMaximizable')
expect(w.maximizable).to.be.false('maximizable') w.setMaximizable(true)
w.closable = false expect(w.isMaximizable()).to.be.true('isMaximizable')
expect(w.maximizable).to.be.false('maximizable') })
w.maximizable = true it('is not affected when changing other states', () => {
expect(w.maximizable).to.be.true('maximizable') const w = new BrowserWindow({ show: false })
w.closable = true w.setMaximizable(false)
expect(w.maximizable).to.be.true('maximizable') expect(w.isMaximizable()).to.be.false('isMaximizable')
w.fullScreenable = false w.setMinimizable(false)
expect(w.maximizable).to.be.true('maximizable') expect(w.isMaximizable()).to.be.false('isMaximizable')
w.setClosable(false)
expect(w.isMaximizable()).to.be.false('isMaximizable')
w.setMaximizable(true)
expect(w.isMaximizable()).to.be.true('isMaximizable')
w.setClosable(true)
expect(w.isMaximizable()).to.be.true('isMaximizable')
w.setFullScreenable(false)
expect(w.isMaximizable()).to.be.true('isMaximizable')
})
}) })
}) })
// TODO(codebytere): remove when propertyification is complete ifdescribe(process.platform === 'win32')('maximizable state', () => {
describe('maximizable state (methods)', () => { it('with properties', () => {
it('can be changed with maximizable option', () => { it('is reset to its former state', () => {
const w = new BrowserWindow({ show: false, maximizable: false }) const w = new BrowserWindow({ show: false })
expect(w.isMaximizable()).to.be.false('isMaximizable') w.maximizable = false
w.resizable = false
w.resizable = true
expect(w.maximizable).to.be.false('maximizable')
w.maximizable = true
w.resizable = false
w.resizable = true
expect(w.maximizable).to.be.true('maximizable')
})
}) })
it('can be changed with setMaximizable method', () => { it('with functions', () => {
const w = new BrowserWindow({ show: false }) it('is reset to its former state', () => {
expect(w.isMaximizable()).to.be.true('isMaximizable') const w = new BrowserWindow({ show: false })
w.setMaximizable(false) w.setMaximizable(false)
expect(w.isMaximizable()).to.be.false('isMaximizable') w.setResizable(false)
w.setMaximizable(true) w.setResizable(true)
expect(w.isMaximizable()).to.be.true('isMaximizable') expect(w.isMaximizable()).to.be.false('isMaximizable')
}) w.setMaximizable(true)
w.setResizable(false)
it('is not affected when changing other states', () => { w.setResizable(true)
const w = new BrowserWindow({ show: false }) expect(w.isMaximizable()).to.be.true('isMaximizable')
w.setMaximizable(false) })
expect(w.isMaximizable()).to.be.false('isMaximizable')
w.setMinimizable(false)
expect(w.isMaximizable()).to.be.false('isMaximizable')
w.setClosable(false)
expect(w.isMaximizable()).to.be.false('isMaximizable')
w.setMaximizable(true)
expect(w.isMaximizable()).to.be.true('isMaximizable')
w.setClosable(true)
expect(w.isMaximizable()).to.be.true('isMaximizable')
w.setFullScreenable(false)
expect(w.isMaximizable()).to.be.true('isMaximizable')
}) })
}) })
ifdescribe(process.platform === 'win32')('maximizable state (Windows only)', () => { ifdescribe(process.platform === 'darwin')('fullscreenable state', () => {
// Only implemented on windows. it('with properties', () => {
it('can be set with fullscreenable constructor option', () => {
const w = new BrowserWindow({ show: false, fullscreenable: false })
expect(w.fullScreenable).to.be.false('fullScreenable')
})
it('is reset to its former state', () => { it('can be changed', () => {
const w = new BrowserWindow({ show: false }) const w = new BrowserWindow({ show: false })
w.maximizable = false expect(w.fullScreenable).to.be.true('fullScreenable')
w.resizable = false w.fullScreenable = false
w.resizable = true expect(w.fullScreenable).to.be.false('fullScreenable')
expect(w.maximizable).to.be.false('maximizable') w.fullScreenable = true
w.maximizable = true expect(w.fullScreenable).to.be.true('fullScreenable')
w.resizable = false })
w.resizable = true
expect(w.maximizable).to.be.true('maximizable')
})
})
// TODO(codebytere): remove when propertyification is complete
ifdescribe(process.platform === 'win32')('maximizable state (Windows only) (methods)', () => {
// Only implemented on windows.
it('is reset to its former state', () => {
const w = new BrowserWindow({ show: false })
w.setMaximizable(false)
w.setResizable(false)
w.setResizable(true)
expect(w.isMaximizable()).to.be.false('isMaximizable')
w.setMaximizable(true)
w.setResizable(false)
w.setResizable(true)
expect(w.isMaximizable()).to.be.true('isMaximizable')
})
})
ifdescribe(process.platform === 'darwin')('fullscreenable state (property)', () => {
it('can be changed with fullscreenable option', () => {
const w = new BrowserWindow({ show: false, fullscreenable: false })
expect(w.fullScreenable).to.be.false('fullScreenable')
}) })
it('can be changed with fullScreenable property', () => { it('with functions', () => {
const w = new BrowserWindow({ show: false }) it('can be set with fullscreenable constructor option', () => {
expect(w.fullScreenable).to.be.true('fullScreenable') const w = new BrowserWindow({ show: false, fullscreenable: false })
w.fullScreenable = false expect(w.isFullScreenable()).to.be.false('isFullScreenable')
expect(w.fullScreenable).to.be.false('fullScreenable') })
w.fullScreenable = true
expect(w.fullScreenable).to.be.true('fullScreenable')
})
})
// TODO(codebytere): remove when propertyification is complete it('can be changed', () => {
ifdescribe(process.platform === 'darwin')('fullscreenable state (methods)', () => { const w = new BrowserWindow({ show: false })
it('can be changed with fullscreenable option', () => { expect(w.isFullScreenable()).to.be.true('isFullScreenable')
const w = new BrowserWindow({ show: false, fullscreenable: false }) w.setFullScreenable(false)
expect(w.isFullScreenable()).to.be.false('isFullScreenable') expect(w.isFullScreenable()).to.be.false('isFullScreenable')
}) w.setFullScreenable(true)
expect(w.isFullScreenable()).to.be.true('isFullScreenable')
it('can be changed with setFullScreenable method', () => { })
const w = new BrowserWindow({ show: false })
expect(w.isFullScreenable()).to.be.true('isFullScreenable')
w.setFullScreenable(false)
expect(w.isFullScreenable()).to.be.false('isFullScreenable')
w.setFullScreenable(true)
expect(w.isFullScreenable()).to.be.true('isFullScreenable')
}) })
}) })
@ -3637,36 +3676,37 @@ describe('BrowserWindow module', () => {
}) })
}) })
describe('closable state (property)', () => { describe('closable state', () => {
it('can be changed with closable option', () => { it('with properties', () => {
const w = new BrowserWindow({ show: false, closable: false }) it('can be set with closable constructor option', () => {
expect(w.closable).to.be.false('closable') const w = new BrowserWindow({ show: false, closable: false })
expect(w.closable).to.be.false('closable')
})
it('can be changed', () => {
const w = new BrowserWindow({ show: false })
expect(w.closable).to.be.true('closable')
w.closable = false
expect(w.closable).to.be.false('closable')
w.closable = true
expect(w.closable).to.be.true('closable')
})
}) })
it('can be changed with setClosable method', () => { it('with functions', () => {
const w = new BrowserWindow({ show: false }) it('can be set with closable constructor option', () => {
expect(w.closable).to.be.true('closable') const w = new BrowserWindow({ show: false, closable: false })
w.closable = false expect(w.isClosable()).to.be.false('isClosable')
expect(w.closable).to.be.false('closable') })
w.closable = true
expect(w.closable).to.be.true('closable')
})
})
// TODO(codebytere): remove when propertyification is complete it('can be changed', () => {
describe('closable state (methods)', () => { const w = new BrowserWindow({ show: false })
it('can be changed with closable option', () => { expect(w.isClosable()).to.be.true('isClosable')
const w = new BrowserWindow({ show: false, closable: false }) w.setClosable(false)
expect(w.isClosable()).to.be.false('isClosable') expect(w.isClosable()).to.be.false('isClosable')
}) w.setClosable(true)
expect(w.isClosable()).to.be.true('isClosable')
it('can be changed with setClosable method', () => { })
const w = new BrowserWindow({ show: false })
expect(w.isClosable()).to.be.true('isClosable')
w.setClosable(false)
expect(w.isClosable()).to.be.false('isClosable')
w.setClosable(true)
expect(w.isClosable()).to.be.true('isClosable')
}) })
}) })