From c109a5487655e83b2575641d19f00cdb23a6f45a Mon Sep 17 00:00:00 2001 From: Justin Mutter Date: Wed, 18 Apr 2012 23:13:27 -0400 Subject: [PATCH 1/2] Adds the ability to choose between iPhone or iPad (low and retina) simulators when working with a universal app --- lib/config.rb | 4 +++- lib/feature.rb | 5 ++++- lib/runner.rb | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/config.rb b/lib/config.rb index bd3d946..f735d8c 100644 --- a/lib/config.rb +++ b/lib/config.rb @@ -29,7 +29,9 @@ def self.device(device_name) { :name => device_name, :udid => device['UDID'], - :screen => device['screen'] + :screen => device['screen'], + :simfamily => device['simfamily'], + :simOS => device['simOS'] } 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 From 8d5c6da726ca816879b8b63d0f9df66053ed2530 Mon Sep 17 00:00:00 2001 From: Justin Mutter Date: Wed, 18 Apr 2012 23:41:12 -0400 Subject: [PATCH 2/2] Removes simOS key from device configs - feature not ready yet. --- lib/config.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/config.rb b/lib/config.rb index f735d8c..7171c04 100644 --- a/lib/config.rb +++ b/lib/config.rb @@ -30,8 +30,7 @@ def self.device(device_name) :name => device_name, :udid => device['UDID'], :screen => device['screen'], - :simfamily => device['simfamily'], - :simOS => device['simOS'] + :simfamily => device['simfamily'] } end