| Safe Haskell | None |
|---|---|
| Language | GHC2024 |
NanoUI.Testing.Harness
Description
Shared helpers for integration tests: input gestures, spans, scroll checks.
Synopsis
- clickPair :: Input -> V2 -> (Input, Input)
- rightClickPair :: Input -> V2 -> (Input, Input)
- pressAt :: Input -> V2 -> Input
- releaseAt :: Input -> Input
- keyInp :: Key -> Input -> Input
- tabInp :: Input -> Input
- withInputOff :: Float -> Float -> Input
- withDelta :: Float -> Float -> Float -> Input
- centerOf :: Response -> V2
- warmup :: Context -> Input -> NanoUI a -> IO ()
- warmup2 :: Context -> Input -> NanoUI a -> IO a
- warmupDraw :: Context -> Input -> NanoUI a -> IO (a, DrawData)
- held :: forall (es :: [Effect]) a r. Ui :> es => IORef a -> (a -> Eff es (r, a)) -> Eff es (r, a)
- runClick :: Context -> Input -> NanoUI a -> V2 -> IO a
- assertSpansHas :: HasCallStack => IORef Int -> Text -> [(Rect, Text, a, b, c)] -> IO ()
- spanYOf :: Text -> [(Rect, Text, a, b, c)] -> [Float]
- spanXOf :: Text -> [(Rect, Text, a, b, c)] -> [Float]
- assertScrollGutterPad :: HasCallStack => IORef Int -> Context -> WidgetId -> Response -> Float -> Float -> IO ()
- assertWheelTitlePinned :: HasCallStack => IORef Int -> Context -> Input -> NanoUI a -> Text -> Text -> V2 -> Maybe Float -> IO ()
- findGrabHover :: Context -> NanoUI a -> Input -> Float -> [Float] -> IO (Maybe Input)
- dragWindowEdge :: Context -> Input -> NanoUI Response -> V2 -> V2 -> IO (Maybe Rect)
- vertUv :: DrawData -> Int -> IO (Float, Float)
- checkLabelAlignEndInk :: IORef Int -> IO ()
- checkIdleFullDamage :: HasCallStack => IORef Int -> Context -> Input -> Input -> NanoUI a -> IO ()
- windowTitleGrab :: Rect -> V2
- runDragFrom :: Context -> Input -> NanoUI a -> V2 -> V2 -> IO ()
- type DemoSpan = (Rect, Text, Color, Color, Rect)
- spanCenter :: Rect -> V2
- hasText :: Text -> [(Rect, Text, a, b, c)] -> Bool
- spanLabel :: Text -> Text
- findExact :: Text -> [DemoSpan] -> Maybe V2
- findHeader :: Text -> [DemoSpan] -> Maybe V2
- findRightmost :: Text -> [DemoSpan] -> Maybe V2
- requireSpan :: String -> Maybe V2 -> IO V2
- expectText :: String -> Text -> [(Rect, Text, a, b, c)] -> IO ()
- clickPos :: (Input -> IO ()) -> Input -> V2 -> IO ()
- clickTab :: (Context -> IO [DemoSpan]) -> (Input -> IO ()) -> Context -> Input -> Text -> IO ()
- dragPos :: (Input -> IO ()) -> Input -> V2 -> V2 -> IO ()
- drawQuads :: DrawData -> IO [(Rect, Color)]
Documentation
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 #
assertScrollGutterPad :: HasCallStack => IORef Int -> Context -> WidgetId -> Response -> Float -> Float -> IO () Source #
assertWheelTitlePinned :: HasCallStack => IORef Int -> Context -> Input -> NanoUI a -> Text -> Text -> V2 -> Maybe Float -> IO () Source #
checkIdleFullDamage :: HasCallStack => IORef Int -> Context -> Input -> Input -> NanoUI a -> IO () Source #
windowTitleGrab :: Rect -> V2 Source #
spanCenter :: Rect -> V2 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.