Sha256: 8dd2a114262aabbb45c0a35b096e6772938c4dbc20efe50d6c70cfe1875cfe39

Contents?: true

Size: 1.32 KB

Versions: 8

Compression:

Stored size: 1.32 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@@')
          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

8 entries across 8 versions & 1 rubygems

Version Path
gametel-0.5.9.3 lib/gametel/platforms/brazenhead/list_item.rb
gametel-0.5.9.2 lib/gametel/platforms/brazenhead/list_item.rb
gametel-0.5.9.1 lib/gametel/platforms/brazenhead/list_item.rb
gametel-0.5.9 lib/gametel/platforms/brazenhead/list_item.rb
gametel-0.5.8.1 lib/gametel/platforms/brazenhead/list_item.rb
gametel-0.5.8 lib/gametel/platforms/brazenhead/list_item.rb
gametel-0.5.7 lib/gametel/platforms/brazenhead/list_item.rb
gametel-0.5.6 lib/gametel/platforms/brazenhead/list_item.rb