Sha256: ec9ca609066598a71c4f668fc887d8d3383767f7926b3f821af5f24373be3fd4

Contents?: true

Size: 1.71 KB

Versions: 21

Compression:

Stored size: 1.71 KB

Contents

require 'rexml/document'
require 'rexml/xpath'

include REXML

def package_name(app)
  require 'rexml/document'
  require 'rexml/xpath'

  manifest = Document.new(manifest(app))
  manifest.root.attributes['package']
end
  
def main_activity(app)
  manifest = Document.new(manifest(app))
  main_activity = manifest.elements["//action[@name='android.intent.action.MAIN']/../.."].attributes['name']
  #Handle situation where main activity is on the form '.class_name'
  if main_activity.start_with? "."
    main_activity = package_name(app) + main_activity
  elsif not main_activity.include? "." #This is undocumentet behaviour but Android seems to accept shorthand naming that does not start with '.'
    main_activity = "#{package_name(app)}.#{main_activity}"
  end
  main_activity
end

def api_level
  formatted_android_home = ENV["ANDROID_HOME"].gsub("\\", "/")
  api_levels = Dir["#{formatted_android_home}/platforms/android-*"].collect{|platform| platform.split("-").last.to_i}.sort
  if api_levels.empty?
    raise "Android SDK not found. Please install one of more using #{ENV["ANDROID_HOME"]}/tools/android"
  end

  api_levels = api_levels.find_all {|l| l > 7}
  if api_levels.empty?
    raise "Android SDK above 7 not found. Please install one of more using #{ENV["ANDROID_HOME"]}/tools/android"
  end
  api_levels.first
end

def manifest(app)
  `java -jar "#{File.dirname(__FILE__)}/lib/manifest_extractor.jar" "#{app}"`
end

def checksum(file_path)
  require 'digest/md5'
  Digest::MD5.hexdigest(File.read(file_path))
end

def test_server_path(apk_file_path)
  "test_servers/#{checksum(apk_file_path)}_#{Calabash::Android::VERSION}.apk"
end

def is_windows?
  require 'rbconfig'
  (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
end


Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
calabash-android-0.3.0.pre8 lib/calabash-android/helpers.rb
calabash-android-0.3.0.pre7 lib/calabash-android/helpers.rb
calabash-android-0.3.0.pre6 lib/calabash-android/helpers.rb
calabash-android-0.3.0.pre5 lib/calabash-android/helpers.rb
calabash-android-0.3.0.pre4 lib/calabash-android/helpers.rb
calabash-android-0.3.0.pre3 lib/calabash-android/helpers.rb
calabash-android-0.3.0.pre2 lib/calabash-android/helpers.rb
calabash-android-0.3.0.pre1 lib/calabash-android/helpers.rb
calabash-android-0.2.22 lib/calabash-android/helpers.rb
calabash-android-0.2.21 lib/calabash-android/helpers.rb
calabash-android-0.2.20 lib/calabash-android/helpers.rb
calabash-android-0.2.19 lib/calabash-android/helpers.rb
calabash-android-0.2.18 lib/calabash-android/helpers.rb
calabash-android-0.2.17 lib/calabash-android/helpers.rb
calabash-android-0.2.16 lib/calabash-android/helpers.rb
calabash-android-0.2.15 lib/calabash-android/helpers.rb
calabash-android-0.2.14 lib/calabash-android/helpers.rb
calabash-android-0.2.13 lib/calabash-android/helpers.rb
calabash-android-0.2.12 lib/calabash-android/helpers.rb
calabash-android-0.2.11 lib/calabash-android/helpers.rb