lib/gametel/accessors.rb in gametel-0.5.7 vs lib/gametel/accessors.rb in gametel-0.5.8

- old
+ new

@@ -1,16 +1,30 @@ module Gametel module Accessors + # + # Generates a method named active? which will wait for the + # activity to become active + # + # returns true when successful + # + def activity(activity_name) + define_method("active?") do + platform.wait_for_activity activity_name + platform.last_json + end + end + + # # Generates methods to enter text into a text field, clear the text # field, get the hint as well as the description # # @example # text(:first_name, :index => 0) # # will generate 'first_name', 'first_name=', 'clear_first_name', 'first_name_hint' and 'first_name_description' methods # - # @param [String] the name used for the generated methods + # @param [Symbol] the name used for the generated methods # @param [Hash] locator for how the text is found The valid # keys are: # * :id # * :index # @@ -34,11 +48,11 @@ # # @example # button(:save, :text => 'Save') # # will generate 'save' and 'save_enabled?' methods # - # @param [String] the name used for the generated methods + # @param [Symbol] the name used for the generated methods # @param [Hash] locator for how the button is found The valid # keys are: # * :text # * :index # * :id @@ -67,11 +81,11 @@ # @example # list_item(:details, :index => 2) # # will generate 'details' method to select third item in the # # first list # - # @param [String] the name used for the generated methods + # @param [Symbol] the name used for the generated methods # @param [Hash] locator for how the list item is found The valid # keys are: # * :text # * :index # * :list - only us with :index to indicate which list to use on @@ -91,11 +105,11 @@ # # @example # checkbox(:enable, :text => 'Enable') # # will generate 'enable' method # - # @param [String] the name used for the generated methods + # @param [Symbol] the name used for the generated methods # @param [Hash] locator for how the checkbox is found The valid # keys are: # * :text # * :index # * :id @@ -114,11 +128,11 @@ # # @example # radio_button(:circle, :text => 'Circle') # # will generate 'circle' method # - # @param [String] the name used for the generated methods + # @param [Symbol] the name used for the generated methods # @param [Hash] locator for how the checkbox is found The valid # keys are: # * :text # * :index # * :id @@ -136,11 +150,11 @@ # Generates one method to click a view. # @example # view(:clickable_text, :id => 'id_name_of_your_control') # # will generate 'clickable_text' method # - # @param [String] the name used for the generated methods + # @param [Symbol] the name used for the generated methods # @param [Hash] locator indicating an id for how the view is found. # The only valid keys are: # * :id # * :text # @@ -158,11 +172,11 @@ # the secondary progress # @example # spinner(:progress_item, :id => 'id_name_of_your_control') # # will generate progress_item, progress_item=, progress_item_secondary, progress_item_secondary= # - # @param [String] the name used for the generated methods + # @param [Symbol] the name used for the generated methods # @param [Hash] locator indicating an id for how the progress bar is found. # The only valid keys are: # * :id # * :index # @@ -186,16 +200,19 @@ Gametel::Views::Progress.new(platform, locator) end end # - # Generates one method to get the selected item text. + # Generates three method to interact with a spinner # @example # spinner(:spinner_item, :id => 'id_name_of_your_control') - # # will generate 'spinner_item' method + # # will generate 'spinner_item' method to return the spinner + # # value, 'select_spinner_item(value) to set the spinner value + # # and 'spinner_view' to return the view + # - # @param [String] the name used for the generated methods + # @param [Symbol] the name used for the generated methods # @param [Hash] locator indicating an id for how the spinner is found. # The only valid keys are: # * :id # * :index # @@ -206,9 +223,37 @@ define_method("select_#{name}") do |value| platform.select_spinner_value(locator, value) end define_method("#{name}_view") do Gametel::Views::Spinner.new(platform, locator) + end + end + + # + # Generaes method to interact with an image. + # + # @example + # image(:headshot, :id => 'headshot') + # # will generate 'click_headshot' method to click the image, + # # 'wait_for_headshot' which will wait until the image has + # # loaded a drawable and 'headshot_view' to return the view + # + # @param [Symbol] the name used for the generated methods + # @param [Hash] locator indicating an id for how the image is found. + # The only valid keys are: + # * :index + # + def image(name, locator) + define_method("click_#{name}") do + platform.click_image(locator) + end + define_method("wait_for_#{name}") do + wait_until do + platform.has_drawable?(locator) + end + end + define_method("#{name}_view") do + Gametel::Views::Image.new(platform, locator) end end end end