class MobileProcess

Public Instance Methods

after_execute() click to toggle source
# File lib/kraken-mobile/mobile/mobile_process.rb, line 13
def after_execute
  unregister_process_from_directory
  device.delete_inbox
end
apk_path() click to toggle source
# File lib/kraken-mobile/mobile/mobile_process.rb, line 34
def apk_path
  return config_apk_path if @test_scenario.requires_predefined_devices?

  path = @test_scenario&.kraken_app&.apk_path
  raise 'ERROR: Invalid APK file path' if path.nil?

  path
end
before_execute() click to toggle source
# File lib/kraken-mobile/mobile/mobile_process.rb, line 8
def before_execute
  register_process_to_directory
  device.create_inbox
end
execute() click to toggle source
# File lib/kraken-mobile/mobile/mobile_process.rb, line 18
def execute
  open(execution_command, 'r') do |output|
    loop do
      $stdout.print output.readline.to_s
      $stdout.flush
    end
  end
  $CHILD_STATUS.exitstatus
rescue EOFError
  nil
end

Private Instance Methods

config_apk_path() click to toggle source
# File lib/kraken-mobile/mobile/mobile_process.rb, line 86
def config_apk_path
  device_config_json = config_json
  return if device_config_json['config'].nil?
  return if device_config_json['config']['apk_path'].nil?

  absolute_config_apk_path = File.expand_path(
    device_config_json['config']['apk_path']
  )

  raise 'ERROR: Invalid config apk path' unless File.file?(
    absolute_config_apk_path
  )

  absolute_config_apk_path
end
config_json() click to toggle source
# File lib/kraken-mobile/mobile/mobile_process.rb, line 78
def config_json
  config_absolute_path = File.expand_path(ENV[K::CONFIG_PATH])
  file = open(config_absolute_path)
  content = file.read
  file.close
  JSON.parse(content)[@id.to_s] || {}
end
environment_variables_command() click to toggle source
# File lib/kraken-mobile/mobile/mobile_process.rb, line 67
def environment_variables_command
  variables = {
    ADB_DEVICE_ARG: device.id
  }
  exporting_command_for_environment_variables(variables)
end
execution_command() click to toggle source
# File lib/kraken-mobile/mobile/mobile_process.rb, line 45
def execution_command
  "|#{environment_variables_command}#{terminal_command_separator}"\
  "#{running_process_command}"
end
running_process_command() click to toggle source
# File lib/kraken-mobile/mobile/mobile_process.rb, line 50
def running_process_command
  feature_path = test_scenario.feature_file.file_path
  raise 'ERROR: Invalid feature file path' if feature_path.nil?

  process_apk_path = apk_path
  raise 'ERROR: Invalid APK file path' if process_apk_path.nil?

  "calabash-android run #{process_apk_path} \
  #{feature_path} --tags @user#{id} \
  --require features/support/env.rb \
  --require features/support/app_installation_hooks.rb \
  --require features/support/app_life_cycle_hooks.rb \
  --require features/step_definitions/mobile_steps.rb \
  --format pretty --format json -o \
  #{K::REPORT_PATH}/#{@test_scenario.execution_id}/#{device.id}/#{K::FILE_REPORT_NAME}"
end