Package playn.core

Class StubPlatform

java.lang.Object
playn.core.Platform
playn.core.StubPlatform

public class StubPlatform extends Platform
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() - 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
  • Constructor Details

    • StubPlatform

      public StubPlatform()
  • Method Details

    • type

      public Platform.Type type()
      Description copied from class: Platform
      Returns the platform Platform.Type.
      Specified by:
      type in class Platform
    • 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 JRE new Date().getTime();, but is terser and avoids the use of long, which is best avoided when translating to JavaScript.
      Specified by:
      time in class Platform
    • tick

      public int tick()
      Description copied from class: Platform
      Returns the number of milliseconds that have elapsed since the game started.
      Specified by:
      tick in class Platform
    • openURL

      public void openURL(String url)
      Description copied from class: Platform
      Opens the given URL in the default browser.
      Specified by:
      openURL in class Platform
    • assets

      public Assets assets()
      Description copied from class: Platform
      Returns the Assets service.
      Specified by:
      assets in class Platform
    • audio

      public Audio audio()
      Description copied from class: Platform
      Returns the Audio service.
      Specified by:
      audio in class Platform
    • graphics

      public Graphics graphics()
      Description copied from class: Platform
      Returns the Graphics service.
      Specified by:
      graphics in class Platform
    • net

      public Net net()
      Description copied from class: Platform
      Returns the Net service.
      Specified by:
      net in class Platform
    • exec

      public Exec exec()
      Description copied from class: Platform
      Returns the Exec service.
      Specified by:
      exec in class Platform
    • input

      public Input input()
      Description copied from class: Platform
      Returns the Input service.
      Specified by:
      input in class Platform
    • json

      public Json json()
      Description copied from class: Platform
      Returns the Json service.
      Specified by:
      json in class Platform
    • log

      public Log log()
      Description copied from class: Platform
      Returns the Log service.
      Specified by:
      log in class Platform
    • storage

      public Storage storage()
      Description copied from class: Platform
      Returns the Storage storage service.
      Specified by:
      storage in class Platform