{"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    use include_dir::{Dir, include_dir};\n\n    static FONTS_DIR: Dir = include_dir!(\"$CARGO_MANIFEST_DIR/../../../tests/screenshots/fonts\");\n    // Pin the primary by name so its position in the fallback chain doesn't depend on\n    // filesystem iteration order. NotoSans-Regular wins as the default upright face.\n    const PRIMARY: &str = \"NotoSans-Regular.ttf\";\n\n    i_slint_core::with_global_context(","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/slint-ui/slint/blob/3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016/internal/backends/testing/lib.rs#L76-L112","documentation":"Error \"the testing backend must be initialized first\" thrown in slint-ui/slint.","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() before using testing backend functions.","Ensure the test binary links the testing backend and initializes it at startup."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3fd8f2ec03c2aa8a95d5f4b9daa299c7b8bf4016","analyzedAt":"2026-08-19T23:23:16.610Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}