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
- #with_other_wm(uhwm_command) ⇒ 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
21 22 23 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 21 def icccm_window_ensure_stop @icccm_window.stop end |
#icccm_window_name ⇒ Object
25 26 27 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 25 def icccm_window_name 'xmessage' end |
#icccm_window_start ⇒ Object
15 16 17 18 19 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 15 def icccm_window_start @icccm_window = Baf::Testing::Process.new %w[xmessage window], env_allow: %w[DISPLAY] @icccm_window.start end |
#uhwm_ensure_stop ⇒ Object
33 34 35 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 33 def uhwm_ensure_stop uhwm_request_quit end |
#uhwm_request_quit ⇒ Object
29 30 31 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 29 def uhwm_request_quit x_key QUIT_KEYBINDING end |
#uhwm_run_wait_ready(options = '-v') ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 37 def uhwm_run_wait_ready = '-v' cmd = $_baf[:program] + .split(' ') env = Baf::Testing::ENV_WHITELIST + $_baf[:env_allow] Baf::Testing::Process.new(cmd, env_allow: env).tap do |uhwm| uhwm.start Baf::Testing.wait_output LOG_READY, stream: -> { uhwm.output } end end |
#with_other_wm(uhwm_command) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 46 def with_other_wm uhwm_command env = Baf::Testing::ENV_WHITELIST + $_baf[:env_allow] @other_wm = Baf::Testing::Process.new uhwm_command, env_allow: env @other_wm.start yield uhwm_request_quit @other_wm = nil end |
#x_client(ident = nil) ⇒ Object
55 56 57 58 59 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 55 def x_client ident = nil ident ||= :default @x_clients ||= {} @x_clients[ident] ||= XClient.new(ident) end |
#x_clients_ensure_stop ⇒ Object
61 62 63 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 61 def x_clients_ensure_stop @x_clients and @x_clients.any? and @x_clients.values.each &:terminate end |
#x_focused_window_id ⇒ Object
65 66 67 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 65 def x_focused_window_id Integer(`xdpyinfo`[/^focus:\s+window\s+(0x\h+)/, 1]) end |
#x_key(*k, delay: 12) ⇒ Object
69 70 71 72 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 69 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
74 75 76 77 78 79 80 81 82 |
# File 'lib/uh/wm/testing/acceptance_helpers.rb', line 74 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 |