Skip to content

Commit

Permalink
support for more high-level UIA methods
Browse files Browse the repository at this point in the history
  • Loading branch information
krukow committed Jun 20, 2013
1 parent 6bd73ca commit 882f5e6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 7 deletions.
2 changes: 1 addition & 1 deletion calabash-cucumber/calabash-cucumber.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |s|
s.add_dependency( "location-one", "~>0.0.10")
s.add_dependency( "httpclient","~> 2.3.3")
s.add_dependency( "bundler", "~> 1.1")
s.add_dependency( "run_loop", "~> 0.0.13" )
s.add_dependency( "run_loop", "~> 0.0.15" )
s.add_dependency( "awesome_print")

end
67 changes: 63 additions & 4 deletions calabash-cucumber/lib/calabash-cucumber/uia.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require 'edn'
require 'location-one'

module Calabash
module Cucumber
module UIA
Expand All @@ -12,17 +14,70 @@ def send_uia_command(opts ={})
end

def uia_query(*queryparts)
#TODO escape ' in query
#TODO escape '\n etc in query
uia_handle_command(:query, queryparts)
end

def uia_names(*queryparts)
#TODO escape '\n etc in query
uia_handle_command(:names, queryparts)
end

def uia_tap(*queryparts)
#TODO escape ' in query
uia_handle_command(:tap, queryparts)
end

def uia_handle_command(cmd, query)
command = %Q[uia.#{cmd}('#{query.to_edn}')]
def uia_tap_mark(mark)
uia_handle_command(:tapMark, mark)
end

def uia_pan(from_q, to_q)
uia_handle_command(:pan, from_q, to_q)
end

def uia_scroll_to(*queryparts)
uia_handle_command(:scrollTo, queryparts)
end

def uia_element_exists?(*queryparts)
uia_handle_command(:elementExists, queryparts)
end

def uia_element_does_not_exist?(*queryparts)
uia_handle_command(:elementDoesNotExist, queryparts)
end

def uia_screenshot(name)
uia_handle_command(:elementDoesNotExist, name)
end

def uia_type_string(string)
uia_handle_command(:typeString, string)
end

def uia_enter()
uia_handle_command(:enter)
end

def uia_set_location(place)
if place.is_a?(String)
loc = LocationOne::Client.location_by_place(place)
loc_data = {"latitude"=>loc.latitude, "longitude"=>loc.longitude}
else
loc_data = place
end
uia_handle_command(:setLocation, loc_data)
end

def uia_handle_command(cmd, *query_args)
args = query_args.map do |part|
if part.is_a?(String)
"'#{escape_uia_string(part)}'"
else
"'#{escape_uia_string(part.to_edn)}'"
end
end
command = %Q[uia.#{cmd}(#{args.join(', ')})]
if ENV['DEBUG'] == '1'
puts "Sending UIA command"
puts command
Expand All @@ -39,6 +94,10 @@ def uia_handle_command(cmd, query)
end
end

def escape_uia_string(string)
#TODO escape '\n in query
string
end

end
end
Expand Down
4 changes: 2 additions & 2 deletions calabash-cucumber/lib/calabash-cucumber/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Calabash
module Cucumber
VERSION = '0.9.149'
FRAMEWORK_VERSION = '0.9.146'
VERSION = '0.9.150'
FRAMEWORK_VERSION = '0.9.150'
end
end

0 comments on commit 882f5e6

Please sign in to comment.