Package playn.core
Class StubPlatform
java.lang.Object
playn.core.Platform
playn.core.StubPlatform
A stub implementation of
Platform
that provides implementations of those services that
can be usefully implemented for unit tests, and throws UnsupportedOperationException
for
the rest. This can usefully be extended in tests to provide test implementations for just the
aspects of the platform that are needed to support the code under test.
The services that are implemented are:
-
type()
- reportsPlatform.Type.STUB
-
time()
- returns current time -
Platform.invokeLater(java.lang.Runnable)
- invokes the supplied runnable immediately on the calling thread -
input
- allows listener registration, never generates events -
log
- writes logs tostderr
-
json
- provides full JSON parsing and formatting -
storage
- maintains an in-memory storage map
-
Nested Class Summary
Nested classes/interfaces inherited from class playn.core.Platform
Platform.Error, Platform.Lifecycle, Platform.Type
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionassets()
Returns theAssets
service.audio()
Returns theAudio
service.exec()
Returns theExec
service.graphics()
Returns theGraphics
service.input()
Returns theInput
service.json()
Returns theJson
service.log()
Returns theLog
service.net()
Returns theNet
service.void
Opens the given URL in the default browser.storage()
Returns theStorage
storage service.int
tick()
Returns the number of milliseconds that have elapsed since the game started.double
time()
Returns the current time, as a double value in millis since January 1, 1970, 00:00:00 GMT.type()
Returns the platformPlatform.Type
.Methods inherited from class playn.core.Platform
dispatchEvent, invokeAsync, invokeLater, isAsyncSupported, reportError
-
Constructor Details
-
StubPlatform
public StubPlatform()
-
-
Method Details
-
type
Description copied from class:Platform
Returns the platformPlatform.Type
. -
time
public double time()Description copied from class:Platform
Returns the current time, as a double value in millis since January 1, 1970, 00:00:00 GMT. This is equivalent to the standard JREnew Date().getTime();
, but is terser and avoids the use oflong
, which is best avoided when translating to JavaScript. -
tick
public int tick()Description copied from class:Platform
Returns the number of milliseconds that have elapsed since the game started. -
openURL
Description copied from class:Platform
Opens the given URL in the default browser. -
assets
Description copied from class:Platform
Returns theAssets
service. -
audio
Description copied from class:Platform
Returns theAudio
service. -
graphics
Description copied from class:Platform
Returns theGraphics
service. -
net
Description copied from class:Platform
Returns theNet
service. -
exec
Description copied from class:Platform
Returns theExec
service. -
input
Description copied from class:Platform
Returns theInput
service. -
json
Description copied from class:Platform
Returns theJson
service. -
log
Description copied from class:Platform
Returns theLog
service. -
storage
Description copied from class:Platform
Returns theStorage
storage service.
-