Supports multiple clients in UAT helpers

This commit is contained in:
Thibault Jouan 2015-04-20 09:17:02 +00:00
parent f2c97499ce
commit 9a4f2727d2

View File

@ -56,8 +56,9 @@ module Uh
@other_wm @other_wm
end end
def x_client def x_client ident: :default
@x_client ||= XClient.new @x_clients ||= {}
@x_clients[ident] ||= XClient.new(ident)
end end
def x_focused_window_id def x_focused_window_id
@ -81,25 +82,25 @@ module Uh
end.any? end.any?
end end
def x_window_id def x_window_id **options
@x_client.window_id x_client(options).window_id
end end
def x_window_name def x_window_name
@x_client.window_name x_client.window_name
end end
def x_window_map times: 1 def x_window_map times: 1, **options
times.times { x_client.map } times.times { x_client(options).map }
x_client.sync x_client(options).sync
end end
def x_window_map_state def x_window_map_state **options
`xwininfo -id #{x_window_id}`[/Map State: (\w+)/, 1] `xwininfo -id #{x_window_id options}`[/Map State: (\w+)/, 1]
end end
def x_clients_ensure_stop def x_clients_ensure_stop
@x_client and @x_client.terminate @x_clients and @x_clients.any? and @x_clients.values.each &:terminate
end end
@ -132,8 +133,8 @@ module Uh
class XClient class XClient
attr_reader :name attr_reader :name
def initialize def initialize name = object_id
@name = "#{self.class.name.split('::').last}/#{object_id}" @name = "#{self.class.name.split('::').last}/#{name}"
@geo = Geo.new(0, 0, 640, 480) @geo = Geo.new(0, 0, 640, 480)
@display = Display.new.tap { |o| o.open } @display = Display.new.tap { |o| o.open }
end end