Class: Xcmonkey

Inherits:
Object
  • Object
show all
Defined in:
lib/xcmonkey.rb,
lib/xcmonkey/version.rb

Constant Summary collapse

VERSION =
'1.2.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ Xcmonkey

Returns a new instance of Xcmonkey.



12
13
14
15
16
17
18
# File 'lib/xcmonkey.rb', line 12

def initialize(params)
  params[:session_path] = Dir.pwd if params[:session_path].nil?
  params[:duration] = 60 if params[:duration].nil?
  params[:enable_simulator_keyboard] = true if params[:enable_simulator_keyboard].nil?
  ensure_required_params(params)
  self.driver = Driver.new(params)
end

Instance Attribute Details

#driverObject

Returns the value of attribute driver.



10
11
12
# File 'lib/xcmonkey.rb', line 10

def driver
  @driver
end

Instance Method Details

#ensure_required_params(params) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
# File 'lib/xcmonkey.rb', line 31

def ensure_required_params(params)
  Logger.error('UDID should be provided') if params[:udid].nil?

  Logger.error('Bundle identifier should be provided') if params[:bundle_id].nil?

  Logger.error('Session path should be a directory') if params[:session_path].nil? || !File.directory?(params[:session_path])

  if params[:duration].nil? || !params[:duration].kind_of?(Integer) || !params[:duration].positive?
    Logger.error('Duration must be Integer and not less than 1 second')
  end
end

#gesturesObject



24
25
26
27
28
29
# File 'lib/xcmonkey.rb', line 24

def gestures
  taps = [:precise_tap, :blind_tap] * 10
  swipes = [:precise_swipe, :blind_swipe] * 5
  presses = [:precise_press, :blind_press]
  taps + swipes + presses
end

#runObject



20
21
22
# File 'lib/xcmonkey.rb', line 20

def run
  driver.monkey_test(gestures)
end