Add unit test for wxTextCtrl::EmptyUndoBuffer()

Check that calling it results in CanUndo() returning false and really
prevents Undo() from working.
This commit is contained in:
Vadim Zeitlin 2021-08-20 16:50:40 +01:00
parent adacb5c07e
commit 64f7c23272

View File

@ -1472,4 +1472,35 @@ TEST_CASE("wxTextCtrl::InitialCanUndo", "[wxTextCtrl][undo]")
}
}
// This test would always fail with MinGW-32 for the same reason as described
// above.
#ifndef __MINGW32_TOOLCHAIN__
TEST_CASE("wxTextCtrl::EmptyUndoBuffer", "[wxTextCtrl][undo]")
{
wxScopedPtr<wxTextCtrl> text(new wxTextCtrl(wxTheApp->GetTopWindow(),
wxID_ANY, "",
wxDefaultPosition,
wxDefaultSize,
wxTE_MULTILINE | wxTE_RICH2));
text->AppendText("foo");
if ( !text->CanUndo() )
{
WARN("Skipping test as Undo() is not supported on this platform.");
return;
}
text->EmptyUndoBuffer();
CHECK_FALSE( text->CanUndo() );
CHECK_NOTHROW( text->Undo() );
CHECK( text->GetValue() == "foo" );
}
#endif // __MINGW32_TOOLCHAIN__
#endif //wxUSE_TEXTCTRL