Handle termination properly
* Tell the manager to close the display before terminating; * Log about quit request and process termination.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
module Uh
|
||||
module WM
|
||||
RSpec.describe Manager do
|
||||
let(:block) { proc { } }
|
||||
let(:events) { Dispatcher.new }
|
||||
let(:modifier) { :mod1 }
|
||||
let(:display) { Display.new }
|
||||
@@ -11,8 +12,6 @@ module Uh
|
||||
end
|
||||
|
||||
describe '#connect', :xvfb do
|
||||
let(:block) { proc { } }
|
||||
|
||||
it 'opens the display' do
|
||||
expect(manager.display).to receive(:open).and_call_original
|
||||
manager.connect
|
||||
@@ -45,6 +44,20 @@ module Uh
|
||||
end
|
||||
end
|
||||
|
||||
describe '#disconnect' do
|
||||
it 'closes the display' do
|
||||
expect(display).to receive :close
|
||||
manager.disconnect
|
||||
end
|
||||
|
||||
it 'emits :disconnected event' do
|
||||
allow(display).to receive :close
|
||||
events.on :disconnected, &block
|
||||
expect(block).to receive :call
|
||||
manager.disconnect
|
||||
end
|
||||
end
|
||||
|
||||
describe '#grab_key' do
|
||||
it 'grabs given key on the display' do
|
||||
expect(manager.display)
|
||||
|
@@ -129,6 +129,19 @@ module Uh
|
||||
runner.run_until &block
|
||||
end
|
||||
end
|
||||
|
||||
describe '#terminate' do
|
||||
it 'tells the manager to disconnect' do
|
||||
expect(runner.manager).to receive :disconnect
|
||||
runner.terminate
|
||||
end
|
||||
|
||||
it 'logs about program termination' do
|
||||
allow(runner.manager).to receive :disconnect
|
||||
expect(env).to receive(:log).with /terminat/i
|
||||
runner.terminate
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user