Class: Apprunner
- Inherits:
-
Object
- Object
- Apprunner
- Defined in:
- lib/droidrunner/apprunner.rb
Overview
< Thor
Instance Method Summary collapse
-
#initialize(adb: nil, port: 55551) ⇒ Apprunner
constructor
A new instance of Apprunner.
-
#install_app(app) ⇒ Object
desc “install_app APPNAME”,“Installs an app in a VM”.
-
#kill_app(app) ⇒ Object
desc “kill_app APPNAME”,“Kills an app in a VM”.
- #monkey_app(app, events) ⇒ Object
-
#run_app(app) ⇒ Object
desc “run_app APP_PACKAGE MAIN_ACTIVITY”,“Runs an app in a VM”.
Constructor Details
#initialize(adb: nil, port: 55551) ⇒ Apprunner
Returns a new instance of Apprunner.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/droidrunner/apprunner.rb', line 5 def initialize(adb:nil, port:55551) puts "Creating adb connection" if adb == nil @adbrunner = Adbrunner.new(port:port) #@adbrunner.kill @adbrunner.connect else @adbrunner = adb end Adbrunner.devices end |
Instance Method Details
#install_app(app) ⇒ Object
desc “install_app APPNAME”,“Installs an app in a VM”
19 20 21 22 |
# File 'lib/droidrunner/apprunner.rb', line 19 def install_app(app) puts "Installing app #{app}" @adbrunner.install(app) end |
#kill_app(app) ⇒ Object
desc “kill_app APPNAME”,“Kills an app in a VM”
38 39 40 41 42 |
# File 'lib/droidrunner/apprunner.rb', line 38 def kill_app(app) puts "Killing app #{app}" @adbrunner.shell(cmd:"am force-stop #{app}") @adbrunner.shell(cmd:"pm clear #{app}") end |
#monkey_app(app, events) ⇒ Object
32 33 34 35 |
# File 'lib/droidrunner/apprunner.rb', line 32 def monkey_app(app,events) puts "Running monkey #{events} events on #{app}" @adbrunner.shell(cmd:"monkey -p #{app} -c android.intent.category.LAUNCHER -v #{events}") end |
#run_app(app) ⇒ Object
desc “run_app APP_PACKAGE MAIN_ACTIVITY”,“Runs an app in a VM”
25 26 27 28 29 30 |
# File 'lib/droidrunner/apprunner.rb', line 25 def run_app(app) puts "Running app : #{app}" #@adbrunner.shell(cmd:"am start -n #{app}/#{activity}") #Running monkey with just one event is icon click (i.e. opening app) @adbrunner.shell(cmd:"monkey -p #{app} -c android.intent.category.LAUNCHER 1") end |