mirror of
https://github.com/slint-ui/slint.git
synced 2025-08-31 07:37:24 +00:00

Move code around and gate the internal functions used in our own tests so we can make the testing backend public
33 lines
1.2 KiB
Rust
33 lines
1.2 KiB
Rust
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.2 OR LicenseRef-Slint-commercial
|
|
|
|
#![doc = include_str!("README.md")]
|
|
#![doc(html_logo_url = "https://slint.dev/logo/slint-logo-square-light.svg")]
|
|
|
|
mod search_api;
|
|
pub use search_api::*;
|
|
#[cfg(feature = "internal")]
|
|
mod internal_tests;
|
|
#[cfg(feature = "internal")]
|
|
pub use internal_tests::*;
|
|
mod testing_backend;
|
|
#[cfg(feature = "internal")]
|
|
pub use testing_backend::*;
|
|
|
|
/// Initialize the testing backend.
|
|
/// Must be called before any call that would otherwise initialize the rendering backend.
|
|
/// Calling it when the rendering backend is already initialized will have no effects
|
|
pub fn init() {
|
|
i_slint_core::platform::set_platform(
|
|
Box::new(testing_backend::TestingBackend::new_no_thread()),
|
|
)
|
|
.expect("platform already initialized");
|
|
}
|
|
|
|
/// Initialize the testing backend with support for simple event loop.
|
|
/// This function can only be called once per process, so make sure to use integration
|
|
/// tests with one `#[test]` function.
|
|
pub fn init_with_event_loop() {
|
|
i_slint_core::platform::set_platform(Box::new(testing_backend::TestingBackend::new()))
|
|
.expect("platform already initialized");
|
|
}
|