Skip to main content

Module testing

Module testing 

Source
Expand description

An Os a test scripts and reads, under the testing feature.

use std::path::PathBuf;

use hypersig_desktop::testing::{DialogKind, FakeOs};

let fake = FakeOs::new();
fake.answer_dialog([PathBuf::from("/notes/today.md")]);
let os = fake.os();

// A handler given `os` asks for a file and gets the one the test chose.
assert_eq!(os.dialog().open_file().await, Some(PathBuf::from("/notes/today.md")));
os.clipboard().write_text("copied").await.unwrap();
assert_eq!(fake.clipboard_text().as_deref(), Some("copied"));
assert_eq!(fake.dialogs()[0].kind, DialogKind::OpenFile);

Structs§

Arranged
How the handlers arranged a window, as FakeOs::window returns it.
FakeOs
A fake system: the answers its dialogs give, and what the handlers did.
ShownDialog
A dialog a handler showed, as FakeOs::dialogs returns it.
ShownMessage
A message box a handler showed, as FakeOs::messages returns it.

Enums§

Choice
The button a test chooses in a message box, with FakeOs::choose.
DialogKind
Which method of Dialog showed a dialog.
MessageKind
Which method of Os showed a message box.