Module: RunLoop
- Defined in:
- lib/run_loop/cli.rb,
lib/run_loop/core.rb,
lib/run_loop/device.rb,
lib/run_loop/version.rb,
lib/run_loop/xctools.rb,
lib/run_loop/instruments.rb,
lib/run_loop/plist_buddy.rb,
lib/run_loop/sim_control.rb
Defined Under Namespace
Modules: Core
Classes: CLI, Device, Instruments, PlistBuddy, SimControl, TimeoutError, Version, XCTools
Constant Summary
collapse
- VERSION =
'1.0.8'
Class Method Summary
collapse
Class Method Details
.default_script_for_uia_strategy(uia_strategy) ⇒ Object
641
642
643
644
645
646
647
648
649
650
|
# File 'lib/run_loop/core.rb', line 641
def self.default_script_for_uia_strategy(uia_strategy)
case uia_strategy
when :preferences
Core.script_for_key(:run_loop_fast_uia)
when :host
Core.script_for_key(:run_loop_host)
else
Core.script_for_key(:run_loop_basic)
end
end
|
.run(options = {}) ⇒ Object
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
|
# File 'lib/run_loop/core.rb', line 652
def self.run(options={})
uia_strategy = options[:uia_strategy]
if options[:script]
script = validate_script(options[:script])
else
if uia_strategy
script = default_script_for_uia_strategy(uia_strategy)
else
if options[:calabash_lite]
uia_strategy = :host
script = Core.script_for_key(:run_loop_host)
else
uia_strategy = :preferences
script = default_script_for_uia_strategy(uia_strategy)
end
end
end
unless uia_strategy
desired_script = options[:script]
if desired_script.is_a?(String) uia_strategy = :host
elsif desired_script == :run_loop_host
uia_strategy = :host
elsif desired_script == :run_loop_fast_uia
uia_strategy = :preferences
else
raise "Inconsistent state: desired script #{desired_script} has not uia_strategy"
end
end
options[:script] = script
options[:uia_strategy] = uia_strategy
Core.run_with_options(options)
end
|
.send_command(run_loop, cmd, timeout = 60) ⇒ Object
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
|
# File 'lib/run_loop/core.rb', line 690
def self.send_command(run_loop, cmd, timeout=60)
if not cmd.is_a?(String)
raise "Illegal command #{cmd} (must be a string)"
end
expected_index = Core.write_request(run_loop, cmd)
result = nil
begin
Timeout::timeout(timeout, TimeoutError) do
result = Core.read_response(run_loop, expected_index)
end
rescue TimeoutError => _
raise TimeoutError, "Time out waiting for UIAutomation run-loop for command #{cmd}. Waiting for index:#{expected_index}"
end
result
end
|
.stop(run_loop, out = Dir.pwd) ⇒ Object
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
|
# File 'lib/run_loop/core.rb', line 712
def self.stop(run_loop, out=Dir.pwd)
return if run_loop.nil?
results_dir = run_loop[:results_dir]
dest = out
RunLoop::Instruments.new.kill_instruments
FileUtils.mkdir_p(dest)
if results_dir
pngs = Dir.glob(File.join(results_dir, 'Run 1', '*.png'))
else
pngs = []
end
FileUtils.cp(pngs, dest) if pngs and pngs.length > 0
end
|
.validate_script(script) ⇒ Object
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
|
# File 'lib/run_loop/core.rb', line 729
def self.validate_script(script)
if script.is_a?(String)
unless File.exist?(script)
raise "Unable to find file: #{script}"
end
elsif script.is_a?(Symbol)
script = Core.script_for_key(script)
unless script
raise "Unknown script for symbol: #{script}. Options: #{Core::SCRIPTS.keys.join(', ')}"
end
else
raise "Script must be a symbol or path: #{script}"
end
script
end
|