lib/calabash-android/operations.rb in calabash-android-0.5.15 vs lib/calabash-android/operations.rb in calabash-android-0.5.16.pre1

- old
+ new

@@ -17,10 +17,11 @@ require 'calabash-android/env' require 'retriable' require 'cucumber' require 'date' require 'time' +require 'shellwords' module Calabash module Android module Operations @@ -40,11 +41,11 @@ end end end def current_activity - `#{default_device.adb_command} shell dumpsys window windows`.each_line.grep(/mFocusedApp.+[\.\/]([^.\s\/\}]+)/){$1}.first + `#{default_device.adb_command} shell dumpsys window windows`.force_encoding('UTF-8').each_line.grep(/mFocusedApp.+[\.\/]([^.\s\/\}]+)/){$1}.first end def log(message) $stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} - #{message}" if (ARGV.include? "-v" or ARGV.include? "--verbose") end @@ -775,10 +776,11 @@ else params = hash.map {|k,v| "-e \"#{k}\" \"#{v}\""}.join(" ") logcat_id = get_logcat_id() - cmd = "#{adb_command} shell am instrument -e logcat #{logcat_id} -e name \"#{name}\" #{params} #{package_name(@test_server_path)}/sh.calaba.instrumentationbackend.SetPreferences" + am_cmd = Shellwords.escape("am instrument -e logcat #{logcat_id} -e name \"#{name}\" #{params} #{package_name(@test_server_path)}/sh.calaba.instrumentationbackend.SetPreferences") + cmd = "#{adb_command} shell #{am_cmd}" raise "Could not set preferences" unless system(cmd) logcat_cmd = get_logcat_cmd(logcat_id) logcat_output = `#{logcat_cmd}`