diff --git a/lib/config.rb b/lib/config.rb index bd3d946..7171c04 100644 --- a/lib/config.rb +++ b/lib/config.rb @@ -29,7 +29,8 @@ def self.device(device_name) { :name => device_name, :udid => device['UDID'], - :screen => device['screen'] + :screen => device['screen'], + :simfamily => device['simfamily'] } end diff --git a/lib/feature.rb b/lib/feature.rb index 39e2712..a688da0 100644 --- a/lib/feature.rb +++ b/lib/feature.rb @@ -61,7 +61,10 @@ def collect `rm -rf #{run_data_path}/*` compile_js - device_params = (@device[:name] == "iOS Simulator") ? "" : "-w #{@device[:udid]}" + device_params = "" + if(@device[:name] != "iOS Simulator") + device_params = "-w #{@device[:udid]}" + end begin out = `instruments #{device_params} -t #{@template} #{Zucchini::Config.app} -e UIASCRIPT #{run_data_path}/feature.js -e UIARESULTSPATH #{run_data_path} 2>&1` diff --git a/lib/runner.rb b/lib/runner.rb index 1256eeb..4ad6ef2 100644 --- a/lib/runner.rb +++ b/lib/runner.rb @@ -24,6 +24,41 @@ def execute def run compare_threads = {} + device_size = "" + if(@device[:name] == "iOS Simulator" && @device[:simfamily] != nil) + #Kill the simulator if it's already running + out = `array=$(ps -ax | grep -i "Simulator" | awk ' { print $1 } '); for PID in $array; do kill $PID; done;` + puts out + + # Figure out which simulator to use... + if(@device[:simfamily] == "iPad" || @device[:simfamily] == "ipad" ) + uidevicefamily = 2 + device_size = "iPad" + else + uidevicefamily = 1 + device_size = "iPhone" + end + # And at what resolution + if @device[:screen].include?("retina") then + if uidevicefamily == 2 then + device_size = "iPad (Retina)" + else + device_size = "iPhone (Retina)" + end + end + + # Set up the simulator's device size... + `defaults write com.apple.iphonesimulator "SimulateDevice" '"#{device_size}"'` + + # Plist tool and file to edit + plistbuddy = "/usr/libexec/PlistBuddy" + plistfile = "#{Zucchini::Config.app}/Info.plist" + # Set the plist items to the correct values + `#{plistbuddy} -c "Delete :UIDeviceFamily" #{plistfile}` + `#{plistbuddy} -c "Add :UIDeviceFamily array" #{plistfile}` + `#{plistbuddy} -c "Add :UIDeviceFamily:0 integer #{uidevicefamily}" #{plistfile}` + end + features.each do |f| f.device = @device f.template = @template