fn adding_child_lifecycle() {
    let record = Recording::default();
    let record_new_child = Recording::default();
    let record_new_child2 = record_new_child.clone();

    let replacer = ReplaceChild::new(TextBox::new(), move || {
        Split::columns(TextBox::new(), TextBox::new().record(&record_new_child2))
    });

    let widget = Split::columns(Label::new("hi").record(&record), replacer);

    Harness::create_simple(String::new(), widget, |harness| {
        harness.send_initial_events();

        assert!(matches!(record.next(), Record::L(LifeCycle::WidgetAdded)));
        assert!(matches!(
            record.next(),
            Record::L(LifeCycle::BuildFocusChain)
        ));
        assert!(matches!(record.next(), Record::E(Event::WindowConnected)));
        assert!(record.is_empty());

        assert!(record_new_child.is_empty());

        harness.submit_command(REPLACE_CHILD);

        assert!(matches!(record.next(), Record::E(Event::Command(_))));

        assert!(matches!(
            record_new_child.next(),
            Record::L(LifeCycle::WidgetAdded)
        ));
        assert!(matches!(
            record_new_child.next(),
            Record::L(LifeCycle::BuildFocusChain)
        ));
        assert!(record_new_child.is_empty());
    })
}
/// Test that lifecycle events are sent correctly to a child added during event
/// handling
Test that lifecycle events are sent correctly to a child added during event
handling
Test that lifecycle events are sent correctly to a child added during event handling
fn adding_child_lifecycle() {
    let record = Recording::default();
    let record_new_child = Recording::default();
    let record_new_child2 = record_new_child.clone();
    let replacer = ReplaceChild::new(TextBox::new(), move || {
        Split::columns(TextBox::new(), TextBox::new().record(&record_new_child2))
    });
    let widget = Split::columns(Label::new("hi").record(&record), replacer);
    Harness::create_simple(String::new(), widget, |harness| {
        harness.send_initial_events();
        assert!(matches!(record.next(), Record::L(LifeCycle::WidgetAdded)));
        assert!(matches!(
            record.next(),
            Record::L(LifeCycle::BuildFocusChain)
        ));
        assert!(matches!(record.next(), Record::E(Event::WindowConnected)));
        assert!(record.is_empty());
        assert!(record_new_child.is_empty());
        harness.submit_command(REPLACE_CHILD);
        assert!(matches!(record.next(), Record::E(Event::Command(_))));
        assert!(matches!(
            record_new_child.next(),
            Record::L(LifeCycle::WidgetAdded)
        ));
        assert!(matches!(
            record_new_child.next(),
            Record::L(LifeCycle::BuildFocusChain)
        ));
        assert!(record_new_child.is_empty());
    })
}
fn adding_child_lifecycle ( ) { let record = Recording :: default ( ) ; let record_new_child = Recording :: default ( ) ; let record_new_child2 = record_new_child . clone ( ) ; let replacer = ReplaceChild :: new ( TextBox :: new ( ) , move | | { Split :: columns ( TextBox :: new ( ) , TextBox :: new ( ) . record ( & record_new_child2 ) ) } ) ; let widget = Split :: columns ( Label :: new ( " " ) . record ( & record ) , replacer ) ; Harness :: create_simple ( String :: new ( ) , widget , | harness | { harness . send_initial_events ( ) ; assert ! ( matches ( record next ( ) Record L ( LifeCycle WidgetAdded ) ) ) ; assert ! ( matches ( record next ( ) Record L ( LifeCycle BuildFocusChain ) ) ) ; assert ! ( matches ( record next ( ) Record E ( Event WindowConnected ) ) ) ; assert ! ( record is_empty ( ) ) ; assert ! ( record_new_child is_empty ( ) ) ; harness . submit_command ( REPLACE_CHILD ) ; assert ! ( matches ( record next ( ) Record E ( Event Command ( ) ) ) ) ; assert ! ( matches ( record_new_child next ( ) Record L ( LifeCycle WidgetAdded ) ) ) ; assert ! ( matches ( record_new_child next ( ) Record L ( LifeCycle BuildFocusChain ) ) ) ; assert ! ( record_new_child is_empty ( ) ) ; } ) }
Test that lifecycle events are sent correctly to a child added during event
handling
Test that lifecycle events are sent correctly to a child added during event handling