module Uh::WM::Testing::AcceptanceHelpers

Constants

LOG_READY
QUIT_KEYBINDING

Attributes

other_wm[R]

Public Instance Methods

icccm_window_ensure_stop() click to toggle source
# File lib/uh/wm/testing/acceptance_helpers.rb, line 20
def icccm_window_ensure_stop
  @icccm_window.stop
end
icccm_window_name() click to toggle source
# File lib/uh/wm/testing/acceptance_helpers.rb, line 24
def icccm_window_name
  'xmessage'
end
icccm_window_start() click to toggle source
# 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() click to toggle source
# File lib/uh/wm/testing/acceptance_helpers.rb, line 32
def uhwm_ensure_stop
  uhwm_request_quit
end
uhwm_request_quit() click to toggle source
# 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') click to toggle source
# File lib/uh/wm/testing/acceptance_helpers.rb, line 40
def uhwm_run_wait_ready options = '-v'
  program_run wait: false, opts: options
  uhwm_wait_ready
end
uhwm_wait_ready() click to toggle source
# File lib/uh/wm/testing/acceptance_helpers.rb, line 36
def uhwm_wait_ready
  wait_output! LOG_READY
end
with_other_wm() { || ... } click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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