lib/calabash-android/operations.rb in calabash-android-0.5.14 vs lib/calabash-android/operations.rb in calabash-android-0.5.15.coordinate.pre.fix

- old
+ new

@@ -9,10 +9,11 @@ require 'calabash-android/gestures' require 'calabash-android/helpers' require 'calabash-android/environment_helpers' require 'calabash-android/text_helpers' require 'calabash-android/touch_helpers' +require 'calabash-android/drag_helpers' require 'calabash-android/wait_helpers' require 'calabash-android/version' require 'calabash-android/env' require 'retriable' require 'cucumber' @@ -25,10 +26,11 @@ module Operations include Calabash::Android::EnvironmentHelpers include Calabash::Android::TextHelpers include Calabash::Android::TouchHelpers include Calabash::Android::WaitHelpers + include Calabash::Android::DragHelpers def self.extended(base) if (class << base; included_modules.map(&:to_s).include?('Cucumber::RbSupport::RbWorld'); end) unless instance_methods.include?(:embed) original_embed = base.method(:embed) @@ -287,10 +289,14 @@ forward_cmd = "#{adb_command} forward tcp:#{@server_port} tcp:#{@test_server_port}" log forward_cmd log `#{forward_cmd}` end + def _sdk_version + `#{adb_command} shell getprop ro.build.version.sdk`.to_i + end + def reinstall_apps uninstall_app(package_name(@app_path)) uninstall_app(package_name(@test_server_path)) install_app(@app_path) install_app(@test_server_path) @@ -300,11 +306,16 @@ uninstall_app(package_name(@test_server_path)) install_app(@test_server_path) end def install_app(app_path) - cmd = "#{adb_command} install \"#{app_path}\"" + if _sdk_version >= 23 + cmd = "#{adb_command} install -g \"#{app_path}\"" + else + cmd = "#{adb_command} install \"#{app_path}\"" + end + log "Installing: #{app_path}" result = `#{cmd}` log result pn = package_name(app_path) succeeded = `#{adb_command} shell pm list packages`.lines.map{|line| line.chomp.sub("package:", "")}.include?(pn) @@ -314,10 +325,15 @@ raise "#{pn} did not get installed. Reason: '#{result.lines.last.chomp}'. Aborting!" end end def update_app(app_path) - cmd = "#{adb_command} install -r \"#{app_path}\"" + if _sdk_version >= 23 + cmd = "#{adb_command} install -rg \"#{app_path}\"" + else + cmd = "#{adb_command} install -r \"#{app_path}\"" + end + log "Updating: #{app_path}" result = `#{cmd}` log "result: #{result}" succeeded = result.include?("Success")