Class: UIAuto::Instruments
- Inherits:
-
Object
- Object
- UIAuto::Instruments
- Defined in:
- lib/uiauto/instruments.rb
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#device ⇒ Object
Returns the value of attribute device.
-
#results ⇒ Object
Returns the value of attribute results.
-
#script ⇒ Object
Returns the value of attribute script.
-
#simulator ⇒ Object
Returns the value of attribute simulator.
-
#trace ⇒ Object
Returns the value of attribute trace.
Instance Method Summary collapse
- #command ⇒ Object
- #execute ⇒ Object
-
#initialize(script, reporter, opts = {}) ⇒ Instruments
constructor
A new instance of Instruments.
Constructor Details
#initialize(script, reporter, opts = {}) ⇒ Instruments
Returns a new instance of Instruments.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/uiauto/instruments.rb', line 11 def initialize(script, reporter, opts = {}) @reporter = reporter @script = script @trace = opts[:trace] @results = opts[:results] @device = opts[:device] @simulator = opts[:simulator] @app = opts[:app] || default_application FileUtils.mkdir_p(@results) unless File.exists?(@results) end |
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
9 10 11 |
# File 'lib/uiauto/instruments.rb', line 9 def app @app end |
#device ⇒ Object
Returns the value of attribute device.
9 10 11 |
# File 'lib/uiauto/instruments.rb', line 9 def device @device end |
#results ⇒ Object
Returns the value of attribute results.
9 10 11 |
# File 'lib/uiauto/instruments.rb', line 9 def results @results end |
#script ⇒ Object
Returns the value of attribute script.
9 10 11 |
# File 'lib/uiauto/instruments.rb', line 9 def script @script end |
#simulator ⇒ Object
Returns the value of attribute simulator.
9 10 11 |
# File 'lib/uiauto/instruments.rb', line 9 def simulator @simulator end |
#trace ⇒ Object
Returns the value of attribute trace.
9 10 11 |
# File 'lib/uiauto/instruments.rb', line 9 def trace @trace end |
Instance Method Details
#command ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/uiauto/instruments.rb', line 23 def command command = ["xcrun instruments"] command << "-w #{device_id}" if device_id command << "-D #{@trace}" command << "-t #{automation_template_location}" command << @app command << "-e UIASCRIPT #{@script}" command << "-e UIARESULTSPATH #{@results}" command.join(" ") end |
#execute ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/uiauto/instruments.rb', line 35 def execute launch_simulator select_device_family instruments = ChildProcess.build(*command.split(" ")) master, slave = if PTY.respond_to?(:open) PTY.open else [File.new("/dev/ptyuf", "w"), File.open("/dev/ttyuf", "r")] end instruments.io.stdout = master instruments.io.stderr = master instruments.duplex = true instruments.start master.close begin loop do buffer = slave.readpartial(8192) @reporter.parse_instruments_output(buffer) end rescue EOFError @reporter.script_finish(@script) ensure slave.close end end |