Class: AtspiAppDriver
- Inherits:
-
Object
- Object
- AtspiAppDriver
- Defined in:
- lib/atspi_app_driver.rb,
lib/atspi_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.9.0"
Instance Attribute Summary collapse
-
#application ⇒ Object
readonly
Returns the value of attribute application.
-
#frame ⇒ Object
readonly
Returns the value of attribute frame.
Instance Method Summary collapse
- #boot(test_timeout: 30, exit_timeout: 10, arguments: []) ⇒ Object
- #cleanup ⇒ Object
-
#initialize(app_name, app_file: nil, verbose: false) ⇒ AtspiAppDriver
constructor
A new instance of AtspiAppDriver.
- #spawn_process(arguments) ⇒ Object
Constructor Details
#initialize(app_name, app_file: nil, verbose: false) ⇒ AtspiAppDriver
Returns a new instance of AtspiAppDriver.
40 41 42 43 44 45 46 47 48 |
# File 'lib/atspi_app_driver.rb', line 40 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
#application ⇒ Object (readonly)
Returns the value of attribute application.
50 51 52 |
# File 'lib/atspi_app_driver.rb', line 50 def application @application end |
#frame ⇒ Object (readonly)
Returns the value of attribute frame.
50 51 52 |
# File 'lib/atspi_app_driver.rb', line 50 def frame @frame end |
Instance Method Details
#boot(test_timeout: 30, exit_timeout: 10, arguments: []) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/atspi_app_driver.rb', line 52 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 |
#cleanup ⇒ Object
74 75 76 77 78 79 |
# File 'lib/atspi_app_driver.rb', line 74 def cleanup status = exit_status @pid = nil @thread&.join status end |
#spawn_process(arguments) ⇒ Object
68 69 70 71 72 |
# File 'lib/atspi_app_driver.rb', line 68 def spawn_process(arguments) command = "ruby -I#{@lib_dir} #{@app_file} #{arguments.join(" ")}" log "About to spawn: `#{command}`" @pid = Process.spawn command end |