lib/calabash-cucumber/launcher.rb in testautoi-0.9.142 vs lib/calabash-cucumber/launcher.rb in testautoi-0.9.143

- old
+ new

@@ -1,26 +1,31 @@ require 'calabash-cucumber/launch/simulator_helper' require 'sim_launcher' +require 'calabash-cucumber/device' require 'run_loop' class Calabash::Cucumber::Launcher attr_accessor :run_loop attr_accessor :device_target - attr_accessor :ios_version + attr_accessor :device def initialize(device_target=:simulator) self.device_target = device_target end class CalabashLauncherTimeoutErr < Timeout::Error end def calabash_no_stop? - ENV['NO_LAUNCH']=="1" or ENV['NO_STOP']=="1" + calabash_no_launch? or ENV['NO_STOP']=="1" end + def calabash_no_launch? + ENV['NO_LAUNCH']=='1' + end + def device_target? ENV['DEVICE_TARGET'] == 'device' end def simulator_target? @@ -30,19 +35,27 @@ def active? (simulator_target? || device_target?) && (not run_loop.nil?) end def ios_major_version - v = ios_version - (v && v.split('.')[0]) + return nil if device.nil? or device.ios_version.nil? + device.ios_major_version end + def ios_version + return nil if device.nil? + device.ios_version + end - def reset_app_jail(sdk, app_path) + + def reset_app_jail(sdk=nil, path=nil) return if device_target? - app = File.basename(app_path) + sdk = sdk || ENV['SDK_VERSION'] || SimLauncher::SdkDetector.new().latest_sdk_version + path = path || Calabash::Cucumber::SimulatorHelper.app_bundle_or_raise(app_path) + + app = File.basename(path) bundle = `find "#{ENV['HOME']}/Library/Application Support/iPhone Simulator/#{sdk}/Applications/" -type d -depth 2 -name "#{app}" | head -n 1` return if bundle.empty? # Assuming we're already clean sandbox = File.dirname(bundle) ['Library', 'Documents', 'tmp'].each do |dir| @@ -128,12 +141,10 @@ end if status=='200' version_body = JSON.parse(res.body) - if version_body['iOS_version'] - self.ios_version = version_body['iOS_version'] - end + self.device = Calabash::Cucumber::Device.new(url, version_body) end status end