Implement Client#kill and Client#kill!
This commit is contained in:
parent
4050d52af7
commit
f26e16fe6e
@ -66,6 +66,20 @@ module Uh
|
||||
@window.focus
|
||||
self
|
||||
end
|
||||
|
||||
def kill
|
||||
if @window.icccm_wm_protocols.include? :WM_DELETE_WINDOW
|
||||
@window.icccm_wm_delete
|
||||
else
|
||||
@window.kill
|
||||
end
|
||||
self
|
||||
end
|
||||
|
||||
def kill!
|
||||
window.kill
|
||||
self
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -17,11 +17,12 @@ module Factories
|
||||
modifier_mask: modifier_mask
|
||||
end
|
||||
|
||||
def mock_window override_redirect: false
|
||||
def mock_window override_redirect: false, icccm_wm_protocols: []
|
||||
instance_spy Uh::Window, 'window',
|
||||
to_s: 'wid',
|
||||
name: 'wname',
|
||||
wclass: 'wclass',
|
||||
override_redirect?: override_redirect
|
||||
override_redirect?: override_redirect,
|
||||
icccm_wm_protocols: icccm_wm_protocols
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,8 @@
|
||||
module Uh
|
||||
module WM
|
||||
RSpec.describe Client do
|
||||
let(:window) { mock_window }
|
||||
let(:protocols) { [] }
|
||||
let(:window) { mock_window icccm_wm_protocols: protocols }
|
||||
let(:geo) { build_geo }
|
||||
subject(:client) { described_class.new window, geo }
|
||||
|
||||
@ -143,6 +144,37 @@ module Uh
|
||||
expect(client.focus).to be client
|
||||
end
|
||||
end
|
||||
|
||||
describe '#kill' do
|
||||
it 'kills the window' do
|
||||
expect(window).to receive :kill
|
||||
client.kill
|
||||
end
|
||||
|
||||
it 'returns self' do
|
||||
expect(client.kill).to be client
|
||||
end
|
||||
|
||||
context 'when window supports icccm wm delete' do
|
||||
let(:protocols) { [:WM_DELETE_WINDOW] }
|
||||
|
||||
it 'icccm deletes the window' do
|
||||
expect(window).to receive :icccm_wm_delete
|
||||
client.kill
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#kill!' do
|
||||
it 'kills the window' do
|
||||
expect(window).to receive :kill
|
||||
client.kill!
|
||||
end
|
||||
|
||||
it 'returns self' do
|
||||
expect(client.kill!).to be client
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user