-
Notifications
You must be signed in to change notification settings - Fork 14
Extending
DroidMate can be extended by adding custom strategies, selectors and model features
The project is written in Kotlin but fully Java compatible.
Writing a new strategy can be as easy as
import org.droidmate.exploration.actions.AbstractExplorationAction
import org.droidmate.exploration.strategy.widget.ExplorationStrategy
class CustomStrategy: ExplorationStrategy() {
override fun chooseAction(): AbstractExplorationAction {
/** TODO custom code to determine next exploration action **/
}
}
Then all you need is to define a selector, such that DM-2 knows with which priority your strategy should be chosen (and under which conditions). We suggest you to use the ExplorationAPI to easily start an exploration.
import org.droidmate.ExplorationAPI
import org.droidmate.exploration.StrategySelector
class Main {
@JvmStatic fun main(args: Array<String>) {
val cfg = ExplorationAPI.config(args)
val customStrategy = CustomStrategy()
val customStrategySelector =
StrategySelector(0, "custom", { _, pool, _ ->
pool.getFirstInstanceOf(CustomStrategy::class.java)})
ExplorationAPI.explore(cfg, strategies = listOf(customStrategy)
, selectors = listOf(customStrategySelector)
// , reportCreators = org.droidmate.command.ExploreCommand.defaultReportWatcher(cfg)
)
}
}
If you want to use the default strategies, you should add them to the strategies list and the selectors collection. You can use org.droidmate.command.ExploreCommand.getDefaultSelectors(cfg)
and org.droidmate.command.ExploreCommand.getDefaultStrategies(cfg)
for this.
An executable example of how to create your own extensions to DroidMate can be found in repo/droidmate_usage_examples