Implement Client#hide
This commit is contained in:
parent
870e11a702
commit
3cf62cc07d
@ -1,13 +1,14 @@
|
|||||||
module Uh
|
module Uh
|
||||||
module WM
|
module WM
|
||||||
class Client
|
class Client
|
||||||
attr_reader :window
|
attr_reader :window, :unmap_count
|
||||||
attr_accessor :geo
|
attr_accessor :geo
|
||||||
|
|
||||||
def initialize window, geo = nil
|
def initialize window, geo = nil
|
||||||
@window = window
|
@window = window
|
||||||
@geo = geo
|
@geo = geo
|
||||||
@visible = false
|
@visible = false
|
||||||
|
@unmap_count = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
@ -40,6 +41,13 @@ module Uh
|
|||||||
@visible = true
|
@visible = true
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def hide
|
||||||
|
@window.unmap
|
||||||
|
@visible = false
|
||||||
|
@unmap_count += 1
|
||||||
|
self
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -16,6 +16,10 @@ module Uh
|
|||||||
expect(client).to be_hidden
|
expect(client).to be_hidden
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'has an unmap count of 0' do
|
||||||
|
expect(client.unmap_count).to eq 0
|
||||||
|
end
|
||||||
|
|
||||||
describe '#to_s' do
|
describe '#to_s' do
|
||||||
it 'includes window name' do
|
it 'includes window name' do
|
||||||
expect(client.to_s).to include 'wname'
|
expect(client.to_s).to include 'wname'
|
||||||
@ -73,6 +77,30 @@ module Uh
|
|||||||
expect(client.show).to be client
|
expect(client.show).to be client
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#hide' do
|
||||||
|
it 'unmaps the window' do
|
||||||
|
expect(window).to receive :unmap
|
||||||
|
client.hide
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'toggles the client as hidden' do
|
||||||
|
client.show
|
||||||
|
expect { client.hide }
|
||||||
|
.to change { client.hidden? }
|
||||||
|
.from(false).to true
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'increments the unmap count' do
|
||||||
|
expect { client.hide }
|
||||||
|
.to change { client.unmap_count }
|
||||||
|
.from(0).to 1
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns self' do
|
||||||
|
expect(client.hide).to be client
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user