{"record":{"id":"a4469e56438c3f8f","repo":"slint-ui/slint","slug":"the-testing-backend-must-be-initialized-first","errorCode":null,"errorMessage":"the testing backend must be initialized first","messagePattern":"the testing backend must be initialized first","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backends/testing/lib.rs","lineNumber":94,"sourceCode":"            threading: true,\n            ..Default::default()\n        },\n    )))\n    .expect(\"platform already initialized\");\n}\n\n/// Advance the simulated mock time by the specified duration. Use in combination with\n/// [`init_integration_test_with_mock_time()`] or [`init_no_event_loop()`].\n#[cfg(not(feature = \"internal\"))]\npub fn mock_elapsed_time(duration: std::time::Duration) {\n    testing_backend::mock_elapsed_time(duration.as_millis() as _);\n}\n\n/// Set the system accent color, as a platform backend would when the OS theme changes.\n/// Must be called after initializing the testing backend (e.g. after [`init_no_event_loop()`]).\npub fn set_system_accent_color(color: i_slint_core::Color) {\n    i_slint_core::context::with_global_context(\n        || panic!(\"the testing backend must be initialized first\"),\n        |ctx| ctx.set_accent_color(color),\n    )\n    .unwrap();\n}\n\n/// Replace the font collection with embedded NotoSans fonts for deterministic test results.\n/// Must be called after initializing the testing backend (e.g. after [`init_no_event_loop()`]).\n#[cfg(feature = \"internal\")]\npub fn configure_test_fonts() {\n    use i_slint_common::sharedfontique::{FALLBACK_FAMILIES, fontique};\n\n    // Listed explicitly, in the order they take in the fallback chain: NotoSans-Regular is\n    // the default upright face and comes first. Embedding the whole directory instead would\n    // make the chain depend on filesystem iteration order, and would pull in whatever else\n    // lives there - the `.license` files, `convert.sh`, and the gitignored upstream fonts\n    // that script downloads into a subdirectory.\n    static FONTS: &[&[u8]] = &[\n        include_bytes!(\"../../../tests/screenshots/fonts/NotoSans-Regular.ttf\"),","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/backends/testing/lib.rs#L76-L112","documentation":"set_system_accent_color can only forward the accent color through the testing backend's platform, and that platform exists only after one of the init functions ran. This panic fires when the test calls set_system_accent_color before initializing the testing backend (or after it was replaced), i.e. an ordering bug in the test setup rather than a data problem.","triggerScenarios":"Thrown at internal/backends/testing/lib.rs:94 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Call i_slint_backend_testing::init() or init_no_event_loop() (or init_integration_test_with_mock_time) before set_system_accent_color","Ensure no other platform backend was initialized first; slint::platform::set_platform only succeeds once per process","In tests, initialize the testing backend in a setup/before-each hook and keep a single initialization per process"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}