lib/calabash-android/operations.rb in calabash-android-0.4.4 vs lib/calabash-android/operations.rb in calabash-android-0.4.5.pre1
- old
+ new
@@ -213,11 +213,15 @@
log "Uninstalling: #{package_name}"
log `#{adb_command} uninstall #{package_name}`
end
def app_running?
- `#{adb_command} shell ps`.include?(ENV["PROCESS_NAME"] || package_name(@app_path))
+ begin
+ http("/ping") == "pong"
+ rescue
+ false
+ end
end
def keyguard_enabled?
dumpsys = `#{adb_command} shell dumpsys window windows`
#If a line containing mCurrentFocus and Keyguard exists the keyguard is enabled
@@ -253,15 +257,12 @@
http = Net::HTTP.new "127.0.0.1", @server_port
http.open_timeout = options[:open_timeout] if options[:open_timeout]
http.read_timeout = options[:read_timeout] if options[:read_timeout]
resp = http.post(path, "#{data.to_json}", {"Content-Type" => "application/json;charset=utf-8"})
resp.body
- rescue Exception => e
- if app_running?
+ rescue EOFError => e
+ log "It looks like your app is no longer running. \nIt could be because of a crash or because your test script shut it down."
raise e
- else
- raise "App no longer running"
- end
end
end
def screenshot(options={:prefix => nil, :name => nil})
prefix = options[:prefix] || ENV['SCREENSHOT_PATH'] || ""