Return true from wxDialog::IsModal() in wxEVT_INIT_DIALOG handler

Ensure that checking for dialog modality in wxEVT_INIT_DIALOG handler returns
true when the dialog is being shown modally in MSW and GTK.

Add a unit test checking that this is the case.

Closes #10385.
This commit is contained in:
Jose Lorenzo
2017-04-15 16:31:13 +01:00
committed by Vadim Zeitlin
parent d2c2274baa
commit b6f2973c41
3 changed files with 41 additions and 7 deletions

View File

@@ -36,11 +36,13 @@ private:
#endif
CPPUNIT_TEST( FileDialog );
CPPUNIT_TEST( CustomDialog );
CPPUNIT_TEST( InitDialog );
CPPUNIT_TEST_SUITE_END();
void MessageDialog();
void FileDialog();
void CustomDialog();
void InitDialog();
wxDECLARE_NO_COPY_CLASS(ModalDialogsTestCase);
};
@@ -132,4 +134,36 @@ void ModalDialogsTestCase::CustomDialog()
CPPUNIT_ASSERT_EQUAL( 42, dlg.m_value );
}
class MyModalDialog : public wxDialog
{
public:
MyModalDialog() : wxDialog (NULL, wxID_ANY, "Modal Dialog")
{
m_wasModal = false;
Bind( wxEVT_INIT_DIALOG, &MyModalDialog::OnInit, this );
}
void OnInit(wxInitDialogEvent& WXUNUSED(event))
{
m_wasModal = IsModal();
CallAfter( &MyModalDialog::EndModal, wxID_OK );
}
bool WasModal() const
{
return m_wasModal;
}
private:
bool m_wasModal;
};
void ModalDialogsTestCase::InitDialog()
{
MyModalDialog dlg;
dlg.ShowModal();
CPPUNIT_ASSERT( dlg.WasModal() );
}
#endif // HAVE_VARIADIC_MACROS