lib/calabash-android/operations.rb in calabash-android-0.7.4.pre1 vs lib/calabash-android/operations.rb in calabash-android-0.8.0.pre1

- old
+ new

@@ -137,12 +137,12 @@ def push(local, remote) default_device.push(local, remote) end - def start_test_server_in_background(options={}) - default_device.start_test_server_in_background(options) + def start_test_server_in_background(options={}, &block) + default_device.start_test_server_in_background(options, &block) end def shutdown_test_server default_device.shutdown_test_server end @@ -355,10 +355,11 @@ log "result: #{result}" succeeded = result.include?("Success") unless succeeded ::Cucumber.wants_to_quit = true + pn = package_name(app_path) raise "#{pn} did not get updated. Aborting!" end end def uninstall_app(package_name) @@ -635,20 +636,20 @@ def push(local, remote) cmd = "#{adb_command} push #{local} #{remote}" raise "Could not push #{local} to #{remote}" unless system(cmd) end - def start_test_server_in_background(options={}) + def start_test_server_in_background(options={}, &block) raise "Will not start test server because of previous failures." if ::Cucumber.wants_to_quit if keyguard_enabled? wake_up end - env_options = options + env_options = options.clone + env_options.delete(:intent) - env_options[:target_package] ||= package_name(@app_path) env_options[:main_activity] ||= main_activity(@app_path) env_options[:test_server_port] ||= @test_server_port env_options[:class] ||= "sh.calaba.instrumentationbackend.InstrumentationBackend" cmd_arr = [adb_command, "shell am instrument"] @@ -717,13 +718,27 @@ raise msg_s end log("Client and server versions match (client: #{client_version}, server: #{server_version}). Proceeding...") + block.call if block + + start_application(options[:intent]) + # What is Calabash tracking? Read this post for information # No private data (like ip addresses) are collected # https://github.com/calabash/calabash-android/issues/655 Calabash::Android::UsageTracker.new.post_usage_async + end + + def start_application(intent) + result = JSON.parse(http("/start-application", {intent: intent})) + + if result['outcome'] != 'SUCCESS' + raise result['detail'] + end + + result['result'] end def shutdown_test_server begin http("/kill")