waft-rendering 0.13.0

Render-object tree and layout for Waft
Documentation
//! flutter_test's paint matchers (`mock_canvas.dart`), its `moreOrLessEquals` family, and
//! flutter's `rendering_tester.dart`: the one `paints` matcher over the display
//! list a render object or a painter records ([`paints`]), and what paints a render object to
//! read it ([`pictures`], [`painted_ops`]). Behind the `test-support` feature, so the tests of a
//! crate above this one read paint as this crate's own do.

mod more_or_less;
mod paints;
mod pictures;
mod rendering_tester;
#[cfg(test)]
mod tests;

pub use more_or_less::{
    MoreOrLessEquals, PRECISION_ERROR_TOLERANCE, assert_f32_equals, assert_more_or_less_equals,
    assert_more_or_less_equals_within,
};
pub use paints::{
    CanvasMethod, PaintCall, PaintMismatch, PaintedStyle, RecordedCall, SomethingPredicate,
    assert_paints, colors_match, count_calls, draws, paints, paints_exactly,
};
pub use pictures::{painted_ops, painted_ops_deep, pictures, pictures_deep};
pub use rendering_tester::{
    EnginePhase, TEST_VIEW_SIZE, install_test_fonts, layout, layout_with, pump_frame,
    test_pipeline_owner, test_render_root,
};

/// Dart's `equalsIgnoringHashCodes`: every `#` and five hex digits read as `#00000`.
pub fn ignoring_hash_codes(text: &str) -> String {
    let mut out = String::with_capacity(text.len());
    let mut rest = text;
    while let Some(at) = rest.find('#') {
        out.push_str(&rest[..at]);
        let hash = &rest[at + 1..];
        let digits = hash.chars().take_while(char::is_ascii_hexdigit).count();
        if digits == 5 {
            out.push_str("#00000");
            rest = &hash[5..];
        } else {
            out.push('#');
            rest = hash;
        }
    }
    out.push_str(rest);
    out
}