Module: Uh::WM::Testing::AcceptanceHelpers
- Defined in:
- lib/uh/wm/testing/acceptance_helpers.rb
Constant Summary collapse
- QUIT_KEYBINDING =
'alt+shift+q'.freeze
- LOG_READY =
'Working events'.freeze
Instance Attribute Summary collapse
-
#other_wm ⇒ Object
readonly
Returns the value of attribute other_wm.
Instance Method Summary collapse
- #icccm_window_ensure_stop ⇒ Object
- #icccm_window_name ⇒ Object
- #icccm_window_start ⇒ Object
- #uhwm_ensure_stop ⇒ Object
- #uhwm_request_quit ⇒ Object
- #uhwm_run_wait_ready(options = '-v') ⇒ Object
- #uhwm_wait_ready ⇒ Object
- #with_other_wm ⇒ Object
- #x_client(ident = nil) ⇒ Object
- #x_clients_ensure_stop ⇒ Object
- #x_focused_window_id ⇒ Object
- #x_key(*k, delay: 12) ⇒ Object
- #x_window_map_state(window_selector) ⇒ Object
Instance Attribute Details
#other_wm ⇒ Object (readonly)
Returns the value of attribute other_wm.
13 14 15 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 13 def other_wm @other_wm end |
Instance Method Details
#icccm_window_ensure_stop ⇒ Object
20 21 22 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 20 def icccm_window_ensure_stop @icccm_window.stop end |
#icccm_window_name ⇒ Object
24 25 26 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 24 def icccm_window_name 'xmessage' end |
#icccm_window_start ⇒ Object
15 16 17 18 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 15 def icccm_window_start @icccm_window = ChildProcess.build(*%w[xmessage window]) @icccm_window.start end |
#uhwm_ensure_stop ⇒ Object
32 33 34 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 32 def uhwm_ensure_stop uhwm_request_quit end |
#uhwm_request_quit ⇒ Object
28 29 30 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 28 def uhwm_request_quit x_key QUIT_KEYBINDING end |
#uhwm_run_wait_ready(options = '-v') ⇒ Object
40 41 42 43 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 40 def uhwm_run_wait_ready = '-v' program_run wait: false, opts: uhwm_wait_ready end |
#uhwm_wait_ready ⇒ Object
36 37 38 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 36 def uhwm_wait_ready wait_output! LOG_READY end |
#with_other_wm ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 45 def with_other_wm @other_wm = ChildProcess.build('./bin/uhwm') @other_wm.start yield @other_wm.stop @other_wm = nil end |
#x_client(ident = nil) ⇒ Object
53 54 55 56 57 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 53 def x_client ident = nil ident ||= :default @x_clients ||= {} @x_clients[ident] ||= XClient.new(ident) end |
#x_clients_ensure_stop ⇒ Object
59 60 61 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 59 def x_clients_ensure_stop @x_clients and @x_clients.any? and @x_clients.values.each &:terminate end |
#x_focused_window_id ⇒ Object
63 64 65 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 63 def x_focused_window_id Integer(`xdpyinfo`[/^focus:\s+window\s+(0x\h+)/, 1]) end |
#x_key(*k, delay: 12) ⇒ Object
67 68 69 70 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 67 def x_key *k, delay: 12 k = k.join " key --delay #{delay} " fail "cannot simulate X key `#{k}'" unless system "xdotool key #{k}" end |
#x_window_map_state(window_selector) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 72 def x_window_map_state window_selector select_args = case window_selector when Integer then "-id #{window_selector}" when String then "-name #{window_selector}" else fail ArgumentError, "not an Integer nor a String: `#{window_selector.inspect}'" end `xwininfo #{select_args} 2> /dev/null`[/Map State: (\w+)/, 1] end |