Top Level Namespace
- Includes:
- REXML
Defined Under Namespace
Modules: Calabash
Constant Summary collapse
- WAIT_TIMEOUT =
ENV['WAIT_TIMEOUT'] || 30
- STEP_PAUSE =
(ENV['STEP_PAUSE'] || 0.5).to_f
Instance Method Summary collapse
- #api_level ⇒ Object
- #checksum(file_path) ⇒ Object
- #is_windows? ⇒ Boolean
- #main_activity(app) ⇒ Object
- #manifest(app) ⇒ Object
- #package_name(app) ⇒ Object
- #test_server_path(apk_file_path) ⇒ Object
Instance Method Details
#api_level ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/calabash-android/helpers.rb', line 26 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 |
#checksum(file_path) ⇒ Object
44 45 46 47 |
# File 'lib/calabash-android/helpers.rb', line 44 def checksum(file_path) require 'digest/md5' Digest::MD5.hexdigest(File.read(file_path)) end |
#is_windows? ⇒ Boolean
53 54 55 56 |
# File 'lib/calabash-android/helpers.rb', line 53 def is_windows? require 'rbconfig' (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/) end |
#main_activity(app) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/calabash-android/helpers.rb', line 14 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 |
#manifest(app) ⇒ Object
40 41 42 |
# File 'lib/calabash-android/helpers.rb', line 40 def manifest(app) `java -jar "#{File.dirname(__FILE__)}/lib/manifest_extractor.jar" "#{app}"` end |