lib/calabash-android/operations.rb in calabash-android-0.4.0.pre17 vs lib/calabash-android/operations.rb in calabash-android-0.4.0.pre18
- old
+ new
@@ -5,28 +5,26 @@
require 'json'
require 'socket'
require 'timeout'
require 'calabash-android/helpers'
require 'calabash-android/wait_helpers'
+require 'calabash-android/touch_helpers'
require 'calabash-android/version'
require 'retriable'
require 'cucumber'
module Calabash module Android
module Operations
include Calabash::Android::WaitHelpers
+ include Calabash::Android::TouchHelpers
def log(message)
$stdout.puts "#{Time.now.strftime("%Y-%m-%d %H:%M:%S")} - #{message}" if (ARGV.include? "-v" or ARGV.include? "--verbose")
end
- def take_screenshot
- default_device.take_screenshot
- end
-
def macro(txt)
if self.respond_to?(:step)
step(txt)
else
Then(txt)
@@ -88,32 +86,22 @@
def screenshot(options={:prefix => nil, :name => nil})
default_device.screenshot(options)
end
+ def fail(msg="Error. Check log for details.", options={:prefix => nil, :name => nil, :label => nil})
+ screenshot_and_raise(msg, options)
+ end
+
def set_gps_coordinates_from_location(location)
default_device.set_gps_coordinates_from_location(location)
end
def set_gps_coordinates(latitude, longitude)
default_device.set_gps_coordinates(latitude, longitude)
end
- #def wait_for(timeout, &block)
- # value = nil
- # begin
- # Timeout::timeout(timeout) do
- # until (value = block.call)
- # sleep 0.3
- # end
- # end
- # rescue Exception => e
- # raise e
- # end
- # value
- #end
-
def query(uiquery, *args)
converted_args = []
args.each do |arg|
if arg.is_a?(Hash) and arg.count == 1
converted_args << {:method_name => arg.keys.first, :arguments => [ arg.values.first ]}
@@ -248,28 +236,9 @@
if app_running?
raise e
else
raise "App no longer running"
end
- end
- end
-
- def take_screenshot
- puts "take_screenshot is deprecated. Use screenshot_embed instead."
- path = ENV["SCREENSHOT_PATH_PREFIX"] || "results"
- FileUtils.mkdir_p path unless File.exist? path
- filename_prefix = FeatureNameMemory.feature_name.gsub(/\s+/, '_').downcase
- begin
- Timeout.timeout(30) do
- file_name = "#{path}/#{filename_prefix}_#{FeatureNameMemory.invocation}_#{StepCounter.step_line}.png"
- image = http("/screenshot")
- open(file_name ,"wb") { |file|
- file.write(image)
- }
- log "Screenshot stored in: #{file_name}!!!"
- end
- rescue Timeout::Error
- raise Exception, "take_screenshot timed out"
end
end
def screenshot(options={:prefix => nil, :name => nil})
prefix = options[:prefix] || ENV['SCREENSHOT_PATH'] || ""