TuiTester.run constructor

TuiTester.run(
  1. Future<Object?> body(), {
  2. int width = 80,
  3. int height = 24,
  4. ColorProfile profile = ColorProfile.noColor,
  5. bool darkBackground = true,
  6. Map<String, String> environment = const {},
  7. List<ProgramOption> options = const [],
})

Runs body, and drives each Program it creates and starts, one after another. Programs created outside body do not use this tester.

Use it for code that makes its own program, such as promptSelect, Form.run or your app's main flow. TuiResult.value is what body returns.

Implementation

TuiTester.run(
  Future<Object?> Function() body, {
  this.width = 80,
  this.height = 24,
  ColorProfile profile = ColorProfile.noColor,
  bool darkBackground = true,
  Map<String, String> environment = const {},
  List<ProgramOption> options = const [],
}) {
  _savedProfile = Style.defaultProfile;
  _savedDark = Style.hasDarkBackground;
  Style.defaultProfile = profile;
  Style.hasDarkBackground = darkBackground;
  final hook = _Hook(this, [
    withInput(null),
    withoutRenderer(),
    withoutSignalHandler(),
    withPlainMode(false),
    withEnvironment(environment),
    withColorProfile(profile),
    (program) => withWindowSize(width, height)(program),
    withFps(120),
    ...options,
  ]);
  _run = Future<Object?>.sync(
    () => runZoned(body, zoneValues: {programTestHookKey: hook}),
  ).whenComplete(_ended);
  // A failing run is reported by press, waitFor, quit, done and dispose.
  unawaited(_run.then((_) {}, onError: (Object _) {}));
}