2008-09-12 20:57:41 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: samples/propgrid/tests.cpp
|
|
|
|
// Purpose: wxPropertyGrid tests
|
|
|
|
// Author: Jaakko Salli
|
|
|
|
// Modified by:
|
|
|
|
// Created: 2007-05-16
|
|
|
|
// Copyright: (c) Jaakko Salli
|
2010-07-13 13:29:13 +00:00
|
|
|
// Licence: wxWindows licence
|
2008-09-12 20:57:41 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "wx/wxprec.h"
|
|
|
|
|
|
|
|
#ifdef __BORLANDC__
|
|
|
|
#pragma hdrstop
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef WX_PRECOMP
|
|
|
|
#include "wx/wx.h"
|
|
|
|
#endif
|
|
|
|
|
2017-07-16 12:47:45 +00:00
|
|
|
#include "wx/propgrid/propgrid.h"
|
|
|
|
#include "wx/propgrid/advprops.h"
|
|
|
|
#include "wx/propgrid/manager.h"
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
#include "propgrid.h"
|
|
|
|
#include "sampleprops.h"
|
|
|
|
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// wxTestCustomFlagsProperty
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
//
|
|
|
|
// Test customizing wxColourProperty via subclassing
|
|
|
|
//
|
|
|
|
// * Includes custom colour entry.
|
|
|
|
// * Includes extra custom entry.
|
|
|
|
//
|
2008-10-07 17:28:05 +00:00
|
|
|
class MyColourProperty : public wxColourProperty
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-10-07 17:28:05 +00:00
|
|
|
MyColourProperty( const wxString& label = wxPG_LABEL,
|
2008-09-12 20:57:41 +00:00
|
|
|
const wxString& name = wxPG_LABEL,
|
|
|
|
const wxColour& value = *wxWHITE )
|
|
|
|
: wxColourProperty(label, name, value)
|
|
|
|
{
|
|
|
|
wxPGChoices colours;
|
2018-09-29 01:45:15 +00:00
|
|
|
colours.Add("White");
|
|
|
|
colours.Add("Black");
|
|
|
|
colours.Add("Red");
|
|
|
|
colours.Add("Green");
|
|
|
|
colours.Add("Blue");
|
|
|
|
colours.Add("Custom");
|
|
|
|
colours.Add("None");
|
2008-09-12 20:57:41 +00:00
|
|
|
m_choices = colours;
|
|
|
|
SetIndex(0);
|
|
|
|
wxVariant variant;
|
|
|
|
variant << value;
|
|
|
|
SetValue(variant);
|
|
|
|
}
|
|
|
|
|
2008-10-07 17:28:05 +00:00
|
|
|
virtual ~MyColourProperty()
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual wxColour GetColour( int index ) const wxOVERRIDE
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
switch (index)
|
|
|
|
{
|
|
|
|
case 0: return *wxWHITE;
|
|
|
|
case 1: return *wxBLACK;
|
|
|
|
case 2: return *wxRED;
|
|
|
|
case 3: return *wxGREEN;
|
|
|
|
case 4: return *wxBLUE;
|
|
|
|
case 5:
|
|
|
|
// Return current colour for the custom entry
|
|
|
|
wxColour col;
|
|
|
|
if ( GetIndex() == GetCustomColourIndex() )
|
|
|
|
{
|
|
|
|
if ( m_value.IsNull() )
|
|
|
|
return col;
|
|
|
|
col << m_value;
|
|
|
|
return col;
|
|
|
|
}
|
|
|
|
return *wxWHITE;
|
2019-07-21 13:15:36 +00:00
|
|
|
}
|
2008-09-12 20:57:41 +00:00
|
|
|
return wxColour();
|
|
|
|
}
|
|
|
|
|
2011-06-30 12:20:29 +00:00
|
|
|
virtual wxString ColourToString( const wxColour& col,
|
|
|
|
int index,
|
2014-03-30 00:02:23 +00:00
|
|
|
int argFlags = 0 ) const wxOVERRIDE
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
if ( index == (int)(m_choices.GetCount()-1) )
|
2015-06-04 20:53:30 +00:00
|
|
|
return wxEmptyString;
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2011-06-30 12:20:29 +00:00
|
|
|
return wxColourProperty::ColourToString(col, index, argFlags);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
2014-03-30 00:02:23 +00:00
|
|
|
virtual int GetCustomColourIndex() const wxOVERRIDE
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
return m_choices.GetCount()-2;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void FormMain::AddTestProperties( wxPropertyGridPage* pg )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->Append( new MyColourProperty("CustomColourProperty", wxPG_LABEL, *wxGREEN) );
|
|
|
|
pg->GetProperty("CustomColourProperty")->SetAutoUnspecified(true);
|
|
|
|
pg->SetPropertyEditor( "CustomColourProperty", wxPGEditor_ComboBox );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyHelpString("CustomColourProperty",
|
|
|
|
"This is a MyColourProperty from the sample app. "
|
|
|
|
"It is built by subclassing wxColourProperty.");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
void FormMain::OnDumpList( wxCommandEvent& WXUNUSED(event) )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
wxVariant values = m_pPropGridManager->GetPropertyValues("list", wxNullProperty, wxPG_INC_ATTRIBUTES);
|
2019-04-21 18:49:11 +00:00
|
|
|
wxString text = "This only tests that wxVariant related routines do not crash.\n";
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
wxDialog* dlg = new wxDialog(this,wxID_ANY,"wxVariant Test",
|
2008-09-12 20:57:41 +00:00
|
|
|
wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
|
|
|
|
|
2019-04-21 18:59:25 +00:00
|
|
|
for ( size_t i = 0; i < values.GetCount(); i++ )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2019-04-21 18:59:25 +00:00
|
|
|
wxString t;
|
2008-09-12 20:57:41 +00:00
|
|
|
wxVariant& v = values[i];
|
|
|
|
|
|
|
|
wxString strValue = v.GetString();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( v.GetName().EndsWith("@attr") )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
text += wxString::Format("Attributes:\n");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2019-04-21 18:59:25 +00:00
|
|
|
for ( size_t n = 0; n < v.GetCount(); n++ )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxVariant& a = v[n];
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
t.Printf(" attribute %i: name=\"%s\" (type=\"%s\" value=\"%s\")\n",(int)n,
|
2018-11-01 23:32:02 +00:00
|
|
|
a.GetName(),a.GetType(),a.GetString());
|
2008-09-12 20:57:41 +00:00
|
|
|
text += t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
t.Printf("%i: name=\"%s\" type=\"%s\" value=\"%s\"\n",(int)i,
|
2018-11-01 23:32:02 +00:00
|
|
|
v.GetName(),v.GetType(),strValue);
|
2008-09-12 20:57:41 +00:00
|
|
|
text += t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// multi-line text editor dialog
|
|
|
|
const int spacing = 8;
|
|
|
|
wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
|
2015-06-07 21:14:37 +00:00
|
|
|
wxTextCtrl* ed = new wxTextCtrl(dlg, wxID_ANY, text,
|
2009-10-13 14:34:47 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2015-06-25 17:25:00 +00:00
|
|
|
wxTE_MULTILINE|wxTE_READONLY);
|
2015-05-30 16:33:25 +00:00
|
|
|
rowsizer->Add( ed, wxSizerFlags(1).Expand().Border(wxALL, spacing));
|
|
|
|
topsizer->Add( rowsizer, wxSizerFlags(1).Expand());
|
2008-09-12 20:57:41 +00:00
|
|
|
rowsizer = new wxBoxSizer( wxHORIZONTAL );
|
2018-09-29 01:45:15 +00:00
|
|
|
rowsizer->Add( new wxButton(dlg,wxID_OK,"Ok"),
|
2015-05-30 16:33:25 +00:00
|
|
|
wxSizerFlags(0).CentreHorizontal().CentreVertical().Border(wxBOTTOM|wxLEFT|wxRIGHT, spacing));
|
2015-04-25 10:52:36 +00:00
|
|
|
topsizer->Add( rowsizer, wxSizerFlags().Right() );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
dlg->SetSizer( topsizer );
|
|
|
|
topsizer->SetSizeHints( dlg );
|
|
|
|
|
|
|
|
dlg->SetSize(400,300);
|
|
|
|
dlg->Centre();
|
|
|
|
dlg->ShowModal();
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
class TestRunner
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2019-06-16 16:30:44 +00:00
|
|
|
TestRunner( const wxString& name, wxPropertyGridManager* man, wxTextCtrl* ed, wxVector<wxString>* errorMessages )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
m_name = name;
|
|
|
|
m_man = man;
|
|
|
|
m_ed = ed;
|
|
|
|
m_errorMessages = errorMessages;
|
|
|
|
#ifdef __WXDEBUG__
|
|
|
|
m_preWarnings = wxPGGlobalVars->m_warnings;
|
|
|
|
#endif
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( name != "none" )
|
|
|
|
Msg(name+"\n");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~TestRunner()
|
|
|
|
{
|
|
|
|
#ifdef __WXDEBUG__
|
|
|
|
int warningsOccurred = wxPGGlobalVars->m_warnings - m_preWarnings;
|
|
|
|
if ( warningsOccurred )
|
|
|
|
{
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString s = wxString::Format("%i warnings occurred during test '%s'", warningsOccurred, m_name);
|
2008-09-12 20:57:41 +00:00
|
|
|
m_errorMessages->push_back(s);
|
|
|
|
Msg(s);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void Msg( const wxString& text )
|
|
|
|
{
|
|
|
|
if ( m_ed )
|
|
|
|
{
|
|
|
|
m_ed->AppendText(text);
|
2018-09-29 01:45:15 +00:00
|
|
|
m_ed->AppendText("\n");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
wxLogDebug(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
wxPropertyGridManager* m_man;
|
|
|
|
wxTextCtrl* m_ed;
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxString>* m_errorMessages;
|
2008-09-12 20:57:41 +00:00
|
|
|
wxString m_name;
|
|
|
|
#ifdef __WXDEBUG__
|
|
|
|
int m_preWarnings;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#define RT_START_TEST(TESTNAME) \
|
2018-09-29 01:45:15 +00:00
|
|
|
TestRunner tr(#TESTNAME, pgman, ed, &errorMessages);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
#define RT_MSG(S) \
|
|
|
|
tr.Msg(S);
|
|
|
|
|
|
|
|
#define RT_FAILURE() \
|
|
|
|
{ \
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString s1 = wxString::Format("Test failure in tests.cpp, line %i.",__LINE__-1); \
|
2008-09-12 20:57:41 +00:00
|
|
|
errorMessages.push_back(s1); \
|
|
|
|
wxLogDebug(s1); \
|
|
|
|
failures++; \
|
|
|
|
}
|
|
|
|
|
2009-08-17 18:36:00 +00:00
|
|
|
#define RT_ASSERT(COND) \
|
|
|
|
if (!(COND)) \
|
|
|
|
RT_FAILURE()
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
#define RT_FAILURE_MSG(MSG) \
|
|
|
|
{ \
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString s1 = wxString::Format("Test failure in tests.cpp, line %i.",__LINE__-1); \
|
2008-09-12 20:57:41 +00:00
|
|
|
errorMessages.push_back(s1); \
|
|
|
|
wxLogDebug(s1); \
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString s2 = wxString::Format("Message: %s",MSG); \
|
2008-09-12 20:57:41 +00:00
|
|
|
errorMessages.push_back(s2); \
|
|
|
|
wxLogDebug(s2); \
|
|
|
|
failures++; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_VALIDATE_VIRTUAL_HEIGHT(PROPS, EXTRATEXT) \
|
|
|
|
{ \
|
|
|
|
unsigned int h1_ = PROPS->GetVirtualHeight(); \
|
|
|
|
unsigned int h2_ = PROPS->GetActualVirtualHeight(); \
|
|
|
|
if ( h1_ != h2_ ) \
|
|
|
|
{ \
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString s_ = wxString::Format("VirtualHeight = %i, should be %i (%s)", h1_, h2_, EXTRATEXT); \
|
2015-06-25 17:29:54 +00:00
|
|
|
RT_FAILURE_MSG(s_); \
|
2008-09-12 20:57:41 +00:00
|
|
|
_failed_ = true; \
|
|
|
|
} \
|
|
|
|
else \
|
|
|
|
{ \
|
|
|
|
_failed_ = false; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2015-06-14 14:56:06 +00:00
|
|
|
inline bool GetRandomBooleanVal()
|
|
|
|
{
|
|
|
|
return (rand() % 2) != 0;
|
|
|
|
}
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2017-10-01 16:11:45 +00:00
|
|
|
extern "C"
|
2008-09-12 20:57:41 +00:00
|
|
|
int gpiro_cmpfunc(const void* a, const void* b)
|
|
|
|
{
|
2017-10-01 16:11:45 +00:00
|
|
|
const wxPGProperty* p1 = *static_cast<wxPGProperty* const*>(a);
|
|
|
|
const wxPGProperty* p2 = *static_cast<wxPGProperty* const*>(b);
|
2008-09-12 20:57:41 +00:00
|
|
|
return (int) (((size_t)p1->GetClientData()) - ((size_t)p2->GetClientData()));
|
|
|
|
}
|
|
|
|
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxPGProperty*> GetPropertiesInRandomOrder( wxPropertyGridInterface* props, int iterationFlags = wxPG_ITERATE_ALL )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxPGProperty*> arr;
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
|
|
|
|
for ( it = props->GetIterator(iterationFlags);
|
|
|
|
!it.AtEnd();
|
2015-06-13 20:32:14 +00:00
|
|
|
++it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = *it;
|
|
|
|
size_t randomNumber = rand();
|
|
|
|
p->SetClientData(reinterpret_cast<void*>(randomNumber));
|
|
|
|
arr.push_back(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPGProperty** firstEntry = &arr[0];
|
|
|
|
qsort(firstEntry, arr.size(), sizeof(wxPGProperty*), gpiro_cmpfunc);
|
|
|
|
|
|
|
|
return arr;
|
|
|
|
}
|
|
|
|
|
2009-01-07 18:53:09 +00:00
|
|
|
// Callback for testing property sorting
|
|
|
|
int MyPropertySortFunction(wxPropertyGrid* WXUNUSED(propGrid),
|
|
|
|
wxPGProperty* p1,
|
|
|
|
wxPGProperty* p2)
|
|
|
|
{
|
|
|
|
// Reverse alphabetical order
|
|
|
|
return p2->GetLabel().CmpNoCase( p1->GetBaseName() );
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
bool FormMain::RunTests( bool fullTest, bool interactive )
|
|
|
|
{
|
|
|
|
wxString t;
|
|
|
|
|
|
|
|
wxPropertyGridManager* pgman = m_pPropGridManager;
|
|
|
|
wxPropertyGrid* pg;
|
|
|
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
pgman->ClearSelection();
|
|
|
|
|
2015-06-26 16:28:05 +00:00
|
|
|
srand((unsigned int)(time(NULL) % UINT_MAX));
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
int failures = 0;
|
|
|
|
bool _failed_ = false;
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxString> errorMessages;
|
2008-09-12 20:57:41 +00:00
|
|
|
wxDialog* dlg = NULL;
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
dlg = new wxDialog(this,wxID_ANY,"wxPropertyGrid Regression Tests",
|
2008-09-12 20:57:41 +00:00
|
|
|
wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
|
|
|
|
|
|
|
|
// multi-line text editor dialog
|
|
|
|
const int spacing = 8;
|
|
|
|
wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
|
2015-06-07 21:14:37 +00:00
|
|
|
wxTextCtrl* ed = new wxTextCtrl(dlg, wxID_ANY, wxEmptyString,
|
2009-10-13 14:34:47 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
2015-06-25 17:25:00 +00:00
|
|
|
wxTE_MULTILINE|wxTE_READONLY);
|
2015-05-30 16:33:25 +00:00
|
|
|
rowsizer->Add( ed, wxSizerFlags(1).Expand().Border(wxALL, spacing));
|
|
|
|
topsizer->Add( rowsizer, wxSizerFlags(1).Expand());
|
2008-09-12 20:57:41 +00:00
|
|
|
rowsizer = new wxBoxSizer( wxHORIZONTAL );
|
2018-09-29 01:45:15 +00:00
|
|
|
rowsizer->Add( new wxButton(dlg,wxID_OK,"Ok"),
|
2015-05-30 16:33:25 +00:00
|
|
|
wxSizerFlags(0).CentreHorizontal().CentreVertical().Border(wxBOTTOM|wxLEFT|wxRIGHT, spacing));
|
2015-04-25 10:52:36 +00:00
|
|
|
topsizer->Add( rowsizer, wxSizerFlags().Right() );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
dlg->SetSizer( topsizer );
|
|
|
|
topsizer->SetSizeHints( dlg );
|
|
|
|
|
|
|
|
dlg->SetSize(400,300);
|
|
|
|
dlg->Move(wxSystemSettings::GetMetric(wxSYS_SCREEN_X)-dlg->GetSize().x,
|
|
|
|
wxSystemSettings::GetMetric(wxSYS_SCREEN_Y)-dlg->GetSize().y);
|
|
|
|
dlg->Show();
|
|
|
|
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Basic iterator tests
|
|
|
|
RT_START_TEST(GetIterator)
|
|
|
|
|
|
|
|
wxPGVIterator it;
|
|
|
|
int count;
|
|
|
|
|
|
|
|
count = 0;
|
|
|
|
for ( it = pgman->GetVIterator(wxPG_ITERATE_PROPERTIES);
|
|
|
|
!it.AtEnd();
|
|
|
|
it.Next() )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = it.GetProperty();
|
|
|
|
if ( p->IsCategory() )
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("'%s' is a category (non-private child property expected)",p->GetLabel()))
|
2008-09-12 20:57:41 +00:00
|
|
|
else if ( p->GetParent()->HasFlag(wxPG_PROP_AGGREGATE) )
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("'%s' is a private child (non-private child property expected)",p->GetLabel()))
|
2008-09-12 20:57:41 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_MSG(wxString::Format("GetVIterator(wxPG_ITERATE_PROPERTIES) -> %i entries", count));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
count = 0;
|
|
|
|
for ( it = pgman->GetVIterator(wxPG_ITERATE_CATEGORIES);
|
|
|
|
!it.AtEnd();
|
|
|
|
it.Next() )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = it.GetProperty();
|
|
|
|
if ( !p->IsCategory() )
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("'%s' is not a category (only category was expected)",p->GetLabel()))
|
2008-09-12 20:57:41 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_MSG(wxString::Format("GetVIterator(wxPG_ITERATE_CATEGORIES) -> %i entries", count));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
count = 0;
|
|
|
|
for ( it = pgman->GetVIterator(wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_CATEGORIES);
|
|
|
|
!it.AtEnd();
|
|
|
|
it.Next() )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = it.GetProperty();
|
|
|
|
if ( p->GetParent()->HasFlag(wxPG_PROP_AGGREGATE) )
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("'%s' is a private child (non-private child property or category expected)",p->GetLabel()))
|
2008-09-12 20:57:41 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_MSG(wxString::Format("GetVIterator(wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_CATEGORIES) -> %i entries", count));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
count = 0;
|
|
|
|
for ( it = pgman->GetVIterator(wxPG_ITERATE_VISIBLE);
|
|
|
|
!it.AtEnd();
|
|
|
|
it.Next() )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = it.GetProperty();
|
|
|
|
if ( (p->GetParent() != p->GetParentState()->DoGetRoot() && !p->GetParent()->IsExpanded()) )
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("'%s' had collapsed parent (only visible properties expected)",p->GetLabel()))
|
2008-09-12 20:57:41 +00:00
|
|
|
else if ( p->HasFlag(wxPG_PROP_HIDDEN) )
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("'%s' was hidden (only visible properties expected)",p->GetLabel()))
|
2008-09-12 20:57:41 +00:00
|
|
|
count++;
|
|
|
|
}
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_MSG(wxString::Format("GetVIterator(wxPG_ITERATE_VISIBLE) -> %i entries", count));
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( fullTest )
|
|
|
|
{
|
|
|
|
// Test that setting focus to properties does not crash things
|
|
|
|
RT_START_TEST(SelectProperty)
|
|
|
|
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
size_t ind;
|
|
|
|
|
|
|
|
for ( ind=0; ind<pgman->GetPageCount(); ind++ )
|
|
|
|
{
|
|
|
|
wxPropertyGridPage* page = pgman->GetPage(ind);
|
|
|
|
pgman->SelectPage(page);
|
|
|
|
|
|
|
|
for ( it = page->GetIterator(wxPG_ITERATE_VISIBLE);
|
|
|
|
!it.AtEnd();
|
2015-06-13 20:32:14 +00:00
|
|
|
++it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = *it;
|
|
|
|
RT_MSG(p->GetLabel());
|
|
|
|
pgman->GetGrid()->SelectProperty(p, true);
|
|
|
|
::wxMilliSleep(150);
|
|
|
|
Update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
//
|
|
|
|
// Delete everything in reverse order
|
|
|
|
RT_START_TEST(DeleteProperty)
|
|
|
|
|
|
|
|
wxPGVIterator it;
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxPGProperty*> array;
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
for ( it = pgman->GetVIterator(wxPG_ITERATE_ALL&~(wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)));
|
|
|
|
!it.AtEnd();
|
|
|
|
it.Next() )
|
|
|
|
array.push_back(it.GetProperty());
|
|
|
|
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxPGProperty*>::reverse_iterator it2;
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2015-06-26 16:15:45 +00:00
|
|
|
for ( it2 = array.rbegin(); it2 != array.rend(); ++it2 )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2019-06-16 16:30:44 +00:00
|
|
|
wxPGProperty* p = *it2;
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_MSG(wxString::Format("Deleting '%s' ('%s')",p->GetLabel(),p->GetName()));
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman->DeleteProperty(p);
|
|
|
|
}
|
|
|
|
|
2015-06-26 16:19:49 +00:00
|
|
|
// Check if grid is empty.
|
|
|
|
it = pgman->GetVIterator(wxPG_ITERATE_ALL&~(wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)));
|
|
|
|
if ( !it.AtEnd() )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString("Not all properties are deleted"));
|
2015-06-26 16:19:49 +00:00
|
|
|
}
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
// Recreate grid
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
//
|
2008-10-06 15:10:00 +00:00
|
|
|
// Test property default values
|
|
|
|
RT_START_TEST(Default_Values)
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxPGVIterator it;
|
|
|
|
|
|
|
|
for ( it = pgman->GetVIterator(wxPG_ITERATE_PROPERTIES);
|
|
|
|
!it.AtEnd();
|
|
|
|
it.Next() )
|
|
|
|
{
|
2008-10-06 15:10:00 +00:00
|
|
|
wxPGProperty* p = it.GetProperty();
|
|
|
|
pgman->SetPropertyValue(p, p->GetDefaultValue());
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Recreate grid
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
}
|
|
|
|
|
2010-04-16 14:36:32 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// Test wxAny<->wxVariant conversion
|
|
|
|
RT_START_TEST(WXVARIANT_TO_WXANY_CONVERSION)
|
|
|
|
|
|
|
|
wxPGProperty* prop;
|
|
|
|
wxAny any;
|
|
|
|
|
|
|
|
#if wxUSE_DATETIME
|
2018-09-29 01:45:15 +00:00
|
|
|
prop = pgman->GetProperty("DateProperty");
|
2010-04-16 14:36:32 +00:00
|
|
|
wxDateTime testTime = wxDateTime::Now();
|
|
|
|
any = testTime;
|
|
|
|
prop->SetValue(any);
|
2014-05-15 22:32:17 +00:00
|
|
|
if ( prop->GetValue().GetAny().As<wxDateTime>() != testTime )
|
2010-04-16 14:36:32 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
#endif
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
prop = pgman->GetProperty("IntProperty");
|
2010-04-16 14:36:32 +00:00
|
|
|
int testInt = 25537983;
|
|
|
|
any = testInt;
|
|
|
|
prop->SetValue(any);
|
2014-05-15 22:32:17 +00:00
|
|
|
if ( prop->GetValue().GetAny().As<int>() != testInt )
|
2010-04-16 14:36:32 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
#ifdef wxLongLong_t
|
2014-05-15 22:32:17 +00:00
|
|
|
if ( prop->GetValue().GetAny().As<wxLongLong_t>() != testInt )
|
2010-04-16 14:36:32 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
#endif
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
prop = pgman->GetProperty("StringProperty");
|
|
|
|
wxString testString = "asd934jfyn3";
|
2010-04-16 14:36:32 +00:00
|
|
|
any = testString;
|
|
|
|
prop->SetValue(any);
|
2014-05-15 22:32:17 +00:00
|
|
|
if ( prop->GetValue().GetAny().As<wxString>() != testString )
|
2010-04-16 14:36:32 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
// Test with a type generated with IMPLEMENT_VARIANT_OBJECT()
|
2018-09-29 01:45:15 +00:00
|
|
|
prop = pgman->GetProperty("ColourProperty");
|
2010-04-16 14:36:32 +00:00
|
|
|
wxColour testCol = *wxCYAN;
|
|
|
|
any = testCol;
|
|
|
|
prop->SetValue(any);
|
2014-05-15 22:32:17 +00:00
|
|
|
if ( prop->GetValue().GetAny().As<wxColour>() != testCol )
|
2010-04-16 14:36:32 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
// Test with a type with custom wxVariantData defined by
|
|
|
|
// wxPG headers.
|
2018-09-29 01:45:15 +00:00
|
|
|
prop = pgman->GetProperty("Position");
|
2010-04-16 14:36:32 +00:00
|
|
|
wxPoint testPoint(199, 199);
|
|
|
|
any = testPoint;
|
|
|
|
prop->SetValue(any);
|
2014-05-15 22:32:17 +00:00
|
|
|
if ( prop->GetValue().GetAny().As<wxPoint>() != testPoint )
|
2010-04-16 14:36:32 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(GetPropertyValues)
|
|
|
|
|
|
|
|
for ( i=0; i<3; i++ )
|
|
|
|
{
|
|
|
|
wxString text;
|
|
|
|
|
|
|
|
wxPropertyGridPage* page = pgman->GetPage(i);
|
|
|
|
|
|
|
|
wxVariant values = page->GetPropertyValues();
|
|
|
|
|
2016-02-18 17:42:06 +00:00
|
|
|
for (unsigned int j = 0; j < (unsigned int)values.GetCount(); j++ )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2016-02-18 17:42:06 +00:00
|
|
|
wxVariant& v = values[j];
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
t.Printf("%i: name=\"%s\" type=\"%s\"\n",(int)j,
|
2018-11-01 23:32:02 +00:00
|
|
|
v.GetName(),v.GetType());
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
text += t;
|
|
|
|
}
|
|
|
|
ed->AppendText(text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
RT_START_TEST(SetPropertyValue_and_GetPropertyValue)
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
// In this section, mixed up usage of "propname" and "propname"
|
2008-09-14 16:48:20 +00:00
|
|
|
// in wxPropertyGridInterface functions is intentional.
|
|
|
|
// Purpose is to test wxPGPropArgCls ctors.
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
//pg = (wxPropertyGrid*) NULL;
|
|
|
|
|
|
|
|
wxArrayString test_arrstr_1;
|
2018-09-29 01:45:15 +00:00
|
|
|
test_arrstr_1.Add("Apple");
|
|
|
|
test_arrstr_1.Add("Orange");
|
|
|
|
test_arrstr_1.Add("Lemon");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxArrayString test_arrstr_2;
|
2018-09-29 01:45:15 +00:00
|
|
|
test_arrstr_2.Add("Potato");
|
|
|
|
test_arrstr_2.Add("Cabbage");
|
|
|
|
test_arrstr_2.Add("Cucumber");
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxArrayInt test_arrint_1;
|
|
|
|
test_arrint_1.Add(1);
|
|
|
|
test_arrint_1.Add(2);
|
|
|
|
test_arrint_1.Add(3);
|
|
|
|
|
|
|
|
wxArrayInt test_arrint_2;
|
|
|
|
test_arrint_2.Add(0);
|
|
|
|
test_arrint_2.Add(1);
|
|
|
|
test_arrint_2.Add(4);
|
|
|
|
|
|
|
|
#if wxUSE_DATETIME
|
|
|
|
wxDateTime dt1 = wxDateTime::Now();
|
|
|
|
dt1.SetYear(dt1.GetYear()-1);
|
|
|
|
|
|
|
|
wxDateTime dt2 = wxDateTime::Now();
|
|
|
|
dt2.SetYear(dt2.GetYear()-10);
|
|
|
|
#endif
|
|
|
|
|
2011-01-02 10:14:29 +00:00
|
|
|
wxColour colWithAlpha(1, 128, 254, 100);
|
|
|
|
wxString colWithAlphaStr(colWithAlpha.GetAsString(wxC2S_CSS_SYNTAX));
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
#define FLAG_TEST_SET1 (wxCAPTION|wxCLOSE_BOX|wxSYSTEM_MENU|wxRESIZE_BORDER)
|
|
|
|
#define FLAG_TEST_SET2 (wxSTAY_ON_TOP|wxCAPTION|wxICONIZE|wxSYSTEM_MENU)
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValue("StringProperty","Text1");
|
|
|
|
pgman->SetPropertyValue("IntProperty",1024);
|
|
|
|
pgman->SetPropertyValue("FloatProperty",1024.0000000001);
|
|
|
|
pgman->SetPropertyValue("BoolProperty",false);
|
|
|
|
pgman->SetPropertyValue("EnumProperty",120);
|
|
|
|
pgman->SetPropertyValue("ArrayStringProperty",test_arrstr_1);
|
2008-09-12 20:57:41 +00:00
|
|
|
wxColour emptyCol;
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValue("ColourProperty",emptyCol);
|
2020-02-03 06:50:32 +00:00
|
|
|
pgman->SetPropertyValue("ColourProperty", const_cast<wxObject*>(static_cast<const wxObject*>(wxBLACK)));
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValue("Size",WXVARIANT(wxSize(150,150)));
|
|
|
|
pgman->SetPropertyValue("Position",WXVARIANT(wxPoint(150,150)));
|
|
|
|
pgman->SetPropertyValue("MultiChoiceProperty",test_arrint_1);
|
2008-09-12 20:57:41 +00:00
|
|
|
#if wxUSE_DATETIME
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValue("DateProperty",dt1);
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
pgman->SelectPage(2);
|
|
|
|
pg = pgman->GetGrid();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pg->GetPropertyValueAsString("StringProperty") != "Text1" )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pg->GetPropertyValueAsInt("IntProperty") != 1024 )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pg->GetPropertyValueAsDouble("FloatProperty") != 1024.0000000001 )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pg->GetPropertyValueAsBool("BoolProperty") != false )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pg->GetPropertyValueAsLong("EnumProperty") != 120 )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pg->GetPropertyValueAsArrayString("ArrayStringProperty") != test_arrstr_1 )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
wxColour col;
|
2018-09-29 01:45:15 +00:00
|
|
|
col << pgman->GetPropertyValue("ColourProperty");
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( col != *wxBLACK )
|
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
wxVariant varSize(pg->GetPropertyValue("Size"));
|
2009-06-07 12:38:39 +00:00
|
|
|
if ( wxSizeRefFromVariant(varSize) != wxSize(150,150) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
wxVariant varPos(pg->GetPropertyValue("Position"));
|
2009-06-07 12:38:39 +00:00
|
|
|
if ( wxPointRefFromVariant(varPos) != wxPoint(150,150) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( !(pg->GetPropertyValueAsArrayInt("MultiChoiceProperty") == test_arrint_1) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
#if wxUSE_DATETIME
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( !(pg->GetPropertyValueAsDateTime("DateProperty") == dt1) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
#endif
|
|
|
|
|
2015-04-03 19:13:44 +00:00
|
|
|
#if wxUSE_LONGLONG && defined(wxLongLong_t)
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValue("IntProperty",wxLL(10000000000));
|
|
|
|
if ( pg->GetPropertyValueAsLongLong("IntProperty") != wxLL(10000000000) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2015-04-03 19:13:44 +00:00
|
|
|
#else
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValue("IntProperty",1000000000);
|
|
|
|
if ( pg->GetPropertyValueAsLong("IntProperty") != 1000000000 )
|
2015-04-03 19:13:44 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
#endif
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyValue("StringProperty","Text2");
|
|
|
|
pg->SetPropertyValue("IntProperty",512);
|
|
|
|
pg->SetPropertyValue("FloatProperty",512.0);
|
|
|
|
pg->SetPropertyValue("BoolProperty",true);
|
|
|
|
pg->SetPropertyValue("EnumProperty",80);
|
|
|
|
pg->SetPropertyValue("ArrayStringProperty",test_arrstr_2);
|
2020-02-03 06:50:32 +00:00
|
|
|
pg->SetPropertyValue("ColourProperty", const_cast<wxObject*>(static_cast<const wxObject*>(wxWHITE)));
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyValue("Size",WXVARIANT(wxSize(300,300)));
|
|
|
|
pg->SetPropertyValue("Position",WXVARIANT(wxPoint(300,300)));
|
|
|
|
pg->SetPropertyValue("MultiChoiceProperty",test_arrint_2);
|
2008-09-12 20:57:41 +00:00
|
|
|
#if wxUSE_DATETIME
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SetPropertyValue("DateProperty",dt2);
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//pg = (wxPropertyGrid*) NULL;
|
|
|
|
|
|
|
|
pgman->SelectPage(0);
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsString("StringProperty") != "Text2" )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsInt("IntProperty") != 512 )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsDouble("FloatProperty") != 512.0 )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsBool("BoolProperty") != true )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsLong("EnumProperty") != 80 )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsArrayString("ArrayStringProperty") != test_arrstr_2 )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
col << pgman->GetPropertyValue("ColourProperty");
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( col != *wxWHITE )
|
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
varSize = pgman->GetPropertyValue("Size");
|
2009-06-07 12:38:39 +00:00
|
|
|
if ( wxSizeRefFromVariant(varSize) != wxSize(300,300) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
varPos = pgman->GetPropertyValue("Position");
|
2009-06-07 12:38:39 +00:00
|
|
|
if ( wxPointRefFromVariant(varPos) != wxPoint(300,300) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( !(pgman->GetPropertyValueAsArrayInt("MultiChoiceProperty") == test_arrint_2) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
#if wxUSE_DATETIME
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( !(pgman->GetPropertyValueAsDateTime("DateProperty") == dt2) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
#endif
|
|
|
|
|
2015-04-03 19:13:44 +00:00
|
|
|
#if wxUSE_LONGLONG && defined(wxLongLong_t)
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValue("IntProperty",wxLL(-80000000000));
|
|
|
|
if ( pgman->GetPropertyValueAsLongLong("IntProperty") != wxLL(-80000000000) )
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_FAILURE();
|
2015-04-03 19:13:44 +00:00
|
|
|
#else
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValue("IntProperty",-1000000000);
|
|
|
|
if ( pgman->GetPropertyValueAsLong("IntProperty") != -1000000000 )
|
2015-04-03 19:13:44 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
#endif
|
2008-09-14 16:20:48 +00:00
|
|
|
|
|
|
|
// Make sure children of composite parent get updated as well
|
2009-01-07 19:00:16 +00:00
|
|
|
// Original string value: "Lamborghini Diablo SV; 5707; [300; 3.9; 8.6] 300000; Not Convertible"
|
2008-09-14 16:20:48 +00:00
|
|
|
|
2008-09-14 16:48:20 +00:00
|
|
|
//
|
2008-09-14 16:20:48 +00:00
|
|
|
// This updates children as well
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString nvs = "Lamborghini Diablo XYZ; 5707; [100; 3.9; 8.6] 3000002; Convertible";
|
2008-09-14 16:48:20 +00:00
|
|
|
pgman->SetPropertyValue("Car", nvs);
|
2008-09-14 16:20:48 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsString("Car.Model") != "Lamborghini Diablo XYZ" )
|
2008-09-14 16:20:48 +00:00
|
|
|
{
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Did not match: Car.Model=%s", pgman->GetPropertyValueAsString("Car.Model")));
|
2008-09-14 16:20:48 +00:00
|
|
|
}
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsInt("Car.Speeds.Max. Speed (mph)") != 100 )
|
2008-09-14 16:20:48 +00:00
|
|
|
{
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Did not match: Car.Speeds.Max. Speed (mph)=%s", pgman->GetPropertyValueAsString("Car.Speeds.Max. Speed (mph)")));
|
2008-09-14 16:20:48 +00:00
|
|
|
}
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsInt("Car.Price ($)") != 3000002 )
|
2008-09-14 16:20:48 +00:00
|
|
|
{
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format(wxS("Did not match: Car.Price ($)=%s"), pgman->GetPropertyValueAsString(wxS("Car.Price ($)"))));
|
2008-09-14 16:20:48 +00:00
|
|
|
}
|
2009-01-07 19:00:16 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( !pgman->GetPropertyValueAsBool("Car.Convertible") )
|
2009-01-07 19:00:16 +00:00
|
|
|
{
|
2018-11-01 23:32:02 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Did not match: Car.Convertible=%s", pgman->GetPropertyValueAsString("Car.Convertible")));
|
2009-01-07 19:00:16 +00:00
|
|
|
}
|
2010-11-20 11:58:54 +00:00
|
|
|
|
|
|
|
// SetPropertyValueString for special cases such as wxColour
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValueString("ColourProperty", "(123,4,255)");
|
|
|
|
col << pgman->GetPropertyValue("ColourProperty");
|
2010-11-20 11:58:54 +00:00
|
|
|
if ( col != wxColour(123, 4, 255) )
|
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValueString("ColourProperty", "#FE860B");
|
|
|
|
col << pgman->GetPropertyValue("ColourProperty");
|
2010-11-20 11:58:54 +00:00
|
|
|
if ( col != wxColour(254, 134, 11) )
|
|
|
|
RT_FAILURE();
|
2011-01-02 10:14:29 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValueString("ColourPropertyWithAlpha",
|
|
|
|
"(10, 20, 30, 128)");
|
|
|
|
col << pgman->GetPropertyValue("ColourPropertyWithAlpha");
|
2011-01-02 10:14:29 +00:00
|
|
|
if ( col != wxColour(10, 20, 30, 128) )
|
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( pgman->GetPropertyValueAsString("ColourPropertyWithAlpha")
|
|
|
|
!= "(10,20,30,128)" )
|
2011-01-02 10:14:29 +00:00
|
|
|
RT_FAILURE();
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
RT_START_TEST(SetPropertyValueUnspecified)
|
|
|
|
|
|
|
|
// Null variant setter tests
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValueUnspecified("StringProperty");
|
|
|
|
pgman->SetPropertyValueUnspecified("IntProperty");
|
|
|
|
pgman->SetPropertyValueUnspecified("FloatProperty");
|
|
|
|
pgman->SetPropertyValueUnspecified("BoolProperty");
|
|
|
|
pgman->SetPropertyValueUnspecified("EnumProperty");
|
|
|
|
pgman->SetPropertyValueUnspecified("ArrayStringProperty");
|
|
|
|
pgman->SetPropertyValueUnspecified("ColourProperty");
|
|
|
|
pgman->SetPropertyValueUnspecified("Size");
|
|
|
|
pgman->SetPropertyValueUnspecified("Position");
|
|
|
|
pgman->SetPropertyValueUnspecified("MultiChoiceProperty");
|
2008-09-12 20:57:41 +00:00
|
|
|
#if wxUSE_DATETIME
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SetPropertyValueUnspecified("DateProperty");
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-08-17 18:36:00 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// Test multiple selection
|
|
|
|
RT_START_TEST(MULTIPLE_SELECTION)
|
|
|
|
if ( !(pgman->GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION) )
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, wxPG_EX_MULTIPLE_SELECTION);
|
2009-08-17 18:36:00 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
|
2016-02-18 17:42:06 +00:00
|
|
|
pg = pgman->GetGrid();
|
2009-08-17 18:36:00 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPGProperty* prop1 = pg->GetProperty("Label");
|
|
|
|
wxPGProperty* prop2 = pg->GetProperty("Cell Text Colour");
|
|
|
|
wxPGProperty* prop3 = pg->GetProperty("Height");
|
|
|
|
wxPGProperty* catProp = pg->GetProperty("Appearance");
|
2009-08-17 18:36:00 +00:00
|
|
|
|
|
|
|
RT_ASSERT( prop1 && prop2 && prop3 );
|
|
|
|
|
|
|
|
pg->ClearSelection();
|
|
|
|
pg->AddToSelection(prop1);
|
|
|
|
pg->AddToSelection(prop2);
|
|
|
|
pg->AddToSelection(prop3);
|
|
|
|
|
|
|
|
// Adding category to selection should fail silently
|
|
|
|
pg->AddToSelection(catProp);
|
|
|
|
|
|
|
|
wxArrayPGProperty selectedProperties = pg->GetSelectedProperties();
|
|
|
|
|
|
|
|
RT_ASSERT( selectedProperties.size() == 3 )
|
|
|
|
RT_ASSERT( pg->IsPropertySelected(prop1) )
|
|
|
|
RT_ASSERT( pg->IsPropertySelected(prop2) )
|
|
|
|
RT_ASSERT( pg->IsPropertySelected(prop3) )
|
|
|
|
RT_ASSERT( !pg->IsPropertySelected(catProp) )
|
|
|
|
|
|
|
|
pg->RemoveFromSelection(prop1);
|
|
|
|
wxArrayPGProperty selectedProperties2 = pg->GetSelectedProperties();
|
|
|
|
|
|
|
|
RT_ASSERT( selectedProperties2.size() == 2 )
|
|
|
|
RT_ASSERT( !pg->IsPropertySelected(prop1) )
|
|
|
|
RT_ASSERT( pg->IsPropertySelected(prop2) )
|
|
|
|
RT_ASSERT( pg->IsPropertySelected(prop3) )
|
|
|
|
|
|
|
|
pg->ClearSelection();
|
|
|
|
|
|
|
|
wxArrayPGProperty selectedProperties3 = pg->GetSelectedProperties();
|
|
|
|
|
|
|
|
RT_ASSERT( selectedProperties3.size() == 0 )
|
|
|
|
RT_ASSERT( !pg->IsPropertySelected(prop1) )
|
|
|
|
RT_ASSERT( !pg->IsPropertySelected(prop2) )
|
|
|
|
RT_ASSERT( !pg->IsPropertySelected(prop3) )
|
|
|
|
|
|
|
|
pg->SelectProperty(prop2);
|
|
|
|
|
|
|
|
RT_ASSERT( !pg->IsPropertySelected(prop1) )
|
|
|
|
RT_ASSERT( pg->IsPropertySelected(prop2) )
|
|
|
|
RT_ASSERT( !pg->IsPropertySelected(prop3) )
|
|
|
|
}
|
|
|
|
|
2018-10-13 09:20:01 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// Test retrieving main parent of the property
|
|
|
|
RT_START_TEST(GetMainParent)
|
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
|
|
|
|
// Simple properties
|
|
|
|
wxPGProperty* prop = pgman->GetProperty("DateProperty");
|
|
|
|
wxPGProperty* parent = prop->GetMainParent();
|
|
|
|
RT_ASSERT(parent->GetName() == "DateProperty");
|
|
|
|
|
|
|
|
prop = pgman->GetProperty("Label");
|
|
|
|
parent = prop->GetMainParent();
|
|
|
|
RT_ASSERT(parent->GetName() == "Label");
|
|
|
|
|
|
|
|
// Properties with children
|
|
|
|
prop = pgman->GetProperty("Font");
|
|
|
|
RT_ASSERT(prop);
|
|
|
|
parent = prop->GetMainParent();
|
|
|
|
RT_ASSERT(parent);
|
|
|
|
RT_ASSERT(parent->GetName() == "Font");
|
|
|
|
|
|
|
|
prop = pgman->GetProperty("Font.Style");
|
|
|
|
RT_ASSERT(prop);
|
|
|
|
parent = prop->GetMainParent();
|
|
|
|
RT_ASSERT(parent);
|
|
|
|
RT_ASSERT(parent->GetName() == "Font");
|
|
|
|
|
|
|
|
prop = pgman->GetProperty("Car");
|
|
|
|
RT_ASSERT(prop);
|
|
|
|
parent = prop->GetMainParent();
|
|
|
|
RT_ASSERT(parent);
|
|
|
|
RT_ASSERT(parent->GetName() == "Car");
|
|
|
|
|
|
|
|
prop = pgman->GetProperty("Car.Model");
|
|
|
|
RT_ASSERT(prop);
|
|
|
|
parent = prop->GetMainParent();
|
|
|
|
RT_ASSERT(parent);
|
|
|
|
RT_ASSERT(parent->GetName() == "Car");
|
|
|
|
|
|
|
|
prop = pgman->GetProperty("Car.Speeds");
|
|
|
|
RT_ASSERT(prop);
|
|
|
|
parent = prop->GetMainParent();
|
|
|
|
RT_ASSERT(parent);
|
|
|
|
RT_ASSERT(parent->GetName() == "Car");
|
|
|
|
|
|
|
|
prop = pgman->GetProperty("3D Object.Triangle 3.A");
|
|
|
|
RT_ASSERT(prop);
|
|
|
|
parent = prop->GetMainParent();
|
|
|
|
RT_ASSERT(parent);
|
|
|
|
RT_ASSERT(parent->GetName() == "3D Object");
|
|
|
|
|
|
|
|
prop = pgman->GetProperty("3D Object.Triangle 3.A.Z");
|
|
|
|
RT_ASSERT(prop);
|
|
|
|
parent = prop->GetMainParent();
|
|
|
|
RT_ASSERT(parent);
|
|
|
|
RT_ASSERT(parent->GetName() == "3D Object");
|
|
|
|
}
|
|
|
|
|
2009-09-01 13:54:41 +00:00
|
|
|
{
|
|
|
|
//
|
|
|
|
// Test label editing
|
|
|
|
RT_START_TEST(LABEL_EDITING)
|
|
|
|
|
2016-02-18 17:42:06 +00:00
|
|
|
pg = pgman->GetGrid();
|
2009-09-01 13:54:41 +00:00
|
|
|
|
|
|
|
// Just mostly test that these won't crash
|
|
|
|
pg->MakeColumnEditable(0, true);
|
|
|
|
pg->MakeColumnEditable(2, true);
|
|
|
|
pg->MakeColumnEditable(0, false);
|
|
|
|
pg->MakeColumnEditable(2, false);
|
2018-09-29 01:45:15 +00:00
|
|
|
pg->SelectProperty("Height");
|
2009-09-01 13:54:41 +00:00
|
|
|
pg->BeginLabelEdit(0);
|
|
|
|
pg->BeginLabelEdit(0);
|
|
|
|
pg->EndLabelEdit(0);
|
|
|
|
pg->EndLabelEdit(0);
|
|
|
|
|
|
|
|
// Recreate grid
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2009-09-01 13:54:41 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
}
|
|
|
|
|
2008-09-25 16:13:32 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(Attributes)
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPGProperty* prop = pgman->GetProperty("StringProperty");
|
2019-05-26 16:52:43 +00:00
|
|
|
prop->SetAttribute("Dummy Attribute", 15L);
|
2008-09-25 16:13:32 +00:00
|
|
|
|
2019-05-26 16:52:43 +00:00
|
|
|
if ( prop->GetAttribute("Dummy Attribute").GetLong() != 15L )
|
2008-09-25 16:13:32 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
prop->SetAttribute("Dummy Attribute", wxVariant());
|
2008-09-25 16:13:32 +00:00
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( !prop->GetAttribute("Dummy Attribute").IsNull() )
|
2008-09-25 16:13:32 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
}
|
|
|
|
|
2019-04-28 13:59:55 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(Attributes with PGManager)
|
|
|
|
|
|
|
|
const long val = 25;
|
|
|
|
pgman->SetPropertyAttribute("IntProperty", "Dummy Attribute", val);
|
|
|
|
if ( pgman->GetPropertyAttribute("IntProperty", "Dummy Attribute").GetLong() != val )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
pgman->SetPropertyAttribute("IntProperty", "Dummy Attribute", wxVariant());
|
|
|
|
if ( !pgman->GetPropertyAttribute("IntProperty", "Dummy Attribute").IsNull() )
|
|
|
|
RT_FAILURE();
|
|
|
|
}
|
|
|
|
|
2019-04-28 14:30:28 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(Getting list of attributes)
|
|
|
|
|
|
|
|
wxPGProperty* prop = pgman->GetProperty("Height");
|
|
|
|
const wxPGAttributeStorage& attrs1 = prop->GetAttributes();
|
|
|
|
if ( attrs1.GetCount() < 1 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
const wxPGAttributeStorage& attrs2 = pgman->GetPropertyAttributes("Height");
|
|
|
|
if ( attrs2.GetCount() != attrs1.GetCount() )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
// Compare both lists
|
|
|
|
wxVariant val1;
|
|
|
|
wxVariant val2;
|
|
|
|
wxPGAttributeStorage::const_iterator it = attrs1.StartIteration();
|
|
|
|
while ( attrs1.GetNext(it, val1) )
|
|
|
|
{
|
|
|
|
val2 = attrs2.FindValue(val1.GetName());
|
|
|
|
if ( val1 != val2 )
|
|
|
|
RT_FAILURE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
RT_START_TEST(Copying list of attributes)
|
|
|
|
|
|
|
|
wxPGAttributeStorage attrs1(pgman->GetPropertyAttributes("Height"));
|
|
|
|
if ( attrs1.GetCount() < 1 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
wxPGAttributeStorage attrs2;
|
|
|
|
attrs2 = attrs1;
|
|
|
|
if ( attrs2.GetCount() != attrs1.GetCount() )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
// Compare both lists
|
|
|
|
wxVariant val1;
|
|
|
|
wxVariant val2;
|
|
|
|
wxPGAttributeStorage::const_iterator it = attrs1.StartIteration();
|
|
|
|
while ( attrs1.GetNext(it, val1) )
|
|
|
|
{
|
|
|
|
val2 = attrs2.FindValue(val1.GetName());
|
|
|
|
if ( val1 != val2 )
|
|
|
|
RT_FAILURE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-25 22:46:22 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(MaxLength)
|
|
|
|
|
|
|
|
wxPGProperty* prop1 = pgman->GetProperty("StringProperty");
|
|
|
|
if ( !prop1->SetMaxLength(10) )
|
|
|
|
RT_FAILURE();
|
|
|
|
if ( prop1->GetMaxLength() != 10 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
if ( !prop1->SetMaxLength(-1) )
|
|
|
|
RT_FAILURE();
|
|
|
|
if ( prop1->GetMaxLength() != 0 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
wxPGProperty* prop2 = pgman->GetProperty("LongStringProp");
|
|
|
|
if ( !prop2->SetMaxLength(20) )
|
|
|
|
RT_FAILURE();
|
|
|
|
if ( prop2->GetMaxLength() != 20 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
wxPGProperty* prop3 = pgman->GetProperty("IntProperty");
|
|
|
|
if ( !prop3->SetMaxLength(30) )
|
|
|
|
RT_FAILURE();
|
|
|
|
if ( prop3->GetMaxLength() != 30 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
wxPGProperty* prop4 = pgman->GetProperty("ArrayStringProperty");
|
|
|
|
if ( !prop4->SetMaxLength(40) )
|
|
|
|
RT_FAILURE();
|
|
|
|
if ( prop4->GetMaxLength() != 40 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
wxPGProperty* prop5 = pgman->GetProperty("EnumProperty");
|
|
|
|
if ( prop5->SetMaxLength(50) )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
wxPGProperty* prop6 = pgman->GetProperty("BoolProperty");
|
|
|
|
if ( prop6->SetMaxLength(60) )
|
|
|
|
RT_FAILURE();
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
RT_START_TEST(MaxLength with PG)
|
|
|
|
pgman->SelectPage(2);
|
|
|
|
pg = pgman->GetGrid();
|
|
|
|
|
|
|
|
wxPGProperty* prop1 = pgman->GetProperty("StringProperty");
|
|
|
|
if ( !pg->SetPropertyMaxLength("StringProperty", 110) )
|
|
|
|
RT_FAILURE();
|
|
|
|
if ( prop1->GetMaxLength() != 110 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
if ( !pg->SetPropertyMaxLength("StringProperty", -1) )
|
|
|
|
RT_FAILURE();
|
|
|
|
if ( prop1->GetMaxLength() != 0 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
wxPGProperty* prop2 = pgman->GetProperty("LongStringProp");
|
|
|
|
if ( !pg->SetPropertyMaxLength("LongStringProp", 120) )
|
|
|
|
RT_FAILURE();
|
|
|
|
if ( prop2->GetMaxLength() != 120 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
wxPGProperty* prop3 = pgman->GetProperty("FloatProperty");
|
|
|
|
if ( !pg->SetPropertyMaxLength("FloatProperty", 130) )
|
|
|
|
RT_FAILURE();
|
|
|
|
if ( prop3->GetMaxLength() != 130 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
if ( pg->SetPropertyMaxLength("ColourProperty", 140) )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
if ( pg->SetPropertyMaxLength("BoolProperty", 150) )
|
|
|
|
RT_FAILURE();
|
|
|
|
}
|
|
|
|
|
2014-05-17 17:22:30 +00:00
|
|
|
#if WXWIN_COMPATIBILITY_3_0
|
2010-12-27 11:25:53 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(DoubleToString)
|
|
|
|
|
|
|
|
// Locale-specific decimal separator
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString sep = wxString::Format("%g", 1.1)[1];
|
2010-12-27 11:25:53 +00:00
|
|
|
|
|
|
|
wxString s;
|
|
|
|
|
|
|
|
if ( wxPropertyGrid::DoubleToString(s, 123.123, 2, true) !=
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString::Format("123%s12", sep) )
|
2010-12-27 11:25:53 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
if ( wxPropertyGrid::DoubleToString(s, -123.123, 4, false) !=
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString::Format("-123%s1230", sep) )
|
2010-12-27 11:25:53 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
if ( wxPropertyGrid::DoubleToString(s, -0.02, 1, false) !=
|
2018-09-29 01:45:15 +00:00
|
|
|
wxString::Format("0%s0", sep) )
|
2010-12-27 11:25:53 +00:00
|
|
|
RT_FAILURE();
|
2018-09-29 01:45:15 +00:00
|
|
|
if ( wxPropertyGrid::DoubleToString(s, -0.000123, 3, true) != "0" )
|
2010-12-27 11:25:53 +00:00
|
|
|
RT_FAILURE();
|
|
|
|
}
|
2014-05-17 17:22:30 +00:00
|
|
|
#endif
|
2010-12-27 11:25:53 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPropertyGridPage* page1;
|
|
|
|
wxPropertyGridPage* page2;
|
|
|
|
wxPropertyGridPage* page3;
|
|
|
|
wxVariant pg1_values;
|
|
|
|
wxVariant pg2_values;
|
|
|
|
wxVariant pg3_values;
|
|
|
|
|
|
|
|
{
|
|
|
|
RT_START_TEST(GetPropertyValues)
|
|
|
|
|
|
|
|
page1 = pgman->GetPage(0);
|
2018-09-29 01:45:15 +00:00
|
|
|
pg1_values = page1->GetPropertyValues("Page1",NULL,wxPG_KEEP_STRUCTURE);
|
2008-09-12 20:57:41 +00:00
|
|
|
page2 = pgman->GetPage(1);
|
2018-09-29 01:45:15 +00:00
|
|
|
pg2_values = page2->GetPropertyValues("Page2",NULL,wxPG_KEEP_STRUCTURE);
|
2008-09-12 20:57:41 +00:00
|
|
|
page3 = pgman->GetPage(2);
|
2018-09-29 01:45:15 +00:00
|
|
|
pg3_values = page3->GetPropertyValues("Page3",NULL,wxPG_KEEP_STRUCTURE);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
RT_START_TEST(SetPropertyValues)
|
|
|
|
|
|
|
|
page1->SetPropertyValues(pg3_values);
|
|
|
|
page2->SetPropertyValues(pg1_values);
|
|
|
|
page3->SetPropertyValues(pg2_values);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 16:40:52 +00:00
|
|
|
if ( !pgman->HasFlag(wxPG_HIDE_CATEGORIES) )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(Collapse_and_GetFirstCategory_and_GetNextCategory)
|
|
|
|
|
|
|
|
for ( i=0; i<3; i++ )
|
|
|
|
{
|
|
|
|
wxPropertyGridPage* page = pgman->GetPage(i);
|
|
|
|
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
|
|
|
|
for ( it = page->GetIterator( wxPG_ITERATE_CATEGORIES );
|
|
|
|
!it.AtEnd();
|
2015-06-13 20:32:14 +00:00
|
|
|
++it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = *it;
|
|
|
|
|
|
|
|
if ( !page->IsPropertyCategory(p) )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
page->Collapse( p );
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
t.Printf("Collapsing: %s\n",page->GetPropertyLabel(p));
|
2008-09-12 20:57:41 +00:00
|
|
|
ed->AppendText(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
RT_START_TEST(Save_And_RestoreEditableState)
|
|
|
|
|
|
|
|
for ( i=0; i<3; i++ )
|
|
|
|
{
|
|
|
|
pgman->SelectPage(i);
|
|
|
|
|
|
|
|
wxString stringState = pgman->SaveEditableState();
|
|
|
|
bool res = pgman->RestoreEditableState(stringState);
|
|
|
|
if ( !res )
|
|
|
|
RT_FAILURE();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-26 16:40:52 +00:00
|
|
|
//if ( !pgman->HasFlag(wxPG_HIDE_CATEGORIES) )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(Expand_and_GetFirstCategory_and_GetNextCategory)
|
|
|
|
|
|
|
|
for ( i=0; i<3; i++ )
|
|
|
|
{
|
|
|
|
wxPropertyGridPage* page = pgman->GetPage(i);
|
|
|
|
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
|
|
|
|
for ( it = page->GetIterator( wxPG_ITERATE_CATEGORIES );
|
|
|
|
!it.AtEnd();
|
2015-06-13 20:32:14 +00:00
|
|
|
++it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
wxPGProperty* p = *it;
|
|
|
|
|
|
|
|
if ( !page->IsPropertyCategory(p) )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
page->Expand( p );
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
t.Printf("Expand: %s\n",page->GetPropertyLabel(p));
|
2008-09-12 20:57:41 +00:00
|
|
|
ed->AppendText(t);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-19 16:57:33 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(Choice_Manipulation)
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
wxPGProperty* enumProp = pgman->GetProperty("EnumProperty");
|
2008-09-19 16:57:33 +00:00
|
|
|
|
|
|
|
pgman->SelectPage(2);
|
|
|
|
pgman->SelectProperty(enumProp);
|
|
|
|
wxASSERT(pgman->GetGrid()->GetSelection() == enumProp);
|
|
|
|
|
|
|
|
const wxPGChoices& choices = enumProp->GetChoices();
|
2018-09-29 01:45:15 +00:00
|
|
|
int ind = enumProp->InsertChoice("New Choice", choices.GetCount()/2);
|
2008-09-19 16:57:33 +00:00
|
|
|
enumProp->DeleteChoice(ind);
|
|
|
|
|
|
|
|
// Recreate the original grid
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2008-09-19 16:57:33 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
}
|
|
|
|
|
2015-06-26 16:40:52 +00:00
|
|
|
//if ( !pgman->HasFlag(wxPG_HIDE_CATEGORIES) )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(RandomCollapse)
|
|
|
|
|
|
|
|
// Select the most error prone page as visible.
|
|
|
|
pgman->SelectPage(1);
|
|
|
|
|
|
|
|
for ( i=0; i<3; i++ )
|
|
|
|
{
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxPGProperty*> arr;
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
wxPropertyGridPage* page = pgman->GetPage(i);
|
|
|
|
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
|
|
|
|
for ( it = page->GetIterator( wxPG_ITERATE_CATEGORIES );
|
|
|
|
!it.AtEnd();
|
2015-06-13 20:32:14 +00:00
|
|
|
++it )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2019-06-16 16:30:44 +00:00
|
|
|
arr.push_back(*it);
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
2015-06-13 20:30:13 +00:00
|
|
|
if ( !arr.empty() )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2019-06-16 16:30:44 +00:00
|
|
|
pgman->Collapse( arr[0] );
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2019-06-16 16:30:44 +00:00
|
|
|
for ( size_t n=arr.size()-1; n>0; n-- )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
2019-06-16 16:30:44 +00:00
|
|
|
pgman->Collapse( arr[n] );
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
RT_START_TEST(EnsureVisible)
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->EnsureVisible("Cell Colour");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
|
2008-12-11 17:11:35 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(RemoveProperty)
|
|
|
|
|
|
|
|
wxPGProperty* p;
|
|
|
|
|
|
|
|
wxPGProperty* origParent =
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->GetProperty("Window Styles")->GetParent();
|
2008-12-11 17:11:35 +00:00
|
|
|
|
2010-10-10 09:34:29 +00:00
|
|
|
// For testing purposes, let's set some custom cell colours
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->GetProperty("Window Styles");
|
2010-10-10 09:34:29 +00:00
|
|
|
p->SetCell(2, wxPGCell("style"));
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->RemoveProperty("Window Styles");
|
2008-12-11 17:11:35 +00:00
|
|
|
pgman->Refresh();
|
|
|
|
pgman->Update();
|
|
|
|
|
|
|
|
pgman->AppendIn(origParent, p);
|
2018-09-29 01:45:15 +00:00
|
|
|
wxASSERT( p->GetCell(2).GetText() == "style");
|
2008-12-11 17:11:35 +00:00
|
|
|
pgman->Refresh();
|
|
|
|
pgman->Update();
|
|
|
|
}
|
|
|
|
|
2009-01-07 18:53:09 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(SortFunction)
|
|
|
|
|
|
|
|
wxPGProperty* p;
|
|
|
|
|
|
|
|
// Make sure indexes are as supposed
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->GetProperty("User Name");
|
2009-01-07 18:53:09 +00:00
|
|
|
if ( p->GetIndexInParent() != 3 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->GetProperty("User Id");
|
2009-01-07 18:53:09 +00:00
|
|
|
if ( p->GetIndexInParent() != 2 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->GetProperty("User Home");
|
2009-01-07 18:53:09 +00:00
|
|
|
if ( p->GetIndexInParent() != 1 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->GetProperty("Operating System");
|
2009-01-07 18:53:09 +00:00
|
|
|
if ( p->GetIndexInParent() != 0 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
pgman->GetGrid()->SetSortFunction(MyPropertySortFunction);
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->GetGrid()->SortChildren("Environment");
|
2009-01-07 18:53:09 +00:00
|
|
|
|
|
|
|
// Make sure indexes have been reversed
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->GetProperty("User Name");
|
2009-01-07 18:53:09 +00:00
|
|
|
if ( p->GetIndexInParent() != 0 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->GetProperty("User Id");
|
2009-01-07 18:53:09 +00:00
|
|
|
if ( p->GetIndexInParent() != 1 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->GetProperty("User Home");
|
2009-01-07 18:53:09 +00:00
|
|
|
if ( p->GetIndexInParent() != 2 )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
2018-09-29 01:45:15 +00:00
|
|
|
p = pgman->GetProperty("Operating System");
|
2009-01-07 18:53:09 +00:00
|
|
|
if ( p->GetIndexInParent() != 3 )
|
|
|
|
RT_FAILURE();
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(SetPropertyBackgroundColour)
|
|
|
|
wxCommandEvent evt;
|
2015-02-08 12:48:43 +00:00
|
|
|
evt.SetInt(1); // IsChecked() will return true.
|
2008-09-12 20:57:41 +00:00
|
|
|
evt.SetId(ID_COLOURSCHEME4);
|
|
|
|
OnCatColours(evt);
|
|
|
|
OnColourScheme(evt);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2009-02-17 18:01:06 +00:00
|
|
|
RT_START_TEST(Clear)
|
|
|
|
|
|
|
|
// Manager clear
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SelectProperty("Label");
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman->Clear();
|
|
|
|
|
|
|
|
if ( pgman->GetPageCount() )
|
|
|
|
RT_FAILURE();
|
2009-02-17 18:01:06 +00:00
|
|
|
|
|
|
|
if ( pgman->GetGrid()->GetRoot()->GetChildCount() )
|
|
|
|
RT_FAILURE();
|
|
|
|
|
|
|
|
// Recreate the original grid
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2009-02-17 18:01:06 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
|
|
|
|
// Grid clear
|
2018-09-29 01:45:15 +00:00
|
|
|
pgman->SelectProperty("Label");
|
2009-02-17 18:01:06 +00:00
|
|
|
pgman->GetGrid()->Clear();
|
|
|
|
|
|
|
|
if ( pgman->GetGrid()->GetRoot()->GetChildCount() )
|
|
|
|
RT_FAILURE();
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
// Recreate the original grid
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
}
|
|
|
|
|
2014-11-15 17:48:54 +00:00
|
|
|
{
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_START_TEST(SetSplitterPosition)
|
|
|
|
|
|
|
|
const int trySplitterPos = 50;
|
2010-09-30 11:44:45 +00:00
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
int style = wxPG_AUTO_SORT; // wxPG_SPLITTER_AUTO_CENTER;
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid(style, -1);
|
|
|
|
pgman = m_pPropGridManager;
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
pgman->SetSplitterPosition(trySplitterPos);
|
|
|
|
|
|
|
|
if ( pgman->GetGrid()->GetSplitterPosition() != trySplitterPos )
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Splitter position was %i (should have been %i)",(int)pgman->GetGrid()->GetSplitterPosition(),trySplitterPos));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
2015-06-14 15:13:21 +00:00
|
|
|
wxSize origSz = GetSize();
|
|
|
|
|
|
|
|
wxSize sz = origSz;
|
2015-06-14 15:10:28 +00:00
|
|
|
sz.IncBy(5, 5);
|
2015-06-14 15:13:21 +00:00
|
|
|
SetSize(sz);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
if ( pgman->GetGrid()->GetSplitterPosition() != trySplitterPos )
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Splitter position was %i (should have been %i)",(int)pgman->GetGrid()->GetSplitterPosition(),trySplitterPos));
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
SetSize(origSz);
|
|
|
|
|
|
|
|
// Recreate the original grid
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman = m_pPropGridManager;
|
2014-11-15 17:48:54 +00:00
|
|
|
}
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
RT_START_TEST(HideProperty)
|
|
|
|
|
|
|
|
wxPropertyGridPage* page = pgman->GetPage(0);
|
|
|
|
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxPGProperty*> arr1 = GetPropertiesInRandomOrder(page);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
if ( !_failed_ )
|
|
|
|
{
|
|
|
|
for ( i=0; i<arr1.size(); i++ )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = arr1[i];
|
|
|
|
page->HideProperty(p, true);
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString s = wxString::Format("HideProperty(%i, %s)", (int)i, p->GetLabel());
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
|
|
|
|
if ( _failed_ )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !_failed_ )
|
|
|
|
{
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxPGProperty*> arr2 = GetPropertiesInRandomOrder(page);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
for ( i=0; i<arr2.size(); i++ )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = arr2[i];
|
|
|
|
page->HideProperty(p, false);
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString s = wxString::Format("ShowProperty(%i, %s)", (int)i, p->GetLabel());
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
|
|
|
|
if ( _failed_ )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Let's do some more, for better consistency
|
|
|
|
arr1 = GetPropertiesInRandomOrder(page);
|
|
|
|
|
|
|
|
if ( !_failed_ )
|
|
|
|
{
|
|
|
|
for ( i=0; i<arr1.size(); i++ )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = arr1[i];
|
|
|
|
page->HideProperty(p, true);
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString s = wxString::Format("HideProperty(%i, %s)", (int)i, p->GetLabel());
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
|
|
|
|
if ( _failed_ )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !_failed_ )
|
|
|
|
{
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxPGProperty*> arr2 = GetPropertiesInRandomOrder(page);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
for ( i=0; i<arr2.size(); i++ )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = arr2[i];
|
|
|
|
page->HideProperty(p, false);
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString s = wxString::Format("ShowProperty(%i, %s)", (int)i, p->GetLabel());
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
|
|
|
|
if ( _failed_ )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Ok, this time only hide half of them
|
|
|
|
arr1 = GetPropertiesInRandomOrder(page);
|
|
|
|
arr1.resize(arr1.size()/2);
|
|
|
|
|
|
|
|
if ( !_failed_ )
|
|
|
|
{
|
|
|
|
for ( i=0; i<arr1.size(); i++ )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = arr1[i];
|
|
|
|
page->HideProperty(p, true);
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString s = wxString::Format("HideProperty(%i, %s)", (int)i, p->GetLabel());
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
|
|
|
|
if ( _failed_ )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !_failed_ )
|
|
|
|
{
|
2019-06-16 16:30:44 +00:00
|
|
|
wxVector<wxPGProperty*> arr2 = GetPropertiesInRandomOrder(page);
|
2008-09-12 20:57:41 +00:00
|
|
|
|
|
|
|
for ( i=0; i<arr2.size(); i++ )
|
|
|
|
{
|
|
|
|
wxPGProperty* p = arr2[i];
|
|
|
|
page->HideProperty(p, false);
|
|
|
|
|
2018-11-01 23:32:02 +00:00
|
|
|
wxString s = wxString::Format("ShowProperty(%i, %s)", (int)i, p->GetLabel());
|
2008-09-12 20:57:41 +00:00
|
|
|
RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
|
|
|
|
if ( _failed_ )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Recreate the original grid
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
}
|
|
|
|
|
2015-06-14 14:56:06 +00:00
|
|
|
{
|
|
|
|
RT_START_TEST(SetFlagsAsString and GetFlagsAsString)
|
|
|
|
|
|
|
|
// Select the most error prone page as visible.
|
|
|
|
pgman->SelectPage(1);
|
|
|
|
|
|
|
|
for ( i = 0; i < 3; i++ )
|
|
|
|
{
|
|
|
|
wxPropertyGridPage* page = pgman->GetPage(i);
|
|
|
|
|
|
|
|
wxPropertyGridIterator it;
|
|
|
|
for ( it = page->GetIterator(wxPG_ITERATE_VISIBLE);
|
|
|
|
!it.AtEnd();
|
|
|
|
++it )
|
|
|
|
{
|
|
|
|
wxPGProperty *p = *it;
|
|
|
|
|
|
|
|
// Save initial flags
|
|
|
|
wxPGProperty::FlagType oldFlags = 0;
|
|
|
|
if( p->HasFlag(wxPG_PROP_COLLAPSED) )
|
|
|
|
{
|
|
|
|
oldFlags |= wxPG_PROP_COLLAPSED;
|
|
|
|
}
|
|
|
|
if( p->HasFlag(wxPG_PROP_DISABLED) )
|
|
|
|
{
|
|
|
|
oldFlags |= wxPG_PROP_DISABLED;
|
|
|
|
}
|
|
|
|
if( p->HasFlag(wxPG_PROP_HIDDEN) )
|
|
|
|
{
|
|
|
|
oldFlags |= wxPG_PROP_HIDDEN;
|
|
|
|
}
|
|
|
|
if( p->HasFlag(wxPG_PROP_NOEDITOR) )
|
|
|
|
{
|
|
|
|
oldFlags |= wxPG_PROP_NOEDITOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString flags;
|
|
|
|
|
|
|
|
if ( p->IsCategory() )
|
|
|
|
{
|
|
|
|
if ( GetRandomBooleanVal() )
|
|
|
|
{
|
|
|
|
if ( !flags.empty() )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
flags.append("|");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
2018-10-01 11:55:42 +00:00
|
|
|
flags.append("COLLAPSED");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GetRandomBooleanVal() )
|
|
|
|
{
|
|
|
|
if ( !flags.empty() )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
flags.append("|");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
2018-10-01 11:55:42 +00:00
|
|
|
flags.append("DISABLED");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( GetRandomBooleanVal() )
|
|
|
|
{
|
|
|
|
if ( !flags.empty() )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
flags.append("|");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
2018-10-01 11:55:42 +00:00
|
|
|
flags.append("HIDDEN");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set flags
|
|
|
|
p->SetFlagsFromString(flags);
|
|
|
|
|
|
|
|
// Verify if flags have been properly set
|
2018-10-01 11:55:42 +00:00
|
|
|
if ( flags.Find("COLLAPSED") != wxNOT_FOUND &&
|
2015-06-14 14:56:06 +00:00
|
|
|
!p->HasFlag(wxPG_PROP_COLLAPSED) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Error setting flag from string 'COLLAPSED' for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
2018-10-01 11:55:42 +00:00
|
|
|
if ( flags.Find("COLLAPSED") == wxNOT_FOUND &&
|
2015-06-14 14:56:06 +00:00
|
|
|
p->HasFlag(wxPG_PROP_COLLAPSED) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Error resetting flag from string 'COLLAPSED'for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
2018-10-01 11:55:42 +00:00
|
|
|
if ( flags.Find("DISABLED") != wxNOT_FOUND &&
|
2015-06-14 14:56:06 +00:00
|
|
|
!p->HasFlag(wxPG_PROP_DISABLED) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Error setting flag from string 'DISABLED' for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
2018-10-01 11:55:42 +00:00
|
|
|
if ( flags.Find("DISABLED") == wxNOT_FOUND &&
|
2015-06-14 14:56:06 +00:00
|
|
|
p->HasFlag(wxPG_PROP_DISABLED) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Error resetting flag from string 'DISABLED' for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
2018-10-01 11:55:42 +00:00
|
|
|
if ( flags.Find("HIDDEN") != wxNOT_FOUND &&
|
2015-06-14 14:56:06 +00:00
|
|
|
!p->HasFlag(wxPG_PROP_HIDDEN) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Error setting flag from string 'HIDDEN' for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
2018-10-01 11:55:42 +00:00
|
|
|
if ( flags.Find("HIDDEN") == wxNOT_FOUND &&
|
2015-06-14 14:56:06 +00:00
|
|
|
p->HasFlag(wxPG_PROP_HIDDEN) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Error resetting flag from string 'HIDDEN' for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get individual flags
|
|
|
|
bool ok;
|
|
|
|
|
|
|
|
flags = p->GetFlagsAsString(wxPG_PROP_COLLAPSED);
|
|
|
|
if ( p->HasFlag(wxPG_PROP_COLLAPSED) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags == "COLLAPSED");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok = flags.empty();
|
|
|
|
}
|
|
|
|
if ( !ok )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_COLLAPSED flag for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
flags = p->GetFlagsAsString(wxPG_PROP_DISABLED);
|
|
|
|
if ( p->HasFlag(wxPG_PROP_DISABLED) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags == "DISABLED");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok = flags.empty();
|
|
|
|
}
|
|
|
|
if ( !ok )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_DISABLED flag for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
flags = p->GetFlagsAsString(wxPG_PROP_HIDDEN);
|
|
|
|
if ( p->HasFlag(wxPG_PROP_HIDDEN) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags == "HIDDEN");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok = flags.empty();
|
|
|
|
}
|
|
|
|
if ( !ok )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_HIDDEN flag for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
flags = p->GetFlagsAsString(wxPG_PROP_NOEDITOR);
|
|
|
|
if ( p->HasFlag(wxPG_PROP_NOEDITOR) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags == "NOEDITOR");
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ok = flags.empty();
|
|
|
|
}
|
|
|
|
if ( !ok )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_NOEDITOR flag for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get all flags
|
|
|
|
flags = p->GetFlagsAsString(wxPG_STRING_STORED_FLAGS);
|
|
|
|
if ( p->HasFlag(wxPG_PROP_COLLAPSED) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags.Find("COLLAPSED") != wxNOT_FOUND);
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags.Find("COLLAPSED") == wxNOT_FOUND);
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
if ( !ok )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_COLLAPSED flag for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( p->HasFlag(wxPG_PROP_DISABLED) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags.Find("DISABLED") != wxNOT_FOUND);
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags.Find("DISABLED") == wxNOT_FOUND);
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
if ( !ok )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_DISBALED flag for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( p->HasFlag(wxPG_PROP_HIDDEN) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags.Find("HIDDEN") != wxNOT_FOUND);
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags.Find("HIDDEN") == wxNOT_FOUND);
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
if ( !ok )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_HIDDEN flag for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( p->HasFlag(wxPG_PROP_NOEDITOR) )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags.Find("NOEDITOR") != wxNOT_FOUND);
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
ok = (flags.Find("NOEDITOR") == wxNOT_FOUND);
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
if ( !ok )
|
|
|
|
{
|
2018-10-01 11:55:42 +00:00
|
|
|
RT_FAILURE_MSG(wxString::Format("Invalid string for wxPG_PROP_NOEDITOR flag for property '%s'",
|
2018-11-01 23:32:02 +00:00
|
|
|
p->GetName()));
|
2015-06-14 14:56:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Restore original flags
|
|
|
|
p->ChangeFlag(wxPG_PROP_COLLAPSED, (oldFlags & wxPG_PROP_COLLAPSED) != 0);
|
|
|
|
p->ChangeFlag(wxPG_PROP_DISABLED, (oldFlags & wxPG_PROP_DISABLED) != 0);
|
|
|
|
p->ChangeFlag(wxPG_PROP_HIDDEN, (oldFlags & wxPG_PROP_HIDDEN) != 0);
|
|
|
|
p->ChangeFlag(wxPG_PROP_NOEDITOR, (oldFlags & wxPG_PROP_NOEDITOR) != 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-09-12 20:57:41 +00:00
|
|
|
if ( fullTest )
|
|
|
|
{
|
|
|
|
RT_START_TEST(MultipleColumns)
|
|
|
|
|
|
|
|
// Test with multiple columns
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2015-02-18 17:17:23 +00:00
|
|
|
pgman = m_pPropGridManager;
|
2008-09-12 20:57:41 +00:00
|
|
|
for ( i=3; i<12; i+=2 )
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_MSG(wxString::Format("%i columns",(int)i));
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman->SetColumnCount(i);
|
|
|
|
Refresh();
|
|
|
|
Update();
|
|
|
|
wxMilliSleep(500);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( fullTest )
|
|
|
|
{
|
|
|
|
RT_START_TEST(WindowStyles)
|
|
|
|
|
|
|
|
// Recreate grid with all possible (single) flags
|
|
|
|
wxASSERT(wxPG_AUTO_SORT == 0x000000010);
|
|
|
|
|
|
|
|
for ( i=4; i<16; i++ )
|
|
|
|
{
|
|
|
|
int flag = 1<<i;
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_MSG(wxString::Format("Style: 0x%X",flag));
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( flag, -1 );
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
Update();
|
|
|
|
wxMilliSleep(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
wxASSERT(wxPG_EX_INIT_NOCAT == 0x00001000);
|
|
|
|
|
2009-08-29 08:09:45 +00:00
|
|
|
for ( i=12; i<27; i++ )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
int flag = 1<<i;
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_MSG(wxString::Format("ExStyle: 0x%X",flag));
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, flag );
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
Update();
|
|
|
|
wxMilliSleep(500);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Recreate the original grid
|
2020-04-18 19:43:54 +00:00
|
|
|
ReplaceGrid( -1, -1 );
|
2008-09-12 20:57:41 +00:00
|
|
|
pgman = m_pPropGridManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
RT_START_TEST(none)
|
|
|
|
|
|
|
|
bool retVal;
|
|
|
|
|
2015-06-13 20:30:13 +00:00
|
|
|
if ( failures || !errorMessages.empty() )
|
2008-09-12 20:57:41 +00:00
|
|
|
{
|
|
|
|
retVal = false;
|
|
|
|
|
|
|
|
wxString s;
|
|
|
|
#ifdef __WXDEBUG__
|
|
|
|
if ( failures )
|
|
|
|
#endif
|
2018-09-29 01:45:15 +00:00
|
|
|
s = wxString::Format("%i tests failed!!!", failures);
|
2008-09-12 20:57:41 +00:00
|
|
|
#ifdef __WXDEBUG__
|
|
|
|
else
|
2018-09-29 01:45:15 +00:00
|
|
|
s = wxString::Format("All tests were successful, but there were %i warnings!", wxPGGlobalVars->m_warnings);
|
2008-09-12 20:57:41 +00:00
|
|
|
#endif
|
|
|
|
RT_MSG(s)
|
|
|
|
for ( i=0; i<errorMessages.size(); i++ )
|
|
|
|
RT_MSG(errorMessages[i])
|
2018-09-29 01:45:15 +00:00
|
|
|
wxMessageBox(s, "Some Tests Failed");
|
2008-09-12 20:57:41 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-29 01:45:15 +00:00
|
|
|
RT_MSG("All tests successful")
|
2008-09-12 20:57:41 +00:00
|
|
|
retVal = true;
|
|
|
|
|
|
|
|
if ( !interactive )
|
|
|
|
dlg->Close();
|
|
|
|
}
|
|
|
|
|
|
|
|
pgman->SelectPage(0);
|
|
|
|
|
|
|
|
// Test may screw up the toolbar, so we need to refresh it.
|
|
|
|
wxToolBar* toolBar = pgman->GetToolBar();
|
|
|
|
if ( toolBar )
|
|
|
|
toolBar->Refresh();
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|