Class: Calabash::Android::Gestures::MultiTouchGesture

Inherits:
Object
  • Object
show all
Defined in:
lib/calabash-android/gestures.rb

Constant Summary collapse

DEFAULT_TIMEOUT =
5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gestures = []) ⇒ MultiTouchGesture

Returns a new instance of MultiTouchGesture.



12
13
14
15
16
17
18
19
# File 'lib/calabash-android/gestures.rb', line 12

def initialize(gestures = [])
  unless gestures.is_a?(Array)
    gestures = [gestures]
  end

  @gestures = gestures
  @timeout = (ENV['CALABASH_DEFAULT_TIMEOUT'] && ENV['CALABASH_DEFAULT_TIMEOUT'].to_i) || DEFAULT_TIMEOUT
end

Instance Attribute Details

#gesturesObject (readonly)

Returns the value of attribute gestures.



7
8
9
# File 'lib/calabash-android/gestures.rb', line 7

def gestures
  @gestures
end

#timeoutObject

Returns the value of attribute timeout.



8
9
10
# File 'lib/calabash-android/gestures.rb', line 8

def timeout
  @timeout
end

Instance Method Details

#+(gesture_collection) ⇒ Object



21
22
23
# File 'lib/calabash-android/gestures.rb', line 21

def +(gesture_collection)
  MultiTouchGesture.new(@gestures + gesture_collection.gestures)
end

#<<(gesture) ⇒ Object



30
31
32
# File 'lib/calabash-android/gestures.rb', line 30

def <<(gesture)
  @gestures << gesture
end

#add_gestureObject



25
26
27
28
# File 'lib/calabash-android/gestures.rb', line 25

def add_gesture
  gestures = @gestures
  MultiTouchGesture.new(gestures + gesture_collection.gestures)
end

#add_touch(touch, index = 0) ⇒ Object



34
35
36
37
38
# File 'lib/calabash-android/gestures.rb', line 34

def add_touch(touch, index=0)
  gestures = @gestures
  gestures[index] << touch
  MultiTouchGesture.new(gestures)
end

#add_touch!(touch, index = 0) ⇒ Object



40
41
42
# File 'lib/calabash-android/gestures.rb', line 40

def add_touch!(touch, index=0)
  @gestures = add_touch(touch, index).gestures
end

#max_execution_timeObject



71
72
73
# File 'lib/calabash-android/gestures.rb', line 71

def max_execution_time
  (@gestures.map {|gesture| gesture.max_execution_time}).max
end

#merge(multi_touch_gesture) ⇒ Object



44
45
46
# File 'lib/calabash-android/gestures.rb', line 44

def merge(multi_touch_gesture)
  MultiTouchGesture.new(gestures.map.with_index {|gesture, index| gesture + multi_touch_gesture.gestures[index]})
end

#merge!(multi_touch_gesture) ⇒ Object



48
49
50
# File 'lib/calabash-android/gestures.rb', line 48

def merge!(multi_touch_gesture)
  @gestures = merge(multi_touch_gesture).gestures
end

#offset=(offset) ⇒ Object



67
68
69
# File 'lib/calabash-android/gestures.rb', line 67

def offset=(offset)
  @gestures.each {|gesture| gesture.offset=offset}
end

#query_string=(query_string) ⇒ Object



59
60
61
# File 'lib/calabash-android/gestures.rb', line 59

def query_string=(query_string)
  @gestures.each {|gesture| gesture.query_string=query_string}
end

#reset_query_stringObject



63
64
65
# File 'lib/calabash-android/gestures.rb', line 63

def reset_query_string
  @gestures.each {|gesture| gesture.reset_query_string}
end

#to_json(*object) ⇒ Object



52
53
54
55
56
57
# File 'lib/calabash-android/gestures.rb', line 52

def to_json(*object)
  {
      query_timeout: @timeout.to_f,
      gestures: @gestures
  }.to_json(*object)
end