Use uh to fake windows in cucumber test suite
This commit is contained in:
parent
0ef0e47036
commit
1903ba166b
@ -21,7 +21,7 @@ end
|
|||||||
|
|
||||||
After do
|
After do
|
||||||
uhwm_ensure_stop
|
uhwm_ensure_stop
|
||||||
x_windows_ensure_stop
|
x_clients_ensure_stop
|
||||||
end
|
end
|
||||||
|
|
||||||
Around '@other_wm_running' do |_, block|
|
Around '@other_wm_running' do |_, block|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require 'uh'
|
||||||
|
|
||||||
module Uh
|
module Uh
|
||||||
module WM
|
module WM
|
||||||
module Testing
|
module Testing
|
||||||
@ -56,6 +58,10 @@ module Uh
|
|||||||
@other_wm
|
@other_wm
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def x_client
|
||||||
|
@x_client ||= XClient.new
|
||||||
|
end
|
||||||
|
|
||||||
def x_key key
|
def x_key key
|
||||||
fail "cannot simulate X key `#{key}'" unless system "xdotool key #{key}"
|
fail "cannot simulate X key `#{key}'" unless system "xdotool key #{key}"
|
||||||
end
|
end
|
||||||
@ -70,16 +76,51 @@ module Uh
|
|||||||
end
|
end
|
||||||
|
|
||||||
def x_window_name
|
def x_window_name
|
||||||
'Event Tester'
|
@x_client.window_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def x_window_map
|
def x_window_map
|
||||||
@x_window = ChildProcess.build(*%w[xev -event owner_grab_button])
|
x_client.map.sync
|
||||||
@x_window.start
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def x_windows_ensure_stop
|
def x_clients_ensure_stop
|
||||||
@x_window and @x_window.stop
|
@x_client and @x_client.terminate
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
class XClient
|
||||||
|
attr_reader :name
|
||||||
|
|
||||||
|
def initialize
|
||||||
|
@name = "#{self.class.name.split('::').last}/#{object_id}"
|
||||||
|
@geo = Geo.new(0, 0, 640, 480)
|
||||||
|
@display = Display.new.tap { |o| o.open }
|
||||||
|
end
|
||||||
|
|
||||||
|
def terminate
|
||||||
|
@display.close
|
||||||
|
end
|
||||||
|
|
||||||
|
def sync
|
||||||
|
@display.sync false
|
||||||
|
end
|
||||||
|
|
||||||
|
def window
|
||||||
|
@window ||= @display.create_window(@geo).tap do |o|
|
||||||
|
o.name = @name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def window_name
|
||||||
|
@name
|
||||||
|
end
|
||||||
|
|
||||||
|
def map
|
||||||
|
window.map
|
||||||
|
self
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user