applyTestTheme function

Future<void> applyTestTheme({
  1. required EnsembleTestContext context,
  2. required String? theme,
  3. required Future<void> pump(),
})

Applies the shared environment and runtime theme state.

Adapters provide their own frame-pump callback so this mutation preserves their existing widget lifecycle boundary.

Implementation

Future<void> applyTestTheme({
  required EnsembleTestContext context,
  required String? theme,
  required Future<void> Function() pump,
}) async {
  if (theme == null || theme.trim().isEmpty) return;
  context.setEnv('APP_THEME', theme);
  final applied = applyEnsembleTestTheme(theme);
  context.runtime.themeMode = applied ?? theme;
  if (applied != null) await pump();
}