Skip to content

Instantly share code, notes, and snippets.

@kamilolesiejuk
Forked from charroch/gist:921679
Created April 23, 2011 19:00
Show Gist options
  • Save kamilolesiejuk/938878 to your computer and use it in GitHub Desktop.
Save kamilolesiejuk/938878 to your computer and use it in GitHub Desktop.
Zoidberg action handling draft
trait AndroidDeviceAction
case class Install extends AndroidDeviceAction
case class Instrument(options:InstrumentOptions) extends AndroidDeviceAction
case class Monkey extends AndroidDeviceAction
case class MoneyScript(script:Script) extends AndroidDeviceAction
trait AndroidDevice extends Actor {
def receive = {
case Install => // install app
case Instrument =>
case Monkey =>
case MoneyScript(s) =>
}
}
// afterwards:
val aDevice = new Device() with AndroidDevice
@charroch
Copy link

you actually want

case MonkeyScript(s) => exectuteMonkey(s) with s begin the script like in http://developer.android.com/guide/developing/tools/monkeyrunner_concepts.html

When you do a case statement, the variable passed within the case class (i.e. the s for the above) will automatically be mapped depending on what receive gets. So in this case will try to map s to a class of type Script and inject it into the following closure (after =>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment