Module: Calabash::Android::DragHelpers

Includes:
EnvironmentHelpers, MonkeyHelpers
Included in:
Operations
Defined in:
lib/calabash-android/drag_helpers.rb

Constant Summary

Constants included from MonkeyHelpers

MonkeyHelpers::MAX_RETRIES

Instance Method Summary collapse

Methods included from MonkeyHelpers

#adb_command, #existing_monkey_pids, #get_monkey_port, #kill_existing_monkey_processes, #kill_monkey_processes_on_device, #kill_monkey_processes_on_host, #monkey_move_from, #monkey_tap, #monkey_touch, #start_monkey

Methods included from EnvironmentHelpers

#xamarin_test_cloud?

Instance Method Details

#drag_and_drop(from_query, to_query, steps = 10, hold_time = 0.5, hang_time = 0.5) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/calabash-android/drag_helpers.rb', line 19

def drag_and_drop(from_query, to_query, steps=10, hold_time=0.5, hang_time=0.5)
  wait_for_element_exists(from_query)
  wait_for_element_exists(to_query)

  from_results = query(from_query)
  to_results = query(to_query)

  if from_results.any?
    if to_results.any?
      from_rect = from_results.first['rect']
      to_rect = to_results.first['rect']
      from_x = from_rect['center_x']
      from_y = from_rect['center_y']
      to_x = to_rect['center_x']
      to_y = to_rect['center_y']

      monkey_move_from(from_x, from_y, to_x, to_y, hold_time: hold_time, hang_time: hang_time, steps: steps)
    else
      raise "No matching elements for: #{to_query}"
    end
  else
    raise "No matching elements for: #{from_query}"
  end
end

#drag_coordinates(from_x, from_y, to_x, to_y, steps = 10, hold_time = 0.5, hang_time = 0.5) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/calabash-android/drag_helpers.rb', line 10

def drag_coordinates(from_x, from_y, to_x, to_y, steps=10, hold_time=0.5, hang_time=0.5)
  calabash_log "Dragging from #{from_x},#{from_y} to #{to_x},#{to_y}"
  monkey_move_from(from_x, from_y,
                   to_x, to_y,
                   hold_time: hold_time,
                   hang_time: hang_time,
                   steps: steps)
end