Class: Xcmonkey

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

Constant Summary collapse

VERSION =
'1.3.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
19
# File 'lib/xcmonkey.rb', line 12

def initialize(params)
  params[:event_count] = 60 if params[:event_count].nil?
  params[:ignore_crashes] = false if params[:ignore_crashes].nil?
  params[:disable_simulator_keyboard] = false if params[:disable_simulator_keyboard].nil?
  self.params = params
  self.driver = Driver.new(params)
  ensure_required_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

#paramsObject

Returns the value of attribute params.



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

def params
  @params
end

Instance Method Details

#ensure_required_paramsObject



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

def ensure_required_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] && !File.directory?(params[:session_path])

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

#gesturesObject



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

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

#runObject



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

def run
  driver.monkey_test(gestures)
end