Skip to content

Deeply hacking into libGdx' input machinery to be able to automate stuff

License

Notifications You must be signed in to change notification settings

suluke/gdx.automation

Repository files navigation

gdx.automation

Input recorder and playback for libGDX

Goals

  • Record input of usage/test scenarios
  • Play back recorded input to replay a usage scenario
  • Enable remote input
  • Generate input programmatically
  • Visualize generated input to let the user see what's going on
  • Provide libGdx-tailored tools for testing ui

I hope, there are people out there who find it useful.
Below I explain what can already be achieved with the project, and in the "Future development" section you will find additional ideas on what is planned to be made possible soon.

Features

  • tested on desktop, code written to also support android (not tested)
  • recorded input legible for both poll- and event-based applications
    (RemoteSender only supports input retrieved via InputProcessors)
  • offering means to record and playback input with just 3 additional lines of code, see below
  • alternative to android's monkeyrunner, platform independently and in the language you already work with!
  • alternative to android's monkey tool, too. (currently TODO, see RandomInputRecordReader)
  • architecture supporting three types of input, for easy extensibility:
    1. static (e.g. which sensors are supported)
    2. synchronous (propagated in main loop, e.g. touch events)
    3. asynchronous (callback supplied, e.g. getPlaceholderText)
  • advanced configurability
    • specify which input values you are interested in
    • where you store the recorded input
    • which format is used (write your own format!)

How to use

Recording

public static void main(String[] args) { // or onCreate on Android
	// initialize your app first...
	InputRecorderConfiguration inputConfig = new InputRecorderConfiguration();
	// maybe alter the configuration
	// create and set a custom InputRecordWriter
	InputRecorder recorder = new InputRecorder(inputConfig);
	recorder.startRecording();
}

Playback

public T myMethod(...) { // wherever you want to playback
	InputRecordReader myInputRecordReader = ... // create and set a custom InputRecordReader
	InputRecordPlayer player = new InputRecordPlayer(myInputRecordReader);
	player.startPlayback();
}

Consult the class documentation to get an overview of how the api looks like.
OR: See the demos folder and the eclipse project within for code in action:

  • com.badlogic.demos.automation.simple: Simple application to visualize input while recrding it with the ability to play it back

Future development

  • get recording to work with simple writer/ output format CHECK!
  • implement InputPlayer CHECK!
  • implement callbacks during playback
    • on replay finished, so e.g. a tutorial will automatically be replayed CHECK!
  • InputCombinator: implement a player supporting to mix the recorded input with the actual input
    • e.g. specify regions that still listen to current device events, so an onscreen button can stop a playback. This would be great for tutorials.
  • develop single file writer and reader
  • RandomInputRecordReader: implement an android-style monkey tool
  • implement InputBuilder, a way to generate input sequences programmatically
  • gradleize project (no jars in repository)
  • write tests, lots of
  • write Actors to make it easy to realize tutorials
  • implement network reader and writer to replace RemoteInput and RemoteSender
  • code flaws:
    • SparseArray needs to be removed
    • thread safety should be re-evaluated (not too much, but not too few either)
    • use less reflection. Use real backends with real access to platform specific code.
    • comply with libGdx' style guidelines (Collections)

Contributing

I would be happy to receive any pull requests with improvements. Note that I am more likely to accept contributions that comply with the libGdx contribution guidelines, though.
Regarding the Contributor License Agreement, I will not demand it for smaller contributions (e.g. fixing a bug, adding new features that are non-essential for the whole project). However, if someone comes an asks me to replace huge parts of already existing code with his own, I will probably insist on a written assurance that he won't revoke his consent for his code being used in gdx-automation later.

Licensing

Copyright 2014 Lukas Böhm

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Deeply hacking into libGdx' input machinery to be able to automate stuff

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published