1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Copyright 2020 the Xilem Authors and the Druid Authors
// SPDX-License-Identifier: Apache-2.0
// After you edit the crate's doc comment, run this command, then check README.md for any missing links
// cargo rdme --workspace-project=masonry_testing
//! Headless runner for testing [Masonry](https://docs.rs/masonry/latest/) applications.
//!
//! The primary type from this crate is [`TestHarness`][], which creates a host for any [Widget][].
//! The widget can of course have children, which allows this crate to be used for testing entire applications.
//!
//! The testing harness can:
//!
//! - Simulate any external event which Masonry handles, including mouse movement, key presses, text input, accessibility events.
//! - Control the flow of time to the application (i.e. for testing animations).
//! - Take screenshots of the application, save these to a file, and ensure that these are up-to-date.
//! See [Screenshots](#screenshots) for more details.
//!
//! <!-- Masonry itself depends on Masonry Testing, so we can't use an intra-doc link here. -->
//! Testing in Masonry is also documented in the [Testing widgets in Masonry](https://docs.rs/masonry/latest/masonry/doc/doc_04_testing_widget/index.html)
//! chapter in Masonry's book.
//!
//! This crate can be accessed for applications using Masonry as `masonry::testing`, if Masonry's `testing` feature is enabled.
//! For applications which are using only [Masonry Core](masonry_core), you should depend on `masonry_testing` directly.
//!
//! # Screenshots
//!
//! Tests using `TestHarness` can include snapshot steps by using the [`assert_render_snapshot`][] macro.
//! This renders the application being tested, then compares it against the png file with the given name
//! from the `screenshots` folder (in the package being tested, i.e. adjacent to its `Cargo.toml` file).
//!
//! Masonry Testing will update the reference file when the `MASONRY_TEST_BLESS` environment variable has a value of `1`.
//! This can be used if the file doesn't exist, or there's an expected difference.
//! The screenshots are losslessly compressed (using [Oxipng][oxipng]) and limited to a small maximum file size (this
//! limit has an escape hatch).
//! This ensures that the screenshots are small enough to embed in a git repository with limited risk
//! of clone times growing unreasonably.
//! UI screenshots compress well, so we expect this to be scalable.
//!
//! For repositories hosted on GitHub, this scheme also allows for including screenshots of your app or
//! widgets in hosted documentation, although we haven't documented this publicly yet.
//!
//! # Examples
//!
//! For examples of this crate in use
//!
//! - To test applications: see the tests in Masonry's examples.
//! - To test widgets: see the `tests` module in each widget in Masonry.
pub use ;
pub use assert_debug_panics_inner;
pub use DebugName;
pub use ;
pub use ModularWidget;
pub use ;
pub use WrapperWidget;
use Widget;
/// External trait implemented for all widgets.
///
/// Implements helper methods useful for unit testing.