nano-ui
Safe HaskellNone
LanguageGHC2024

NanoUI.Testing.Harness

Description

Shared helpers for integration tests: input gestures, spans, scroll checks.

Synopsis

Documentation

keyInp :: Key -> Input -> Input Source #

A single key-down frame.

tabInp :: Input -> Input Source #

Step the tab focus to the next focusable.

warmup :: Context -> Input -> NanoUI a -> IO () Source #

held :: forall (es :: [Effect]) a r. Ui :> es => IORef a -> (a -> Eff es (r, a)) -> Eff es (r, a) Source #

Drive a controlled input the way an application does: pass the value held in the test's IORef and store the widget's result for the next frame. Not a hook: a hook write makes the frame run the view again without input, and the frame then returns that pass's result without its click or change flags.

runClick :: Context -> Input -> NanoUI a -> V2 -> IO a Source #

Run a press frame and a release frame at pos (clickPair), returning the release frame's result.

assertSpansHas :: HasCallStack => IORef Int -> Text -> [(Rect, Text, a, b, c)] -> IO () Source #

spanYOf :: Text -> [(Rect, Text, a, b, c)] -> [Float] Source #

spanXOf :: Text -> [(Rect, Text, a, b, c)] -> [Float] Source #

runDragFrom :: Context -> Input -> NanoUI a -> V2 -> V2 -> IO () Source #

hasText :: Text -> [(Rect, Text, a, b, c)] -> Bool Source #

expectText :: String -> Text -> [(Rect, Text, a, b, c)] -> IO () Source #

Fail with msg unless a span contains needle.

clickPos :: (Input -> IO ()) -> Input -> V2 -> IO () Source #

Press, hold and release at pos, then two idle frames.

clickTab :: (Context -> IO [DemoSpan]) -> (Input -> IO ()) -> Context -> Input -> Text -> IO () Source #

dragPos :: (Input -> IO ()) -> Input -> V2 -> V2 -> IO () Source #

Press at from, hold at to and release there, then two idle frames.

drawQuads :: DrawData -> IO [(Rect, Color)] Source #

Decode the quads a frame actually rasterised: one (rect, color) per six-index quad, in draw order. Span and arena queries cannot see chrome (scroller wells, scrollbar lanes); this can. Every rasterised op in the draw arena is emitted as 4 vertices / 6 indices; a command that breaks that packing fails loudly here instead of decoding garbage.