Work around GTK problems in wxPersistentDVC unit test
We need to wait until wxDataViewCtrl is realized for its columns widths to be actually set, as calling gtk_tree_view_column_set_fixed_width() just queues a resize that will take effect later, as documented in the previous commit.
This commit is contained in:
@@ -20,6 +20,10 @@
|
|||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/dataview.h"
|
#include "wx/dataview.h"
|
||||||
|
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
#include "wx/stopwatch.h"
|
||||||
|
#endif // __WXGTK__
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/persist/dataview.h"
|
#include "wx/persist/dataview.h"
|
||||||
@@ -84,6 +88,25 @@ static wxDataViewCtrl* CreatePersistenceTestDVC()
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GTKWaitRealized(wxDataViewCtrl* list)
|
||||||
|
{
|
||||||
|
#ifdef __WXGTK__
|
||||||
|
wxStopWatch sw;
|
||||||
|
while ( list->GetColumn(0)->GetWidth() == 0 )
|
||||||
|
{
|
||||||
|
if ( sw.Time() > 500 )
|
||||||
|
{
|
||||||
|
WARN("Timed out waiting for wxDataViewCtrl to be realized");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxYield();
|
||||||
|
}
|
||||||
|
#else // !__WXGTK__
|
||||||
|
wxUnusedVar(list);
|
||||||
|
#endif // __WXGTK__/!__WXGTK__
|
||||||
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
// tests themselves
|
// tests themselves
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@@ -102,6 +125,10 @@ TEST_CASE_METHOD(PersistenceTests, "wxPersistDVC", "[persist][wxDataViewCtrl]")
|
|||||||
|
|
||||||
CHECK(wxPersistenceManager::Get().Register(list));
|
CHECK(wxPersistenceManager::Get().Register(list));
|
||||||
|
|
||||||
|
// We need to wait until the window is fully realized and the column
|
||||||
|
// widths are actually set.
|
||||||
|
GTKWaitRealized(list);
|
||||||
|
|
||||||
// Deleting the control itself doesn't allow it to save its state as
|
// Deleting the control itself doesn't allow it to save its state as
|
||||||
// the wxEVT_DESTROY handler is called too late, so delete its parent
|
// the wxEVT_DESTROY handler is called too late, so delete its parent
|
||||||
// (as would usually be the case) instead.
|
// (as would usually be the case) instead.
|
||||||
@@ -130,6 +157,10 @@ TEST_CASE_METHOD(PersistenceTests, "wxPersistDVC", "[persist][wxDataViewCtrl]")
|
|||||||
// Test that the object was registered and restored.
|
// Test that the object was registered and restored.
|
||||||
CHECK(wxPersistenceManager::Get().RegisterAndRestore(list));
|
CHECK(wxPersistenceManager::Get().RegisterAndRestore(list));
|
||||||
|
|
||||||
|
// Similar to above, we need to wait until it's realized after
|
||||||
|
// restoring the widths.
|
||||||
|
GTKWaitRealized(list);
|
||||||
|
|
||||||
// Test that the correct values were restored.
|
// Test that the correct values were restored.
|
||||||
CHECK(150 == list->GetColumn(0)->GetWidth());
|
CHECK(150 == list->GetColumn(0)->GetWidth());
|
||||||
CHECK(250 == list->GetColumn(1)->GetWidth());
|
CHECK(250 == list->GetColumn(1)->GetWidth());
|
||||||
|
Reference in New Issue
Block a user