lib/calabash-android/operations.rb in calabash-android-0.2.9 vs lib/calabash-android/operations.rb in calabash-android-0.2.10
- old
+ new
@@ -4,10 +4,11 @@
require 'rubygems'
require 'json'
require 'socket'
require 'timeout'
require 'calabash-android/helpers'
+require 'retriable'
module Calabash module Android
module Operations
@@ -27,10 +28,14 @@
else
Then(txt)
end
end
+ def shutdown_test_server
+ Device.default_device.shutdown_test_server
+ end
+
def performAction(action, *arguments)
Device.default_device.perform_action(action, *arguments)
end
def install_app(app_path)
@@ -74,13 +79,10 @@
def ni
raise "Not yet implemented."
end
- def is_windows?
- ENV["OS"] == "Windows_NT"
- end
###
### app life cycle
def connect_to_test_server
puts "Explicit calls to connect_to_test_server should be removed."
@@ -142,10 +144,14 @@
def uninstall_app(package_name)
log "Uninstalling: #{package_name}"
log `#{adb_command} uninstall #{package_name}`
end
+ def shutdown_test_server
+ http("/kill")
+ end
+
def perform_action(action, *arguments)
log "Action: #{action} - Params: #{arguments.join(', ')}"
params = {"command" => action, "arguments" => arguments}
@@ -220,14 +226,10 @@
else
""
end
end
- def is_windows?
- ENV["OS"] == "Windows_NT"
- end
-
def start_test_server_in_background
test_server_package = package_name(@test_server_path)
cmd = "#{adb_command} shell am instrument -w -e class sh.calaba.instrumentationbackend.InstrumentationBackend #{test_server_package}/sh.calaba.instrumentationbackend.CalabashInstrumentationTestRunner"
log "Starting test server using:"
log cmd
@@ -236,13 +238,22 @@
else
`#{cmd} 1>&2 &`
end
begin
- Timeout::timeout(15) do
- puts http("/ping")
+ retriable :tries => 10, :interval => 3 do
+ log "Checking if instrumentation backend is ready"
+ ready = http("/ready")
+
+ if ready != "true"
+ log "Instrumentation backend not yet ready"
+ raise "Not ready"
+ else
+ log "Instrumentation backend is ready!"
+ end
end
- rescue Timeout::Error
+
+ rescue
msg = "Unable to make connection to Calabash Test Server at http://127.0.0.1:#{@server_port}/\n"
msg << "Please check the logcat output for more info about what happened\n"
raise msg
end
end