Skip to content

Commit

Permalink
support for 4-inch simulator pref
Browse files Browse the repository at this point in the history
  • Loading branch information
krukow committed Nov 17, 2012
1 parent 38a9ba1 commit 0a53e0a
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 13 deletions.
35 changes: 23 additions & 12 deletions calabash-cucumber/bin/calabash-ios-sim.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def calabash_sim_reset
end

def calabash_sim_accessibility
dirs = Dir.glob(File.join(File.expand_path("~/Library"),"Application Support","iPhone Simulator","*.*","Library","Preferences"))
dirs = Dir.glob(File.join(File.expand_path("~/Library"), "Application Support", "iPhone Simulator", "*.*", "Library", "Preferences"))
dirs.each do |sim_pref_dir|
fp = File.expand_path("#{@script_dir}/data/")
FileUtils.cp("#{fp}/com.apple.Accessibility.plist", sim_pref_dir)
Expand All @@ -50,7 +50,7 @@ def calabash_sim_location(args)
bundle_id = args.shift


dirs = Dir.glob(File.join(File.expand_path("~/Library"),"Application Support","iPhone Simulator","*.*","Library","Caches","locationd"))
dirs = Dir.glob(File.join(File.expand_path("~/Library"), "Application Support", "iPhone Simulator", "*.*", "Library", "Caches", "locationd"))
dirs.each do |sim_dir|
existing_path = "#{sim_dir}/clients.plist"
if File.exist?(existing_path)
Expand Down Expand Up @@ -99,23 +99,23 @@ def calabash_sim_locale(args)
end

langs = hash['AppleLanguages']
lang_index = langs.find_index {|l| l == lang}
lang_index = langs.find_index { |l| l == lang }

if lang_index.nil?
puts "Unable to find #{lang}..."
puts "Options:\n#{langs.join("\n")}"
exit 0
end

langs[0],langs[lang_index] = langs[lang_index],langs[0]
langs[0], langs[lang_index] = langs[lang_index], langs[0]


if reg
hash['AppleLocale'] = reg
end
res_plist = CFPropertyList::List.new
res_plist.value = CFPropertyList.guess(hash)
dirs = Dir.glob(File.join(File.expand_path("~/Library"),"Application Support","iPhone Simulator","*.*","Library","Preferences"))
dirs = Dir.glob(File.join(File.expand_path("~/Library"), "Application Support", "iPhone Simulator", "*.*", "Library", "Preferences"))
dirs.each do |sim_pref_dir|
res_plist.save("#{sim_pref_dir}/.GlobalPreferences.plist", CFPropertyList::List::FORMAT_BINARY)
end
Expand All @@ -126,18 +126,29 @@ def calabash_sim_locale(args)

def calabash_sim_device(args)
quit_sim
options = ["iPad", "iPhone", "iPhone_Retina"]
if args.length != 1 or not options.find {|x| x == args[0]}
options = ["iPad", "iPhone", "iPhone_Retina", "iPhone_Retina_4inch"]
if args.length != 1 or not options.find { |x| x == args[0] }
print_usage
puts "Unrecognized args: #{args}"
puts "should be one of #{options}"
exit(0)
end
path =File.join(File.expand_path("~/Library"),"Preferences","com.apple.iphonesimulator.plist")
path =File.join(File.expand_path("~/Library"), "Preferences", "com.apple.iphonesimulator.plist")
plist = CFPropertyList::List.new(:file => path)
hash = CFPropertyList.native_types(plist.value)
hash['SimulateDevice'] = args[0].gsub("iPhone_Retina","iPhone (Retina)")
plist.value = CFPropertyList.guess(hash)
plist.save(path, CFPropertyList::List::FORMAT_BINARY)
end

device = case args[0]
when "iPhone_Retina"
"iPhone (Retina)"
when "iPhone_Retina_4inch"
"iPhone (Retina 4-inch)"
else
args[0]
end
if device
hash['SimulateDevice'] = device
plist.value = CFPropertyList.guess(hash)
plist.save(path, CFPropertyList::List::FORMAT_BINARY)
end

end
8 changes: 8 additions & 0 deletions calabash-cucumber/lib/calabash-cucumber/ibase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ def page(clz,*args)
clz.new(@world,*args)
end

def step(s)

end

def steps(ss)

end

def await(opts={})
wait_for_elements_exist([trait], opts)
self
Expand Down
2 changes: 1 addition & 1 deletion calabash-cucumber/lib/calabash-cucumber/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Calabash
module Cucumber
VERSION = "0.9.119"
VERSION = "0.9.120"
FRAMEWORK_VERSION = "0.9.117"
end
end
19 changes: 19 additions & 0 deletions calabash-jvm/src/calabash_jvm/wait.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,29 @@
(ns calabash-jvm.wait
(:use [slingshot.slingshot :only [try+ throw+]])

(:require [calabash-jvm
[http :as http]
[core :as core]
[utils :as utils]]))


(defn with-timeout*
[opts action]
(let [opts (merge {:timeout 10 :message "Timeout"} opts)
f (future-call action)
timeout (* 1000 (:timeout opts))
res (deref f timeout :calabash-jvm/timeout)]
(try
(if (= :calabash-jvm/timeout res)
(throw+ (merge {:type :calabash-jvm/timeout} opts))
res)
(finally
(future-cancel f)))))

(defmacro with-timeout [opts & body]
`(let [f# (fn [] ~@body)]
(with-timeout* ~opts f#)))

(defn do-until
[pred action]
(loop []
Expand Down

0 comments on commit 0a53e0a

Please sign in to comment.