FleuryTester constructor
FleuryTester({
- AnimationPolicy animationPolicy = AnimationPolicy.enabled,
- CellSize viewportSize = const CellSize(80, 24),
- ColorMode colorMode = ColorMode.truecolor,
- GlyphTier glyphTier = GlyphTier.unicode,
- InlineImageSupport images = InlineImageSupport.none,
- TextPresentationPolicy textPolicy = TextPresentationPolicy.spec,
- bool overlayRepaintBoundaries = true,
- Clipboard? clipboard,
- InputParser? terminalParser,
- FleuryTestFailureHandler failureHandler = _throwFleuryTestFailure,
Constructs a tester with fresh, isolated framework pieces.
Tests typically don't call this directly โ use testWidgets from
package:fleury_test.
Implementation
FleuryTester({
AnimationPolicy animationPolicy = AnimationPolicy.enabled,
CellSize viewportSize = const CellSize(80, 24),
ColorMode colorMode = ColorMode.truecolor,
GlyphTier glyphTier = GlyphTier.unicode,
InlineImageSupport images = InlineImageSupport.none,
TextPresentationPolicy textPolicy = TextPresentationPolicy.spec,
this.overlayRepaintBoundaries = true,
Clipboard? clipboard,
InputParser? terminalParser,
FleuryTestFailureHandler failureHandler = _throwFleuryTestFailure,
}) : _terminalParser = terminalParser,
clipboard = clipboard ?? InProcessClipboard(),
_viewportSize = viewportSize,
_colorMode = colorMode,
_glyphTier = glyphTier,
_images = images,
_textPolicy = textPolicy,
_failureHandler = failureHandler,
_clock = FakeClock(),
_focusManager = FocusManager() {
_scheduler = FakeTickerScheduler(clock: _clock);
_binding = TuiBinding(
tickerScheduler: _scheduler,
animationPolicy: animationPolicy,
);
_dispatcher = InputDispatcher(
focusManager: _focusManager,
pointerRouter: _pointerRouter,
);
// The latch is wired by the one function every host uses, and published
// from the same two places production publishes it: the ticker clock at
// frame start (inside `installKeyboardLatch`), the frame clock from
// [render] โ the harness analog of `FrameDriver.onLatchInput` (RFC 0020
// ยง5.6). The harness must never publish it through a seam of its own:
// it did for a while, from `TickerScheduler.onFrameStart` alone, which
// meant no widget test could see a render expiring a sampled edge โ
// renders in here did not latch at all.
_publishFrameLatch = installKeyboardLatch(
session: _dispatcher.keyboardSession,
scheduler: _scheduler,
);
_keyboardNotifier = KeyboardStateNotifier(_dispatcher);
// The runtime's error panel, for a test that opts back into containment.
// Per-owner, so a test customizing hooks can't leak into the next test.
_owner = BuildOwner(
errorBuilder: (error, stack) => ErrorWidget.builder(error, stack),
);
// Containment inverts for tests: a bug in build, a lifecycle hook,
// layout, or paint should FAIL the test loudly, not render a red panel
// behind passing assertions. A containment test opts back in with
// `owner.rethrowContainedErrors = false`; a test of one boundary's
// layout/paint containment can use `ErrorBoundary(rethrowContained:
// false)` instead, which does not affect build errors.
_owner.rethrowContainedErrors = true;
_owner.onScheduleBuild = _scheduleActionFrame;
_owner.renderDamageTracker.onInvalidate = _scheduleActionFrame;
_binding.onPostFrameCallback = _scheduleActionFrame;
// Off by default in tests so it doesn't perturb golden output; an
// overflow-specific test opts back in.
RenderFlex.debugShowOverflow = false;
}