Sha256: 706a0471c08b5d69d5c9527c2bbe2ac6b138ad140f246a49ce4d7c9e941e5de5

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

require 'brazenhead'

module Gametel
  module Platforms
    module ListItem

      def press_list_item(locator)
        list = locator[:list] ? locator[:list] : 0
        result = click_in_list(locator[:index] + 1, list) if locator[:index]
        result = click_on_text(locator[:text]) if locator[:text]
      end

      def text_from_list_item(locator)
        list_item(locator) do |device|
          get_class(device, 'android.widget.TextView')
          device.get_current_views('@@the_class@@', '@@the_view@@', :target => 'Robotium')
        end
        last_json.map { |text_view| text_view['text'] }
      end

      def list_item_has_image(locator)
        list_item(locator) do |device|
          get_class(device, 'android.widget.ImageView')
          device.get_current_views('@@the_class@@', '@@the_view@@', :target => 'Robotium')
        end
        last_json[0]['hasDrawable'] if last_json[0]
      end

      def list_item(locator, &block) 
        chain_calls do |device|
          device.list_item_by_text(locator[:text], :target => 'Brazenhead', :variable => '@@the_view@@') if locator[:text]
          device.list_item_by_index(locator[:index], :target => 'Brazenhead', :variable => '@@the_view@@') if locator[:index]
          block.call device if block
        end
      end

      def get_class(device, class_name)
        device.get_class
        device.for_name class_name, :variable => '@@the_class@@'
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
gametel-0.8 lib/gametel/platforms/brazenhead/list_item.rb
gametel-0.7 lib/gametel/platforms/brazenhead/list_item.rb
gametel-0.6 lib/gametel/platforms/brazenhead/list_item.rb