Class: GnomeAppDriver

Inherits:
Object
  • Object
show all
Defined in:
lib/gnome_app_driver.rb,
lib/gnome_app_driver/version.rb

Overview

Test driver for the Atspi-enabled applications. Takes care of boot and shutdown, and provides a handle on the GUI’s main UI frame.

Constant Summary collapse

VERSION =
"0.3.3"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_name, app_file: nil, verbose: false) ⇒ GnomeAppDriver

Returns a new instance of GnomeAppDriver.



47
48
49
50
51
52
53
54
55
# File 'lib/gnome_app_driver.rb', line 47

def initialize(app_name, app_file: nil, verbose: false)
  @app_file = app_file || "bin/#{app_name}"
  @lib_dir = "lib"
  @app_name = app_name
  @pid = nil
  @verbose = verbose
  @frame = nil
  @thread = nil
end

Instance Attribute Details

#applicationObject (readonly)

Returns the value of attribute application.



57
58
59
# File 'lib/gnome_app_driver.rb', line 57

def application
  @application
end

#frameObject (readonly)

Returns the value of attribute frame.



57
58
59
# File 'lib/gnome_app_driver.rb', line 57

def frame
  @frame
end

Instance Method Details

#boot(test_timeout: 30, exit_timeout: 10, arguments: []) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/gnome_app_driver.rb', line 59

def boot(test_timeout: 30, exit_timeout: 10, arguments: [])
  raise "Already booted" if @pid

  spawn_process(arguments)

  @cleanup = false

  @frame = find_and_focus_frame

  @thread = Thread.new do
    wait_for("test to be done", test_timeout) { @cleanup }
    wait_for("pid to go away", exit_timeout) { !@pid }
    kill_process if @pid
  end
end

#cleanupObject



81
82
83
84
85
86
# File 'lib/gnome_app_driver.rb', line 81

def cleanup
  status = exit_status
  @pid = nil
  @thread&.join
  status
end

#spawn_process(arguments) ⇒ Object



75
76
77
78
79
# File 'lib/gnome_app_driver.rb', line 75

def spawn_process(arguments)
  command = "ruby -I#{@lib_dir} #{@app_file} #{arguments.join(" ")}"
  log "About to spawn: `#{command}`"
  @pid = Process.spawn command
end