Module: Gametel::Platforms::ListItem

Included in:
BrazenheadPlatform
Defined in:
lib/gametel/platforms/brazenhead/list_item.rb

Instance Method Summary collapse

Instance Method Details

#get_class(device, class_name) ⇒ Object



37
38
39
40
# File 'lib/gametel/platforms/brazenhead/list_item.rb', line 37

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

#list_item(locator, &block) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/gametel/platforms/brazenhead/list_item.rb', line 29

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

#list_item_has_image(locator) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/gametel/platforms/brazenhead/list_item.rb', line 21

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

#press_list_item(locator) ⇒ Object



7
8
9
10
11
# File 'lib/gametel/platforms/brazenhead/list_item.rb', line 7

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

#text_from_list_item(locator) ⇒ Object



13
14
15
16
17
18
19
# File 'lib/gametel/platforms/brazenhead/list_item.rb', line 13

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