public class StubPlatform extends Platform
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() - reports Platform.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 to stderr
json - provides full JSON parsing and formatting
storage - maintains an in-memory storage map
Platform.Error, Platform.Lifecycle, Platform.Type| Constructor and Description |
|---|
StubPlatform() |
| Modifier and Type | Method and Description |
|---|---|
Assets |
assets()
Returns the
Assets service. |
Audio |
audio()
Returns the
Audio service. |
Exec |
exec()
Returns the
Exec service. |
Graphics |
graphics()
Returns the
Graphics service. |
Input |
input()
Returns the
Input service. |
Json |
json()
Returns the
Json service. |
Log |
log()
Returns the
Log service. |
Net |
net()
Returns the
Net service. |
void |
openURL(java.lang.String url)
Opens the given URL in the default browser.
|
Storage |
storage()
Returns the
Storage 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.
|
Platform.Type |
type()
Returns the platform
Platform.Type. |
dispatchEvent, invokeAsync, invokeLater, isAsyncSupported, reportErrorpublic Platform.Type type()
PlatformPlatform.Type.public double time()
Platformnew Date().getTime();, but is terser and
avoids the use of long, which is best avoided when translating to JavaScript.public int tick()
Platformpublic void openURL(java.lang.String url)
Platformpublic Graphics graphics()
PlatformGraphics service.Copyright © 2018. All Rights Reserved.