funny george image

ImperiusGem

Remote-control/execute Java on Android phones via Ruby
  1. Add this gem to your project (add this to your Gemfile): gem 'imperiusgem', :git => '[email protected]:lookout/ImperiusGem.git', :branch => 'master'
  2. Use require 'imperiusgem' in your ruby code.
  3. Connect your android device using adb
  4. Run adb forward tcp:#1337 tcp:#1337
  5. Compile ImperiusGeorge and push the .jar file to /data/local/tmp/test.jar
  6. Run adb shell uiautomator runtest test.jar -c imperiusgeorge.TestServer
  7. 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