Package limn.testing

Class AccessibleHarness

java.lang.Object
limn.testing.AccessibleHarness

public final class AccessibleHarness extends Object
A widget bound to a headless scene whose window hands out a bridge that keeps what it is given: what a per-shape contract needs to read the tree a real widget publishes and to drive a verb into it the way a platform does. It is the mechanics of the toolkit's own AccessibleComponentTestBase, without JUnit, so that a contract in these fixtures can run over a widget from any module and, one day, from an application.

Time does not pass unless advanceTime(long, limn.scene.Widget<?>) says it does, for the reason that base gives: a measurement that lands in the middle of a fade depends on the machine, not on the widget. The scene's clock and the one the runtime's delayed tasks fall due on are one clock: the harness hands the runtime its own as it is built, so a timer, or the arrival a fade that goes straight there waits for under less motion, falls due as advanceTime passes it, as a fade that moves arrives on the scene's frames. The last harness built on a runtime is the one whose time its delayed tasks follow. A verb is performed from a thread that is not the UI thread, which is the path a bridge takes, and the host must return without blocking it. The scene is 400 by 300, the stub window's size; a subject that wants a smaller box wraps its widget in a SizedBox.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The bridge, listening from the first frame, holding every tree and event published.
    final List<Change>
    Every change the scene announced since the last clearObservations().
    static final float
     
    final Scene
    The scene the root is bound in.
    static final float
    The scene's width and height, which are the stub window's.
    The window the scene is bound to; its StubWindow.accessibility is the bridge.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AccessibleHarness(UiRuntime runtime, Widget<?> root)
    Binds root and renders the first frame, so that tree() answers at once.
    AccessibleHarness(UiRuntime runtime, Widget<?> root, StubWindow window)
    Binds root in window: a stub that cannot position lets a popup open as an overlay of the scene, where the tree can see it, rather than as a window of its own.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    advanceTime(long millis, @Nullable Widget<?> damage)
    Moves scene time forward in steps no longer than the scene's own tick, damaging damage before each frame so that an animation on it advances: one turn of the loop, the queue drained and a frame rendered (frame()), for each step.
    void
    Forgets the events and changes seen so far; the trees stay.
     
    void
    focus(Widget<?> widget)
    Gives widget the keyboard and renders a frame, so the cursor is published.
    void
    One turn of a backend's loop: the UI queue drained, then one frame rendered at the current scene time, so that what the toolkit leaves for the next turn (the end of a fade that goes straight there among it) is done before the frame shows the tree, as on a desktop.
    node(long id)
    The node with id id in the tree published last.
    node(String name)
    The node named name in the tree published last.
    boolean
    perform(long nodeId, Accessible.Action action, Accessible.Argument arg)
    Performs a verb the way a platform does: from another thread, through the host, then drains the runtime and renders a frame so the tree shows what the verb did.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AccessibleHarness

      public AccessibleHarness(UiRuntime runtime, Widget<?> root)
      Binds root and renders the first frame, so that tree() answers at once.
      Parameters:
      runtime - the installed runtime, whose queue a performed verb is drained through
      root - what to bind; a widget, or a box around one
    • AccessibleHarness

      public AccessibleHarness(UiRuntime runtime, Widget<?> root, StubWindow window)
      Binds root in window: a stub that cannot position lets a popup open as an overlay of the scene, where the tree can see it, rather than as a window of its own.
      Parameters:
      runtime - the installed runtime, whose queue a performed verb is drained through
      root - what to bind
      window - the window to bind in; its accessibility bridge is replaced by this harness's
  • Method Details

    • frame

      public void frame()
      One turn of a backend's loop: the UI queue drained, then one frame rendered at the current scene time, so that what the toolkit leaves for the next turn (the end of a fade that goes straight there among it) is done before the frame shows the tree, as on a desktop.
    • advanceTime

      public void advanceTime(long millis, @Nullable Widget<?> damage)
      Moves scene time forward in steps no longer than the scene's own tick, damaging damage before each frame so that an animation on it advances: one turn of the loop, the queue drained and a frame rendered (frame()), for each step. The runtime's delayed tasks fall due on the same clock, so a timer and a fade's waiting arrival run as their time passes.
      Parameters:
      millis - how far to move
      damage - the widget to invalidate each frame, or null
    • clearObservations

      public void clearObservations()
      Forgets the events and changes seen so far; the trees stay.
    • tree

      public AccessibleTree tree()
      Returns:
      the tree published last
    • focus

      public void focus(Widget<?> widget)
      Gives widget the keyboard and renders a frame, so the cursor is published.
    • perform

      public boolean perform(long nodeId, Accessible.Action action, Accessible.Argument arg)
      Performs a verb the way a platform does: from another thread, through the host, then drains the runtime and renders a frame so the tree shows what the verb did.
      Parameters:
      nodeId - the node addressed
      action - the verb
      arg - its argument, or Accessible.Argument.NONE
      Returns:
      what the host answered: whether the verb was accepted
    • node

      public AccessibleNode node(String name)
      The node named name in the tree published last.
      Throws:
      AssertionError - with the whole tree when there is none
    • node

      public AccessibleNode node(long id)
      The node with id id in the tree published last.
      Throws:
      AssertionError - with the whole tree when there is none
    • describe

      public String describe()
      Returns:
      the tree published last, one line per node, for a message