Class: Calabash::Extras::AndroidRunner::Emulator
- Inherits:
-
Object
- Object
- Calabash::Extras::AndroidRunner::Emulator
- Defined in:
- lib/calabash-extras/android_runner.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config) ⇒ Emulator
constructor
A new instance of Emulator.
- #is_running? ⇒ Boolean
- #kill ⇒ Object
- #kill_old ⇒ Object
- #run ⇒ Object
- #unlock ⇒ Object
Constructor Details
#initialize(config) ⇒ Emulator
Returns a new instance of Emulator.
49 50 51 |
# File 'lib/calabash-extras/android_runner.rb', line 49 def initialize(config) @cfg = config end |
Class Method Details
.launch(config) ⇒ Object
43 44 45 46 47 |
# File 'lib/calabash-extras/android_runner.rb', line 43 def self.launch(config) inst = self.new(config) inst.kill_old inst.run end |
Instance Method Details
#is_running? ⇒ Boolean
60 61 62 |
# File 'lib/calabash-extras/android_runner.rb', line 60 def is_running? defined? @pid && !@pid.nil? && @pid > 0 end |
#kill ⇒ Object
70 71 72 |
# File 'lib/calabash-extras/android_runner.rb', line 70 def kill Process.kill('QUIT', @pid) if is_running? end |
#kill_old ⇒ Object
74 75 76 |
# File 'lib/calabash-extras/android_runner.rb', line 74 def kill_old find_pids.each { |pid| Process.kill('QUIT', pid) } end |
#run ⇒ Object
53 54 55 56 57 58 |
# File 'lib/calabash-extras/android_runner.rb', line 53 def run @pid = fork { exec(@cfg['run']) } sleep(@cfg['wait_for_emulator']) unlock sleep(@cfg['sleep_after_launch']) end |
#unlock ⇒ Object
64 65 66 67 68 |
# File 'lib/calabash-extras/android_runner.rb', line 64 def unlock emulator_cli = Net::Telnet::new('Host' => @cfg['host'], 'Port' => @cfg['port']) emulator_cli.puts('event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0') emulator_cli.close end |