Class: Apophis::GenymotionRunner
- Inherits:
-
Object
- Object
- Apophis::GenymotionRunner
- Defined in:
- lib/apophis/genymotion_runner.rb
Constant Summary collapse
- ADB =
'$ANDROID_HOME/platform-tools/adb'.freeze
- GM =
'/Applications/Genymotion.app/Contents/MacOS/player.app/Contents/MacOS/player'.freeze
- LAUNCH_WAIT =
5
- SPLASH_SLEEP =
5
Instance Method Summary collapse
- #devices ⇒ Object
- #doctor! ⇒ Object
-
#initialize(gmroot = nil) ⇒ GenymotionRunner
constructor
A new instance of GenymotionRunner.
- #launch(name, timeout = 180) ⇒ Object
-
#wait_for_android_device(timeout = 5) ⇒ Object
later, add an id for specific device.
Constructor Details
#initialize(gmroot = nil) ⇒ GenymotionRunner
Returns a new instance of GenymotionRunner.
10 11 12 |
# File 'lib/apophis/genymotion_runner.rb', line 10 def initialize(gmroot=nil) @gm = gmroot || GM end |
Instance Method Details
#devices ⇒ Object
22 23 24 25 |
# File 'lib/apophis/genymotion_runner.rb', line 22 def devices out = `#{ADB} devices` out.lines.map(&:chop).reject{|line|line.start_with?('*')}.reject(&:empty?)[1..-1] end |
#doctor! ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/apophis/genymotion_runner.rb', line 14 def doctor! errors = [] errors << "No valid Android tooling installed / or ANDROID_HOME not set: adb" unless system("#{ADB} version > /dev/null") errors << "Cannot find genymotion at #{@gm}" unless system("ls #{@gm} > /dev/null") raise errors.join("\n") unless errors.empty? end |
#launch(name, timeout = 180) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/apophis/genymotion_runner.rb', line 27 def launch(name, timeout=180) DottyTimeout.timeout(timeout) do Process.spawn("#{@gm} --vm-name '#{name}' > /dev/null 2>&1", out:'/dev/null', err:'/dev/null') begin wait_for_android_device(LAUNCH_WAIT) return true rescue end false end sleep(SPLASH_SLEEP) end |
#wait_for_android_device(timeout = 5) ⇒ Object
later, add an id for specific device
41 42 43 44 45 |
# File 'lib/apophis/genymotion_runner.rb', line 41 def wait_for_android_device(timeout=5) #later, add an id for specific device DottyTimeout.timeout(timeout) do devices.size > 0 end end |