ImperiusGem
#####Remote-control/execute Java on Android phones via Ruby
- Add this gem to your project (add this to your Gemfile):
gem 'imperiusgem', :git => 'git@github.com:lookout/ImperiusGem.git', :branch => 'master'
- Use
require 'imperiusgem'
in your ruby code. - Connect your android device using adb
- Run
adb forward tcp:#1337 tcp:#1337
- Compile ImperiusGeorge and push the .jar file to
/data/local/tmp/test.jar
- Run
adb shell uiautomator runtest test.jar -c imperiusgeorge.TestServer
- That's it! Try some sample code!
###Simple example
d = ImperiusGem::Device.new("http://localhost:7120")
uihelp = ImperiusGem::Thing.new(d,"imperiusgeorge.UIHelp")
uihelp.click("hello world")
###Fancy unit test example
class TestTests < Test::Unit::TestCase
def test_something
UiDevice.getInstance.pressHome
`adb shell am start -n com.android.settings/.Settings`
UIHelp.find("Sound").click if UIHelp.find("Sound").exists
UIHelp.clickIfExactExists("Volumes")
UIHelp.clickIfExactExists("OK")
UiDevice.getInstance.pressHome
@d.clean
end
def self.const_missing(name)
@d = ImperiusGem::Device.new("http://localhost:7120") if !@d
@d.setPackages(["imperiusgeorge", "com.android.uiautomator.core"])
ImperiusGem::Thing.new(@d,name.to_s)
end
end