lib/calabash-android/operations.rb in calabash-android-0.7.3.pre3 vs lib/calabash-android/operations.rb in calabash-android-0.7.3.preintentstart1

- 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 @@ -635,18 +635,19 @@ 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" @@ -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.to_json})) + + if result['outcome'] != 'SUCCESS' + raise result['detail'] + end + + result['result'] end def shutdown_test_server begin http("/kill")