fix: power observer dbus crash (#15030)

* fix: check dbus response for nullptr before using

* chore: use BindOnce for ProxyObject::CallMethod cb

* chore: comment out name of unused argument

* fix: re-enable and fix linux power monitor tests

* fix: change tyop from code comments

* refactor: don't keep unnecessary dbus pointer

* chore: remove the 'TODO: fix this' spec comment
This commit is contained in:
Charles Kerr 2018-10-09 00:32:19 -05:00 committed by GitHub
parent 7df51eef3c
commit 05f4860889
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 39 deletions

View file

@ -16,8 +16,7 @@ chai.use(dirtyChai)
const skip = process.platform !== 'linux' || !process.env.DBUS_SYSTEM_BUS_ADDRESS
// TODO(alexeykuzmin): [Ch66] Crashes on Linux ia32. Fix it and enable back.
xdescribe('powerMonitor', () => {
describe('powerMonitor', () => {
let logindMock, dbusMockPowerMonitor, getCalls, emitSignal, reset
if (!skip) {
@ -31,7 +30,9 @@ xdescribe('powerMonitor', () => {
reset = Promise.promisify(logindMock.Reset, { context: logindMock })
})
after(reset)
after(async () => {
await reset()
})
}
(skip ? describe.skip : describe)('when powerMonitor module is loaded with dbus mock', () => {
@ -129,8 +130,12 @@ xdescribe('powerMonitor', () => {
describe('powerMonitor.querySystemIdleState', () => {
it('notify current system idle state', done => {
// this function is not mocked out, so we can test the result's
// form and type but not its value.
powerMonitor.querySystemIdleState(1, idleState => {
expect(idleState).to.be.true()
expect(idleState).to.be.a('string')
const validIdleStates = [ 'active', 'idle', 'locked', 'unknown' ]
expect(validIdleStates).to.include(idleState)
done()
})
})