Module: Calabash::Cucumber::IOS7Operations

Includes:
UIA
Included in:
Core
Defined in:
lib/calabash-cucumber/ios7_operations.rb

Instance Method Summary collapse

Methods included from UIA

#escape_uia_string, #send_uia_command, #uia_element_does_not_exist?, #uia_element_exists?, #uia_enter, #uia_handle_command, #uia_names, #uia_pan, #uia_pan_offset, #uia_pinch, #uia_pinch_offset, #uia_query, #uia_screenshot, #uia_scroll_to, #uia_send_app_to_background, #uia_set_location, #uia_swipe, #uia_swipe_offset, #uia_tap, #uia_tap_mark, #uia_tap_offset, #uia_type_string

Instance Method Details

#find_or_raise(ui_query) ⇒ Object



65
66
67
68
69
70
71
72
# File 'lib/calabash-cucumber/ios7_operations.rb', line 65

def find_or_raise(ui_query)
  results = query(ui_query)
  if results.empty?
    screenshot_and_raise "Unable to find element matching query #{ui_query}"
  else
    results.first
  end
end

#ios7?Boolean

Returns:

  • (Boolean)


10
11
12
13
# File 'lib/calabash-cucumber/ios7_operations.rb', line 10

def ios7?
  launcher = @calabash_launcher || Calabash::Cucumber::Launcher.launcher_if_used
  ENV['OS']=='ios7' || (launcher && launcher.device && launcher.device.ios7?)
end

#pan_ios7(from, to, options = {}) ⇒ Object



54
55
56
57
58
59
# File 'lib/calabash-cucumber/ios7_operations.rb', line 54

def pan_ios7(from, to, options={})
  from_result = find_or_raise from
  to_result = find_or_raise to
  uia_pan_offset(point_from(from_result, options), point_from(to_result, options), options)
  [to_result]
end

#pinch_ios7(in_or_out, options) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/calabash-cucumber/ios7_operations.rb', line 40

def pinch_ios7(in_or_out, options)
  ui_query = options[:query]
  offset =  options[:offset]
  duration = options[:duration] || 0.5
  if ui_query.nil?
    uia_pinch_offset(in_or_out, offset, {:duration => options[:duration]})
  else
    el_to_pinch = find_or_raise(ui_query)
    offset = point_from(el_to_pinch, options)
    uia_pinch_offset(in_or_out, offset, duration)
    [el_to_pinch]
  end
end

#rotate_ios7(dir) ⇒ Object



61
62
63
# File 'lib/calabash-cucumber/ios7_operations.rb', line 61

def rotate_ios7(dir)
  throw NotImplementedError
end

#swipe_ios7(options) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/calabash-cucumber/ios7_operations.rb', line 27

def swipe_ios7(options)
  ui_query = options[:query]
  offset =  options[:offset]
  if ui_query.nil?
    uia_swipe_offset(offset, options)
  else
    el_to_swipe = find_or_raise(ui_query)
    offset = point_from(el_to_swipe, options)
    uia_swipe_offset(offset, options)
    [el_to_swipe]
  end
end

#touch_ios7(options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/calabash-cucumber/ios7_operations.rb', line 15

def touch_ios7(options)
  ui_query = options[:query]
  offset =  options[:offset]
  if ui_query.nil?
    uia_tap_offset(offset)
  else
    el_to_touch = find_or_raise(ui_query)
    touch(el_to_touch, options)
    [el_to_touch]
  end
end