Add unit test for no events when adding first wxNotebook page
Adding the first page shouldn't generate any events even if the selection does change (from -1 to 0) internally.
This commit is contained in:
@@ -20,7 +20,9 @@
|
|||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/notebook.h"
|
#include "wx/notebook.h"
|
||||||
|
|
||||||
#include "bookctrlbasetest.h"
|
#include "bookctrlbasetest.h"
|
||||||
|
#include "testableframe.h"
|
||||||
|
|
||||||
class NotebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
|
class NotebookTestCase : public BookCtrlBaseTestCase, public CppUnit::TestCase
|
||||||
{
|
{
|
||||||
@@ -118,4 +120,25 @@ void NotebookTestCase::NoEventsOnDestruction()
|
|||||||
CHECK( m_numPageChanges == 1 );
|
CHECK( m_numPageChanges == 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("wxNotebook::NoEventsForFirstPage", "[wxNotebook][event]")
|
||||||
|
{
|
||||||
|
wxNotebook* const
|
||||||
|
notebook = new wxNotebook(wxTheApp->GetTopWindow(), wxID_ANY,
|
||||||
|
wxDefaultPosition, wxSize(400, 200));
|
||||||
|
|
||||||
|
CHECK( notebook->GetSelection() == wxNOT_FOUND );
|
||||||
|
|
||||||
|
EventCounter countPageChanging(notebook, wxEVT_NOTEBOOK_PAGE_CHANGING);
|
||||||
|
EventCounter countPageChanged(notebook, wxEVT_NOTEBOOK_PAGE_CHANGED);
|
||||||
|
|
||||||
|
notebook->AddPage(new wxPanel(notebook), "First page");
|
||||||
|
|
||||||
|
// The selection should have been changed.
|
||||||
|
CHECK( notebook->GetSelection() == 0 );
|
||||||
|
|
||||||
|
// But no events should have been generated.
|
||||||
|
CHECK( countPageChanging.GetCount() == 0 );
|
||||||
|
CHECK( countPageChanged.GetCount() == 0 );
|
||||||
|
}
|
||||||
|
|
||||||
#endif //wxUSE_NOTEBOOK
|
#endif //wxUSE_NOTEBOOK
|
||||||
|
Reference in New Issue
Block a user