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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionassets()Returns theAssetsservice.audio()Returns theAudioservice.exec()Returns theExecservice.graphics()Returns theGraphicsservice.input()Returns theInputservice.json()Returns theJsonservice.log()Returns theLogservice.net()Returns theNetservice.voidOpens the given URL in the default browser.storage()Returns theStoragestorage service.inttick()Returns the number of milliseconds that have elapsed since the game started.doubletime()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:PlatformReturns the platformPlatform.Type. -
time
public double time()Description copied from class:PlatformReturns 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:PlatformReturns the number of milliseconds that have elapsed since the game started. -
openURL
Description copied from class:PlatformOpens the given URL in the default browser. -
assets
Description copied from class:PlatformReturns theAssetsservice. -
audio
Description copied from class:PlatformReturns theAudioservice. -
graphics
Description copied from class:PlatformReturns theGraphicsservice. -
net
Description copied from class:PlatformReturns theNetservice. -
exec
Description copied from class:PlatformReturns theExecservice. -
input
Description copied from class:PlatformReturns theInputservice. -
json
Description copied from class:PlatformReturns theJsonservice. -
log
Description copied from class:PlatformReturns theLogservice. -
storage
Description copied from class:PlatformReturns theStoragestorage service.
-