fix doctests

This commit is contained in:
Lucas Nogueira
2026-03-10 18:46:14 -03:00
parent cc0464a5c7
commit 68942c485e
11 changed files with 271 additions and 101 deletions

View File

@@ -176,7 +176,7 @@ cargo_toml = "0.22"
http-range = "0.1.5"
[features]
default = ["compression", "common-controls-v6", "dynamic-acl"]
default = ["compression", "common-controls-v6", "dynamic-acl", "test"]
unstable = []
macos-proxy = []
common-controls-v6 = [

View File

@@ -449,7 +449,9 @@ impl<R: Runtime> AppHandle<R> {
/// PluginBuilder::new("dummy").build()
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(move |app| {
/// let handle = app.handle().clone();
/// std::thread::spawn(move || {
@@ -490,7 +492,9 @@ impl<R: Runtime> AppHandle<R> {
/// let plugin = init_plugin();
/// // `.name()` requires the `Plugin` trait import
/// let plugin_name = plugin.name();
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .plugin(plugin)
/// .setup(move |app| {
/// let handle = app.handle().clone();
@@ -563,7 +567,9 @@ impl<R: Runtime> AppHandle<R> {
///
/// # Examples
/// ```,no_run
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(move |app| {
/// #[cfg(target_os = "macos")]
/// app.handle().set_activation_policy(tauri::ActivationPolicy::Accessory);
@@ -583,7 +589,9 @@ impl<R: Runtime> AppHandle<R> {
///
/// # Examples
/// ```,no_run
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(move |app| {
/// #[cfg(target_os = "macos")]
/// app.handle().set_dock_visibility(false);
@@ -1013,7 +1021,9 @@ macro_rules! shared_app_impl {
/// ```
/// use tauri::Listener;
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// app.listen("component-loaded", move |event| {
/// println!("window just loaded a component");
@@ -1048,7 +1058,9 @@ macro_rules! shared_app_impl {
/// ```
/// use tauri::Listener;
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let handler = app.listen("component-loaded", move |event| {
/// println!("app just loaded a component");
@@ -1111,7 +1123,9 @@ impl<R: Runtime> App<R> {
///
/// # Examples
/// ```,no_run
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(move |app| {
/// #[cfg(target_os = "macos")]
/// app.set_activation_policy(tauri::ActivationPolicy::Accessory);
@@ -1132,7 +1146,9 @@ impl<R: Runtime> App<R> {
///
/// # Examples
/// ```,no_run
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(move |app| {
/// #[cfg(target_os = "macos")]
/// app.set_dock_visibility(false);
@@ -1161,7 +1177,9 @@ impl<R: Runtime> App<R> {
///
/// # Examples
/// ```,no_run
/// let mut app = tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// let mut app = tauri::Builder::<TauriRuntime>::new()
/// // on an actual app, remove the string argument
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
/// .expect("error while building tauri application");
@@ -1189,7 +1207,9 @@ impl<R: Runtime> App<R> {
///
/// # Examples
/// ```,no_run
/// let app = tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// let app = tauri::Builder::<TauriRuntime>::new()
/// // on an actual app, remove the string argument
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
/// .expect("error while building tauri application");
@@ -1225,7 +1245,9 @@ impl<R: Runtime> App<R> {
///
/// # Examples
/// ```,no_run
/// let app = tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// let app = tauri::Builder::<TauriRuntime>::new()
/// // on an actual app, remove the string argument
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
/// .expect("error while building tauri application");
@@ -1288,7 +1310,9 @@ impl<R: Runtime> App<R> {
/// ```no_run
/// use tauri::Manager;
///
/// let mut app = tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// let mut app = tauri::Builder::<TauriRuntime>::new()
/// // on an actual app, remove the string argument
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
/// .expect("error while building tauri application");
@@ -1328,7 +1352,9 @@ impl<R: Runtime> App<R> {
///
/// # Examples
/// ```,no_run
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// // on an actual app, remove the string argument
/// .run(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
/// .expect("error while running tauri application");
@@ -1530,7 +1556,9 @@ impl<R: Runtime> Builder<R> {
/// fn command_1() -> String {
/// return "hello world".to_string();
/// }
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .invoke_handler(tauri::generate_handler![
/// command_1,
/// // etc...
@@ -1621,7 +1649,9 @@ impl<R: Runtime> Builder<R> {
/// }
/// "#;
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .append_invoke_initialization_script(custom_script);
/// ```
pub fn append_invoke_initialization_script(
@@ -1642,7 +1672,9 @@ impl<R: Runtime> Builder<R> {
doc = r####"
```
use tauri::Manager;
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let main_window = app.get_webview_window("main").unwrap();
main_window.set_title("Tauri!")?;
@@ -1708,7 +1740,9 @@ tauri::Builder::<tauri::Wry>::new()
/// }
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .plugin(plugin::init());
/// ```
#[must_use]
@@ -1769,7 +1803,9 @@ tauri::Builder::<tauri::Wry>::new()
/// storage.store.lock().unwrap().insert(key, value);
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .manage(Storage { store: Default::default() })
/// .manage(DbConnection { db: Default::default() })
/// .invoke_handler(tauri::generate_handler![connect, storage_insert])
@@ -1796,7 +1832,9 @@ tauri::Builder::<tauri::Wry>::new()
/// println!("state: {}", state.inner().0);
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .manage(MyInt(10))
/// .manage(MyString("Hello, managed state!".to_string()))
/// .invoke_handler(tauri::generate_handler![int_command, string_command])
@@ -1823,7 +1861,9 @@ tauri::Builder::<tauri::Wry>::new()
/// ```
/// use tauri::menu::{Menu, MenuItem, PredefinedMenuItem, Submenu};
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .menu(|handle| Menu::with_items(handle, &[
/// &Submenu::with_items(
/// handle,
@@ -1853,7 +1893,9 @@ tauri::Builder::<tauri::Wry>::new()
/// ```
/// use tauri::menu::*;
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .on_menu_event(|app, event| {
/// if event.id() == "quit" {
/// app.exit(0);
@@ -1876,7 +1918,9 @@ tauri::Builder::<tauri::Wry>::new()
/// ```
/// use tauri::Manager;
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .on_tray_icon_event(|app, event| {
/// let tray = app.tray_by_id(event.id()).expect("can't find tray icon");
/// let _ = tray.set_visible(false);
@@ -1897,7 +1941,9 @@ tauri::Builder::<tauri::Wry>::new()
///
/// # Examples
/// ```
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .enable_macos_default_menu(false);
/// ```
#[must_use]
@@ -1910,7 +1956,9 @@ tauri::Builder::<tauri::Wry>::new()
///
/// # Examples
/// ```
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .on_window_event(|window, event| match event {
/// tauri::WindowEvent::Focused(focused) => {
/// // hide window whenever it loses focus
@@ -1934,7 +1982,9 @@ tauri::Builder::<tauri::Wry>::new()
///
/// # Examples
/// ```
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .on_webview_event(|window, event| match event {
/// tauri::WebviewEvent::DragDrop(event) => {
/// println!("{:?}", event);
@@ -1964,7 +2014,9 @@ tauri::Builder::<tauri::Wry>::new()
///
/// # Examples
/// ```
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .register_uri_scheme_protocol("app-files", |_ctx, request| {
/// // skip leading `/`
/// if let Ok(data) = std::fs::read(&request.uri().path()[1..]) {
@@ -2025,7 +2077,9 @@ tauri::Builder::<tauri::Wry>::new()
///
/// # Examples
/// ```
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .register_asynchronous_uri_scheme_protocol("app-files", |_ctx, request, responder| {
/// // skip leading `/`
/// let path = request.uri().path()[1..].to_string();
@@ -2089,7 +2143,9 @@ tauri::Builder::<tauri::Wry>::new()
///
/// # Examples
/// ```,no_run
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .device_event_filter(tauri::DeviceEventFilter::Always);
/// ```
///

View File

@@ -234,7 +234,9 @@ fn default_runtime() -> GlobalRuntime {
/// tauri::async_runtime::set(tokio::runtime::Handle::current());
///
/// // bootstrap the tauri app...
/// // tauri::Builder::<tauri::Wry>::new().run().unwrap();
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// // # type TauriRuntime = tauri::test::MockRuntime;
/// // tauri::Builder::<TauriRuntime>::new().run().unwrap();
/// }
///
/// async fn do_something() {}

View File

@@ -581,7 +581,9 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
/// storage.store.lock().unwrap().insert(key, value);
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .manage(Storage { store: Default::default() })
/// .manage(DbConnection { db: Default::default() })
/// .invoke_handler(tauri::generate_handler![connect, storage_insert])
@@ -608,7 +610,9 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
/// println!("state: {}", state.inner().0);
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// app.manage(MyInt(0));
/// app.manage(MyString("tauri".into()));
@@ -719,7 +723,9 @@ pub trait Manager<R: Runtime>: sealed::ManagerBase<R> {
/// ```
/// use tauri::Manager;
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// #[cfg(feature = "beta")]
/// app.add_capability(include_str!("../capabilities/beta/cap.json"));
@@ -771,12 +777,14 @@ pub trait Listener<R: Runtime>: sealed::ManagerBase<R> {
/// use tauri::{Manager, Listener, Emitter};
///
/// #[tauri::command]
/// fn synchronize(window: tauri::Window) {
/// fn synchronize(window: tauri::Window<tauri::test::MockRuntime>) {
/// // emits the synchronized event to all windows
/// window.emit("synchronized", ());
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// app.listen("synchronized", |event| {
/// println!("app is in sync");
@@ -806,7 +814,9 @@ pub trait Listener<R: Runtime>: sealed::ManagerBase<R> {
/// ```
/// use tauri::{Manager, Listener};
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let handle = app.handle().clone();
/// let handler = app.listen_any("ready", move |event| {
@@ -833,12 +843,14 @@ pub trait Listener<R: Runtime>: sealed::ManagerBase<R> {
/// use tauri::{Manager, Emitter, Listener};
///
/// #[tauri::command]
/// fn synchronize(window: tauri::Window) {
/// fn synchronize(window: tauri::Window<tauri::test::MockRuntime>) {
/// // emits the synchronized event to all windows
/// window.emit("synchronized", ());
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// app.listen_any("synchronized", |event| {
/// println!("app is in sync");
@@ -880,7 +892,7 @@ pub trait Emitter<R: Runtime>: sealed::ManagerBase<R> {
/// use tauri::Emitter;
///
/// #[tauri::command]
/// fn synchronize(app: tauri::AppHandle) {
/// fn synchronize(app: tauri::AppHandle<tauri::test::MockRuntime>) {
/// // emits the synchronized event to all webviews
/// app.emit("synchronized", ());
/// }
@@ -905,7 +917,7 @@ pub trait Emitter<R: Runtime>: sealed::ManagerBase<R> {
/// use tauri::{Emitter, EventTarget};
///
/// #[tauri::command]
/// fn download(app: tauri::AppHandle) {
/// fn download(app: tauri::AppHandle<tauri::test::MockRuntime>) {
/// for i in 1..100 {
/// std::thread::sleep(std::time::Duration::from_millis(150));
/// // emit a download progress event to all listeners
@@ -947,7 +959,7 @@ pub trait Emitter<R: Runtime>: sealed::ManagerBase<R> {
/// use tauri::{Emitter, EventTarget};
///
/// #[tauri::command]
/// fn download(app: tauri::AppHandle) {
/// fn download(app: tauri::AppHandle<tauri::test::MockRuntime>) {
/// for i in 1..100 {
/// std::thread::sleep(std::time::Duration::from_millis(150));
/// // emit a download progress event to the updater window

View File

@@ -14,7 +14,9 @@ use crate::{Manager, Runtime, image::Image, menu::*};
///
/// ```no_run
/// use tauri::menu::*;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(move |app| {
/// let handle = app.handle();
/// # let icon1 = tauri::image::Image::new(&[], 0, 0);
@@ -85,7 +87,9 @@ impl<'m, R: Runtime, M: Manager<R>> MenuBuilder<'m, R, M> {
///
/// ```no_run
/// use tauri::menu::*;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(move |app| {
/// let handle = app.handle();
/// # let icon1 = tauri::image::Image::new(&[], 0, 0);

View File

@@ -253,7 +253,9 @@ impl<R: Runtime> PathResolver<R> {
///
/// ```rust,no_run
/// use tauri::{path::BaseDirectory, Manager};
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let path = app.path().resolve("path/to/something", BaseDirectory::Config)?;
/// assert_eq!(path.to_str().unwrap(), "/home/${whoami}/.config/path/to/something");
@@ -270,7 +272,9 @@ impl<R: Runtime> PathResolver<R> {
///
/// ```rust,no_run
/// use tauri::Manager;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let path = app.path().parse("$HOME/.bashrc")?;
/// assert_eq!(path.to_str().unwrap(), "/home/${whoami}/.bashrc");

View File

@@ -37,7 +37,9 @@ use std::path::PathBuf;
/// use tauri::{process::current_binary, Env, Manager};
/// let current_binary_path = current_binary(&Env::default()).unwrap();
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let current_binary_path = current_binary(&app.env())?;
/// Ok(())
@@ -65,7 +67,9 @@ pub fn current_binary(_env: &Env) -> std::io::Result<PathBuf> {
/// ```rust,no_run
/// use tauri::{process::restart, Env, Manager};
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// restart(&app.env());
/// Ok(())

View File

@@ -27,8 +27,8 @@
//! }
//!
//! fn main() {
//! // Use `tauri::Builder::<tauri::Wry>::new()` to use the default runtime rather than the `MockRuntime`;
//! // let app = create_app(tauri::Builder::<tauri::Wry>::new());
//! // To use a real runtime (e.g. wry), add tauri-runtime-wry and use:
//! // let app = create_app(tauri::Builder::<tauri_runtime_wry::Wry<tauri::EventLoopMessage>>::new());
//! let app = create_app(mock_builder());
//! let webview = tauri::WebviewWindowBuilder::new(&app, "main", Default::default()).build().unwrap();
//!
@@ -156,7 +156,9 @@ pub fn mock_context<R: Runtime, A: Assets<R>>(assets: A) -> crate::Context<R> {
/// ```rust
/// #[cfg(test)]
/// fn do_something() {
/// let app = tauri::test::mock_builder()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// let app = tauri::Builder::<TauriRuntime>::new()
/// // remove the string argument to use your app's config file
/// .build(tauri::generate_context!("test/fixture/src-tauri/tauri.conf.json"))
/// .unwrap();

View File

@@ -213,7 +213,9 @@ impl<R: Runtime> WebviewBuilder<R> {
feature = "unstable",
doc = r####"
```
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = tauri::window::WindowBuilder::new(app, "label").build()?;
let webview_builder = tauri::webview::WebviewBuilder::new("label", tauri::WebviewUrl::App("index.html".into()));
@@ -230,7 +232,9 @@ tauri::Builder::<tauri::Wry>::new()
feature = "unstable",
doc = r####"
```
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let handle = app.handle().clone();
std::thread::spawn(move || {
@@ -251,7 +255,7 @@ tauri::Builder::<tauri::Wry>::new()
doc = r####"
```
#[tauri::command]
async fn create_window(app: tauri::AppHandle) {
async fn create_window(app: tauri::AppHandle<tauri::test::MockRuntime>) {
let window = tauri::window::WindowBuilder::new(&app, "label").build().unwrap();
let webview_builder = tauri::webview::WebviewBuilder::new("label", tauri::WebviewUrl::External("https://tauri.app/".parse().unwrap()));
window.add_child(webview_builder, tauri::LogicalPosition::new(0, 0), window.inner_size().unwrap());
@@ -295,7 +299,7 @@ async fn create_window(app: tauri::AppHandle) {
doc = r####"
```
#[tauri::command]
async fn create_window(app: tauri::AppHandle) {
async fn create_window(app: tauri::AppHandle<tauri::test::MockRuntime>) {
let window = tauri::window::WindowBuilder::new(&app, "label").build().unwrap();
let webview_builder = tauri::webview::WebviewBuilder::from_config(&app.config().app.windows.get(0).unwrap().clone());
window.add_child(webview_builder, tauri::LogicalPosition::new(0, 0), window.inner_size().unwrap());
@@ -384,7 +388,9 @@ use tauri::{
};
use http::header::HeaderValue;
use std::collections::HashMap;
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = tauri::window::WindowBuilder::new(app, "label").build()?;
@@ -436,7 +442,9 @@ use tauri::{
};
use http::header::HeaderValue;
use std::collections::HashMap;
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = tauri::window::WindowBuilder::new(app, "label").build()?;
@@ -483,7 +491,9 @@ use tauri::{
};
use http::header::HeaderValue;
use std::collections::HashMap;
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = tauri::window::WindowBuilder::new(app, "label").build()?;
@@ -560,7 +570,9 @@ use tauri::{
webview::{DownloadEvent, WebviewBuilder},
};
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = WindowBuilder::new(app, "label").build()?;
let webview_builder = WebviewBuilder::new("core", WebviewUrl::App("index.html".into()))
@@ -610,7 +622,9 @@ use tauri::{
};
use http::header::HeaderValue;
use std::collections::HashMap;
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = tauri::window::WindowBuilder::new(app, "label").build()?;
let webview_builder = WebviewBuilder::new("core", WebviewUrl::App("index.html".into()))
@@ -826,7 +840,9 @@ const INIT_SCRIPT: &str = r#"
"#;
fn main() {
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = tauri::window::WindowBuilder::new(app, "label").build()?;
let webview_builder = tauri::webview::WebviewBuilder::new("label", tauri::WebviewUrl::App("index.html".into()))
@@ -885,7 +901,9 @@ const INIT_SCRIPT: &str = r#"
"#;
fn main() {
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = tauri::window::WindowBuilder::new(app, "label").build()?;
let webview_builder = tauri::webview::WebviewBuilder::new("label", tauri::WebviewUrl::App("index.html".into()))
@@ -1345,7 +1363,9 @@ impl<R: Runtime> Webview<R> {
/// some_value: String,
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview = app.get_webview_window("main").unwrap();
/// let scope = webview.resolve_command_scope::<ScopeType>("my-plugin", "read");
@@ -1536,7 +1556,9 @@ impl<R: Runtime> Webview<R> {
```rust,no_run
use tauri::Manager;
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let main_webview = app.get_webview("main").unwrap();
main_webview.with_webview(|webview| {
@@ -1891,7 +1913,9 @@ tauri::Builder::<tauri::Wry>::new()
doc = r####"
```rust,no_run
use tauri::Manager;
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
#[cfg(debug_assertions)]
app.get_webview("main").unwrap().open_devtools();
@@ -1922,7 +1946,9 @@ tauri::Builder::<tauri::Wry>::new()
doc = r####"
```rust,no_run
use tauri::Manager;
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
#[cfg(debug_assertions)]
{
@@ -1960,7 +1986,9 @@ tauri::Builder::<tauri::Wry>::new()
doc = r####"
```rust,no_run
use tauri::Manager;
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
#[cfg(debug_assertions)]
{
@@ -2107,7 +2135,9 @@ impl<R: Runtime> Listener<R> for Webview<R> {
```
use tauri::{Manager, Listener};
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let webview = app.get_webview("main").unwrap();
webview.listen("component-loaded", move |event| {
@@ -2159,7 +2189,9 @@ tauri::Builder::<tauri::Wry>::new()
```
use tauri::{Manager, Listener};
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let webview = app.get_webview("main").unwrap();
let webview_ = webview.clone();

View File

@@ -65,7 +65,9 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
/// - Create a window in the setup hook:
///
/// ```
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview_window = tauri::WebviewWindowBuilder::new(app, "label", tauri::WebviewUrl::App("index.html".into()))
/// .build()?;
@@ -76,7 +78,9 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
/// - Create a window in a separate thread:
///
/// ```
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let handle = app.handle().clone();
/// std::thread::spawn(move || {
@@ -92,7 +96,7 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
///
/// ```
/// #[tauri::command]
/// async fn create_window(app: tauri::AppHandle) {
/// async fn create_window(app: tauri::AppHandle<tauri::test::MockRuntime>) {
/// let webview_window = tauri::WebviewWindowBuilder::new(&app, "label", tauri::WebviewUrl::App("index.html".into()))
/// .build()
/// .unwrap();
@@ -133,7 +137,7 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
///
/// ```
/// #[tauri::command]
/// async fn reopen_window(app: tauri::AppHandle) {
/// async fn reopen_window(app: tauri::AppHandle<tauri::test::MockRuntime>) {
/// let webview_window = tauri::WebviewWindowBuilder::from_config(&app, &app.config().app.windows.get(0).unwrap())
/// .unwrap()
/// .build()
@@ -145,7 +149,7 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
///
/// ```
/// #[tauri::command]
/// async fn open_window_multiple(app: tauri::AppHandle) {
/// async fn open_window_multiple(app: tauri::AppHandle<tauri::test::MockRuntime>) {
/// let mut conf = app.config().app.windows.iter().find(|c| c.label == "template-for-multiwindow").unwrap().clone();
/// // This should be a unique label for all windows. For example, we can use a random suffix:
/// let mut buf = [0u8; 1];
@@ -177,7 +181,9 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
/// # Examples
/// ```
/// use tauri::menu::{Menu, Submenu, MenuItem};
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let handle = app.handle();
/// let save_menu_item = MenuItem::new(handle, "Save", true, None::<&str>)?;
@@ -223,7 +229,9 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
/// };
/// use http::header::HeaderValue;
/// use std::collections::HashMap;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview_window = WebviewWindowBuilder::new(app, "core", WebviewUrl::App("index.html".into()))
/// .on_web_resource_request(|request, response| {
@@ -264,7 +272,9 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
/// };
/// use http::header::HeaderValue;
/// use std::collections::HashMap;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview_window = WebviewWindowBuilder::new(app, "core", WebviewUrl::App("index.html".into()))
/// .on_navigation(|url| {
@@ -311,7 +321,9 @@ impl<'a, R: Runtime, M: Manager<R>> WebviewWindowBuilder<'a, R, M> {
/// };
/// use http::header::HeaderValue;
/// use std::collections::HashMap;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let app_ = app.handle().clone();
/// let webview_window = WebviewWindowBuilder::new(app, "core", WebviewUrl::App("index.html".into()))
@@ -391,7 +403,9 @@ use tauri::{
webview::{DownloadEvent, WebviewWindowBuilder},
};
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let handle = app.handle();
let webview_window = WebviewWindowBuilder::new(handle, "core", WebviewUrl::App("index.html".into()))
@@ -436,7 +450,9 @@ tauri::Builder::<tauri::Wry>::new()
/// };
/// use http::header::HeaderValue;
/// use std::collections::HashMap;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview_window = WebviewWindowBuilder::new(app, "core", WebviewUrl::App("index.html".into()))
/// .on_page_load(|window, payload| {
@@ -965,7 +981,9 @@ impl<R: Runtime, M: Manager<R>> WebviewWindowBuilder<'_, R, M> {
/// "#;
///
/// fn main() {
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview = tauri::WebviewWindowBuilder::new(app, "label", tauri::WebviewUrl::App("index.html".into()))
/// .initialization_script(INIT_SCRIPT)
@@ -1007,7 +1025,9 @@ impl<R: Runtime, M: Manager<R>> WebviewWindowBuilder<'_, R, M> {
/// "#;
///
/// fn main() {
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview = tauri::WebviewWindowBuilder::new(app, "label", tauri::WebviewUrl::App("index.html".into()))
/// .initialization_script_for_all_frames(INIT_SCRIPT)
@@ -1274,7 +1294,9 @@ impl<R: Runtime, M: Manager<R>> WebviewWindowBuilder<'_, R, M> {
///
/// ```
/// fn main() {
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let mut builder = tauri::WebviewWindowBuilder::new(app, "label", tauri::WebviewUrl::App("index.html".into()));
/// #[cfg(target_os = "ios")]
@@ -1475,7 +1497,9 @@ impl<R: Runtime> WebviewWindow<R> {
/// some_value: String,
/// }
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview = app.get_webview_window("main").unwrap();
/// let scope = webview.resolve_command_scope::<ScopeType>("my-plugin", "read");
@@ -1508,7 +1532,9 @@ impl<R: Runtime> WebviewWindow<R> {
/// use tauri::menu::{Menu, Submenu, MenuItem};
/// use tauri::{WebviewWindowBuilder, WebviewUrl};
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let handle = app.handle();
/// let save_menu_item = MenuItem::new(handle, "Save", true, None::<&str>)?;
@@ -1946,7 +1972,9 @@ impl<R: Runtime> WebviewWindow<R> {
///
/// ```rust,no_run
/// use tauri::{Manager, window::{Color, Effect, EffectState, EffectsBuilder}};
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview_window = app.get_webview_window("main").unwrap();
/// webview_window.set_effects(
@@ -2221,11 +2249,13 @@ impl<R: Runtime> WebviewWindow<R> {
///
/// # Examples
///
/// ```rust,no_run
/// ```ignore
/// use tauri::Manager;
///
/// fn main() {
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let main_webview = app.get_webview_window("main").unwrap();
/// main_webview.with_webview(|webview| {
@@ -2337,7 +2367,9 @@ impl<R: Runtime> WebviewWindow<R> {
///
/// ```rust,no_run
/// use tauri::Manager;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// #[cfg(debug_assertions)]
/// app.get_webview_window("main").unwrap().open_devtools();
@@ -2363,7 +2395,9 @@ impl<R: Runtime> WebviewWindow<R> {
///
/// ```rust,no_run
/// use tauri::Manager;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// #[cfg(debug_assertions)]
/// {
@@ -2396,7 +2430,9 @@ impl<R: Runtime> WebviewWindow<R> {
///
/// ```rust,no_run
/// use tauri::Manager;
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// #[cfg(debug_assertions)]
/// {
@@ -2499,7 +2535,9 @@ impl<R: Runtime> Listener<R> for WebviewWindow<R> {
/// ```
/// use tauri::{Manager, Listener};
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview_window = app.get_webview_window("main").unwrap();
/// webview_window.listen("component-loaded", move |event| {
@@ -2546,7 +2584,9 @@ impl<R: Runtime> Listener<R> for WebviewWindow<R> {
/// ```
/// use tauri::{Manager, Listener};
///
/// tauri::Builder::<tauri::Wry>::new()
/// // type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
/// # type TauriRuntime = tauri::test::MockRuntime;
/// tauri::Builder::<TauriRuntime>::new()
/// .setup(|app| {
/// let webview_window = app.get_webview_window("main").unwrap();
/// let webview_window_ = webview_window.clone();

View File

@@ -156,7 +156,9 @@ impl<'a, R: Runtime, M: Manager<R>> WindowBuilder<'a, R, M> {
feature = "unstable",
doc = r####"
```
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = tauri::window::WindowBuilder::new(app, "label")
.build()?;
@@ -171,7 +173,9 @@ tauri::Builder::<tauri::Wry>::new()
feature = "unstable",
doc = r####"
```
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let handle = app.handle().clone();
std::thread::spawn(move || {
@@ -192,7 +196,7 @@ tauri::Builder::<tauri::Wry>::new()
doc = r####"
```
#[tauri::command]
async fn create_window(app: tauri::AppHandle) {
async fn create_window(app: tauri::AppHandle<tauri::test::MockRuntime>) {
let window = tauri::window::WindowBuilder::new(&app, "label")
.build()
.unwrap();
@@ -234,7 +238,7 @@ async fn create_window(app: tauri::AppHandle) {
doc = r####"
```
#[tauri::command]
async fn reopen_window(app: tauri::AppHandle) {
async fn reopen_window(app: tauri::AppHandle<tauri::test::MockRuntime>) {
let window = tauri::window::WindowBuilder::from_config(&app, &app.config().app.windows.get(0).unwrap().clone())
.unwrap()
.build()
@@ -294,7 +298,9 @@ async fn reopen_window(app: tauri::AppHandle) {
doc = r####"
```
use tauri::menu::{Menu, Submenu, MenuItem};
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let handle = app.handle();
let save_menu_item = MenuItem::new(handle, "Save", true, None::<&str>)?;
@@ -1136,7 +1142,9 @@ impl<R: Runtime> Window<R> {
doc = r####"
```
use tauri::menu::{Menu, Submenu, MenuItem};
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let handle = app.handle();
let save_menu_item = MenuItem::new(handle, "Save", true, None::<&str>)?;
@@ -1837,7 +1845,9 @@ impl<R: Runtime> Window<R> {
doc = r####"
```rust,no_run
use tauri::{Manager, window::{Color, Effect, EffectState, EffectsBuilder}};
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = app.get_window("main").unwrap();
window.set_effects(
@@ -2255,7 +2265,9 @@ impl<R: Runtime> Listener<R> for Window<R> {
```
use tauri::{Manager, Listener};
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = app.get_window("main").unwrap();
window.listen("component-loaded", move |event| {
@@ -2307,7 +2319,9 @@ tauri::Builder::<tauri::Wry>::new()
```
use tauri::{Manager, Listener};
tauri::Builder::<tauri::Wry>::new()
// type TauriRuntime = tauri_runtime_wry::Wry<tauri::EventLoopMessage>;
type TauriRuntime = tauri::test::MockRuntime;
tauri::Builder::<TauriRuntime>::new()
.setup(|app| {
let window = app.get_window("main").unwrap();
let window_ = window.clone();