]> git.saurik.com Git - wxWidgets.git/blame - samples/propgrid/tests.cpp
Do not use deprecated property attribute wxPG_ATTR_INLINE_HELP (fixes #11605)
[wxWidgets.git] / samples / propgrid / tests.cpp
CommitLineData
1c4293cb
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: samples/propgrid/tests.cpp
3// Purpose: wxPropertyGrid tests
4// Author: Jaakko Salli
5// Modified by:
6// Created: 2007-05-16
ea5af9c5 7// RCS-ID: $Id$
1c4293cb
VZ
8// Copyright: (c) Jaakko Salli
9// Licence: wxWindows license
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18#ifndef WX_PRECOMP
19 #include "wx/wx.h"
20#endif
21
22#include <wx/propgrid/propgrid.h>
23#include <wx/propgrid/advprops.h>
24#include <wx/propgrid/manager.h>
25
26#include "propgrid.h"
27#include "sampleprops.h"
28
29
1c4293cb
VZ
30// -----------------------------------------------------------------------
31// wxTestCustomFlagsProperty
32// -----------------------------------------------------------------------
33
1c4293cb
VZ
34//
35// Test customizing wxColourProperty via subclassing
36//
37// * Includes custom colour entry.
38// * Includes extra custom entry.
39//
d61d8cff 40class MyColourProperty : public wxColourProperty
1c4293cb
VZ
41{
42public:
d61d8cff 43 MyColourProperty( const wxString& label = wxPG_LABEL,
1c4293cb
VZ
44 const wxString& name = wxPG_LABEL,
45 const wxColour& value = *wxWHITE )
46 : wxColourProperty(label, name, value)
47 {
48 wxPGChoices colours;
49 colours.Add(wxT("White"));
50 colours.Add(wxT("Black"));
51 colours.Add(wxT("Red"));
52 colours.Add(wxT("Green"));
53 colours.Add(wxT("Blue"));
54 colours.Add(wxT("Custom"));
55 colours.Add(wxT("None"));
56 m_choices = colours;
57 SetIndex(0);
58 wxVariant variant;
59 variant << value;
60 SetValue(variant);
61 }
62
d61d8cff 63 virtual ~MyColourProperty()
1c4293cb
VZ
64 {
65 }
66
67 virtual wxColour GetColour( int index ) const
68 {
69 switch (index)
70 {
71 case 0: return *wxWHITE;
72 case 1: return *wxBLACK;
73 case 2: return *wxRED;
74 case 3: return *wxGREEN;
75 case 4: return *wxBLUE;
76 case 5:
77 // Return current colour for the custom entry
78 wxColour col;
79 if ( GetIndex() == GetCustomColourIndex() )
80 {
81 if ( m_value.IsNull() )
82 return col;
83 col << m_value;
84 return col;
85 }
86 return *wxWHITE;
87 };
88 return wxColour();
89 }
90
91 virtual wxString ColourToString( const wxColour& col, int index ) const
92 {
93 if ( index == (int)(m_choices.GetCount()-1) )
94 return wxT("");
95
96 return wxColourProperty::ColourToString(col, index);
97 }
98
99 virtual int GetCustomColourIndex() const
100 {
101 return m_choices.GetCount()-2;
102 }
103};
104
105
106void FormMain::AddTestProperties( wxPropertyGridPage* pg )
107{
d61d8cff
JS
108 pg->Append( new MyColourProperty(wxT("CustomColourProperty"), wxPG_LABEL, *wxGREEN) );
109 pg->GetProperty(wxT("CustomColourProperty"))->SetFlag(wxPG_PROP_AUTO_UNSPECIFIED);
110 pg->SetPropertyEditor( wxT("CustomColourProperty"), wxPGEditor_ComboBox );
1c4293cb 111
d61d8cff
JS
112 pg->SetPropertyHelpString(wxT("CustomColourProperty"),
113 wxT("This is a MyColourProperty from the sample app. ")
1c4293cb 114 wxT("It is built by subclassing wxColourProperty."));
1c4293cb
VZ
115}
116
117// -----------------------------------------------------------------------
118
119void FormMain::OnDumpList( wxCommandEvent& WXUNUSED(event) )
120{
121 wxVariant values = m_pPropGridManager->GetPropertyValues(wxT("list"), wxNullProperty, wxPG_INC_ATTRIBUTES);
122 wxString text = wxT("This only tests that wxVariant related routines do not crash.");
123 wxString t;
124
125 wxDialog* dlg = new wxDialog(this,-1,wxT("wxVariant Test"),
126 wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
127
128 unsigned int i;
129 for ( i = 0; i < (unsigned int)values.GetCount(); i++ )
130 {
131 wxVariant& v = values[i];
132
133 wxString strValue = v.GetString();
134
135#if wxCHECK_VERSION(2,8,0)
136 if ( v.GetName().EndsWith(wxT("@attr")) )
137#else
138 if ( v.GetName().Right(5) == wxT("@attr") )
139#endif
140 {
141 text += wxString::Format(wxT("Attributes:\n"));
142
143 unsigned int n;
144 for ( n = 0; n < (unsigned int)v.GetCount(); n++ )
145 {
146 wxVariant& a = v[n];
147
148 t.Printf(wxT(" atribute %i: name=\"%s\" (type=\"%s\" value=\"%s\")\n"),(int)n,
149 a.GetName().c_str(),a.GetType().c_str(),a.GetString().c_str());
150 text += t;
151 }
152 }
153 else
154 {
155 t.Printf(wxT("%i: name=\"%s\" type=\"%s\" value=\"%s\"\n"),(int)i,
156 v.GetName().c_str(),v.GetType().c_str(),strValue.c_str());
157 text += t;
158 }
159 }
160
161 // multi-line text editor dialog
162 const int spacing = 8;
163 wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
164 wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
cd644aa1
JS
165 wxTextCtrl* ed = new wxTextCtrl(dlg, 11, text,
166 wxDefaultPosition, wxDefaultSize,
167 wxTE_MULTILINE);
1c4293cb
VZ
168 rowsizer->Add( ed, 1, wxEXPAND|wxALL, spacing );
169 topsizer->Add( rowsizer, 1, wxEXPAND, 0 );
170 rowsizer = new wxBoxSizer( wxHORIZONTAL );
171 const int butSzFlags =
172 wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT;
173 rowsizer->Add( new wxButton(dlg,wxID_OK,wxT("Ok")),
174 0, butSzFlags, spacing );
175 topsizer->Add( rowsizer, 0, wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL, 0 );
176
177 dlg->SetSizer( topsizer );
178 topsizer->SetSizeHints( dlg );
179
180 dlg->SetSize(400,300);
181 dlg->Centre();
182 dlg->ShowModal();
183}
184
185// -----------------------------------------------------------------------
186
187class TestRunner
188{
189public:
190
191 TestRunner( const wxString& name, wxPropertyGridManager* man, wxTextCtrl* ed, wxArrayString* errorMessages )
192 {
193 m_name = name;
194 m_man = man;
195 m_ed = ed;
196 m_errorMessages = errorMessages;
197#ifdef __WXDEBUG__
198 m_preWarnings = wxPGGlobalVars->m_warnings;
199#endif
200
201 if ( name != wxT("none") )
202 Msg(name+wxT("\n"));
203 }
204
205 ~TestRunner()
206 {
207#ifdef __WXDEBUG__
208 int warningsOccurred = wxPGGlobalVars->m_warnings - m_preWarnings;
209 if ( warningsOccurred )
210 {
211 wxString s = wxString::Format(wxT("%i warnings occurred during test '%s'"), warningsOccurred, m_name.c_str());
212 m_errorMessages->push_back(s);
213 Msg(s);
214 }
215#endif
216 }
217
218 void Msg( const wxString& text )
219 {
220 if ( m_ed )
221 {
222 m_ed->AppendText(text);
223 m_ed->AppendText(wxT("\n"));
224 }
225 wxLogDebug(text);
226 }
227
228protected:
229 wxPropertyGridManager* m_man;
230 wxTextCtrl* m_ed;
231 wxArrayString* m_errorMessages;
232 wxString m_name;
233#ifdef __WXDEBUG__
234 int m_preWarnings;
235#endif
236};
237
238
239#define RT_START_TEST(TESTNAME) \
240 TestRunner tr(wxT(#TESTNAME), pgman, ed, &errorMessages);
241
242#define RT_MSG(S) \
243 tr.Msg(S);
244
245#define RT_FAILURE() \
246 { \
247 wxString s1 = wxString::Format(wxT("Test failure in tests.cpp, line %i."),__LINE__-1); \
248 errorMessages.push_back(s1); \
249 wxLogDebug(s1); \
250 failures++; \
251 }
252
fc72fab6
JS
253#define RT_ASSERT(COND) \
254 if (!(COND)) \
255 RT_FAILURE()
256
1c4293cb
VZ
257#define RT_FAILURE_MSG(MSG) \
258 { \
259 wxString s1 = wxString::Format(wxT("Test failure in tests.cpp, line %i."),__LINE__-1); \
260 errorMessages.push_back(s1); \
261 wxLogDebug(s1); \
262 wxString s2 = wxString::Format(wxT("Message: %s"),MSG); \
263 errorMessages.push_back(s2); \
264 wxLogDebug(s2); \
265 failures++; \
266 }
267
268#define RT_VALIDATE_VIRTUAL_HEIGHT(PROPS, EXTRATEXT) \
269 { \
270 unsigned int h1_ = PROPS->GetVirtualHeight(); \
271 unsigned int h2_ = PROPS->GetActualVirtualHeight(); \
272 if ( h1_ != h2_ ) \
273 { \
274 wxString s_ = wxString::Format(wxT("VirtualHeight = %i, should be %i (%s)"), h1_, h2_, EXTRATEXT.c_str()); \
275 RT_FAILURE_MSG(s_.c_str()); \
276 _failed_ = true; \
277 } \
278 else \
279 { \
280 _failed_ = false; \
281 } \
282 }
283
284
285int gpiro_cmpfunc(const void* a, const void* b)
286{
287 const wxPGProperty* p1 = (const wxPGProperty*) a;
288 const wxPGProperty* p2 = (const wxPGProperty*) b;
289 return (int) (((size_t)p1->GetClientData()) - ((size_t)p2->GetClientData()));
290}
291
292wxArrayPGProperty GetPropertiesInRandomOrder( wxPropertyGridInterface* props, int iterationFlags = wxPG_ITERATE_ALL )
293{
294 wxArrayPGProperty arr;
295
296 wxPropertyGridIterator it;
297
298 for ( it = props->GetIterator(iterationFlags);
299 !it.AtEnd();
300 it++ )
301 {
302 wxPGProperty* p = *it;
303 size_t randomNumber = rand();
304 p->SetClientData(reinterpret_cast<void*>(randomNumber));
305 arr.push_back(p);
306 }
307
308 wxPGProperty** firstEntry = &arr[0];
309 qsort(firstEntry, arr.size(), sizeof(wxPGProperty*), gpiro_cmpfunc);
310
311 return arr;
312}
313
43396981
JS
314// Callback for testing property sorting
315int MyPropertySortFunction(wxPropertyGrid* WXUNUSED(propGrid),
316 wxPGProperty* p1,
317 wxPGProperty* p2)
318{
319 // Reverse alphabetical order
320 return p2->GetLabel().CmpNoCase( p1->GetBaseName() );
321}
322
1c4293cb
VZ
323bool FormMain::RunTests( bool fullTest, bool interactive )
324{
325 wxString t;
326
327 wxPropertyGridManager* pgman = m_pPropGridManager;
328 wxPropertyGrid* pg;
329
330 size_t i;
331
332 pgman->ClearSelection();
333
334 int failures = 0;
335 bool _failed_ = false;
336 wxArrayString errorMessages;
337 wxDialog* dlg = NULL;
338
339 dlg = new wxDialog(this,-1,wxT("wxPropertyGrid Regression Tests"),
340 wxDefaultPosition,wxDefaultSize,wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER);
341
342 // multi-line text editor dialog
343 const int spacing = 8;
344 wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
345 wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
cd644aa1
JS
346 wxTextCtrl* ed = new wxTextCtrl(dlg, 11, wxEmptyString,
347 wxDefaultPosition, wxDefaultSize,
348 wxTE_MULTILINE);
1c4293cb
VZ
349 rowsizer->Add( ed, 1, wxEXPAND|wxALL, spacing );
350 topsizer->Add( rowsizer, 1, wxEXPAND, 0 );
351 rowsizer = new wxBoxSizer( wxHORIZONTAL );
352 const int butSzFlags =
353 wxALIGN_CENTRE_HORIZONTAL|wxALIGN_CENTRE_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT;
354 rowsizer->Add( new wxButton(dlg,wxID_OK,wxT("Ok")),
355 0, butSzFlags, spacing );
356 topsizer->Add( rowsizer, 0, wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL, 0 );
357
358 dlg->SetSizer( topsizer );
359 topsizer->SetSizeHints( dlg );
360
361 dlg->SetSize(400,300);
362 dlg->Move(wxSystemSettings::GetMetric(wxSYS_SCREEN_X)-dlg->GetSize().x,
363 wxSystemSettings::GetMetric(wxSYS_SCREEN_Y)-dlg->GetSize().y);
364 dlg->Show();
365
366 {
367 //
368 // Basic iterator tests
369 RT_START_TEST(GetIterator)
370
371 wxPGVIterator it;
372 int count;
373
374 count = 0;
375 for ( it = pgman->GetVIterator(wxPG_ITERATE_PROPERTIES);
376 !it.AtEnd();
377 it.Next() )
378 {
379 wxPGProperty* p = it.GetProperty();
380 if ( p->IsCategory() )
381 RT_FAILURE_MSG(wxString::Format(wxT("'%s' is a category (non-private child property expected)"),p->GetLabel().c_str()).c_str())
382 else if ( p->GetParent()->HasFlag(wxPG_PROP_AGGREGATE) )
383 RT_FAILURE_MSG(wxString::Format(wxT("'%s' is a private child (non-private child property expected)"),p->GetLabel().c_str()).c_str())
384 count++;
385 }
386
387 RT_MSG(wxString::Format(wxT("GetVIterator(wxPG_ITERATE_PROPERTIES) -> %i entries"), count));
388
389 count = 0;
390 for ( it = pgman->GetVIterator(wxPG_ITERATE_CATEGORIES);
391 !it.AtEnd();
392 it.Next() )
393 {
394 wxPGProperty* p = it.GetProperty();
395 if ( !p->IsCategory() )
396 RT_FAILURE_MSG(wxString::Format(wxT("'%s' is not a category (only category was expected)"),p->GetLabel().c_str()).c_str())
397 count++;
398 }
399
400 RT_MSG(wxString::Format(wxT("GetVIterator(wxPG_ITERATE_CATEGORIES) -> %i entries"), count));
401
402 count = 0;
403 for ( it = pgman->GetVIterator(wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_CATEGORIES);
404 !it.AtEnd();
405 it.Next() )
406 {
407 wxPGProperty* p = it.GetProperty();
408 if ( p->GetParent()->HasFlag(wxPG_PROP_AGGREGATE) )
409 RT_FAILURE_MSG(wxString::Format(wxT("'%s' is a private child (non-private child property or category expected)"),p->GetLabel().c_str()).c_str())
410 count++;
411 }
412
413 RT_MSG(wxString::Format(wxT("GetVIterator(wxPG_ITERATE_PROPERTIES|wxPG_ITERATE_CATEGORIES) -> %i entries"), count));
414
415 count = 0;
416 for ( it = pgman->GetVIterator(wxPG_ITERATE_VISIBLE);
417 !it.AtEnd();
418 it.Next() )
419 {
420 wxPGProperty* p = it.GetProperty();
421 if ( (p->GetParent() != p->GetParentState()->DoGetRoot() && !p->GetParent()->IsExpanded()) )
422 RT_FAILURE_MSG(wxString::Format(wxT("'%s' had collapsed parent (only visible properties expected)"),p->GetLabel().c_str()).c_str())
423 else if ( p->HasFlag(wxPG_PROP_HIDDEN) )
424 RT_FAILURE_MSG(wxString::Format(wxT("'%s' was hidden (only visible properties expected)"),p->GetLabel().c_str()).c_str())
425 count++;
426 }
427
428 RT_MSG(wxString::Format(wxT("GetVIterator(wxPG_ITERATE_VISIBLE) -> %i entries"), count));
429 }
430
431 if ( fullTest )
432 {
433 // Test that setting focus to properties does not crash things
434 RT_START_TEST(SelectProperty)
435
436 wxPropertyGridIterator it;
437 size_t ind;
438
439 for ( ind=0; ind<pgman->GetPageCount(); ind++ )
440 {
441 wxPropertyGridPage* page = pgman->GetPage(ind);
442 pgman->SelectPage(page);
443
444 for ( it = page->GetIterator(wxPG_ITERATE_VISIBLE);
445 !it.AtEnd();
446 it++ )
447 {
448 wxPGProperty* p = *it;
449 RT_MSG(p->GetLabel());
450 pgman->GetGrid()->SelectProperty(p, true);
451 ::wxMilliSleep(150);
452 Update();
453 }
454 }
455 }
456
1c4293cb
VZ
457 {
458 //
459 // Delete everything in reverse order
460 RT_START_TEST(DeleteProperty)
461
462 wxPGVIterator it;
463 wxArrayPGProperty array;
464
465 for ( it = pgman->GetVIterator(wxPG_ITERATE_ALL&~(wxPG_IT_CHILDREN(wxPG_PROP_AGGREGATE)));
466 !it.AtEnd();
467 it.Next() )
468 array.push_back(it.GetProperty());
469
470 wxArrayPGProperty::reverse_iterator it2;
471
472 for ( it2 = array.rbegin(); it2 != array.rend(); it2++ )
473 {
474 wxPGProperty* p = (wxPGProperty*)*it2;
475 RT_MSG(wxString::Format(wxT("Deleting '%s' ('%s')"),p->GetLabel().c_str(),p->GetName().c_str()));
476 pgman->DeleteProperty(p);
477 }
478
479 // Recreate grid
480 CreateGrid( -1, -1 );
481 pgman = m_pPropGridManager;
482 }
483
484 {
485 //
ba9ed9d0
JS
486 // Test property default values
487 RT_START_TEST(Default_Values)
1c4293cb
VZ
488
489 wxPGVIterator it;
490
491 for ( it = pgman->GetVIterator(wxPG_ITERATE_PROPERTIES);
492 !it.AtEnd();
493 it.Next() )
494 {
ba9ed9d0
JS
495 wxPGProperty* p = it.GetProperty();
496 pgman->SetPropertyValue(p, p->GetDefaultValue());
1c4293cb
VZ
497 }
498
499 // Recreate grid
500 CreateGrid( -1, -1 );
501 pgman = m_pPropGridManager;
502 }
503
504 {
505 RT_START_TEST(GetPropertyValues)
506
507 for ( i=0; i<3; i++ )
508 {
509 wxString text;
510
511 wxPropertyGridPage* page = pgman->GetPage(i);
512
513 wxVariant values = page->GetPropertyValues();
514
515 unsigned int i;
516 for ( i = 0; i < (unsigned int)values.GetCount(); i++ )
517 {
518 wxVariant& v = values[i];
519
520 t.Printf(wxT("%i: name=\"%s\" type=\"%s\"\n"),(int)i,
521 v.GetName().c_str(),v.GetType().c_str());
522
523 text += t;
524 }
525 ed->AppendText(text);
526 }
527 }
528
529 {
530 RT_START_TEST(SetPropertyValue_and_GetPropertyValue)
531
f3793429
JS
532 // In this section, mixed up usage of wxT("propname") and "propname"
533 // in wxPropertyGridInterface functions is intentional.
534 // Purpose is to test wxPGPropArgCls ctors.
535
1c4293cb
VZ
536 //pg = (wxPropertyGrid*) NULL;
537
538 wxArrayString test_arrstr_1;
539 test_arrstr_1.Add(wxT("Apple"));
540 test_arrstr_1.Add(wxT("Orange"));
541 test_arrstr_1.Add(wxT("Lemon"));
542
543 wxArrayString test_arrstr_2;
544 test_arrstr_2.Add(wxT("Potato"));
545 test_arrstr_2.Add(wxT("Cabbage"));
546 test_arrstr_2.Add(wxT("Cucumber"));
547
548 wxArrayInt test_arrint_1;
549 test_arrint_1.Add(1);
550 test_arrint_1.Add(2);
551 test_arrint_1.Add(3);
552
553 wxArrayInt test_arrint_2;
554 test_arrint_2.Add(0);
555 test_arrint_2.Add(1);
556 test_arrint_2.Add(4);
557
558#if wxUSE_DATETIME
559 wxDateTime dt1 = wxDateTime::Now();
560 dt1.SetYear(dt1.GetYear()-1);
561
562 wxDateTime dt2 = wxDateTime::Now();
563 dt2.SetYear(dt2.GetYear()-10);
564#endif
565
566#define FLAG_TEST_SET1 (wxCAPTION|wxCLOSE_BOX|wxSYSTEM_MENU|wxRESIZE_BORDER)
567#define FLAG_TEST_SET2 (wxSTAY_ON_TOP|wxCAPTION|wxICONIZE|wxSYSTEM_MENU)
568
569 pgman->SetPropertyValue(wxT("StringProperty"),wxT("Text1"));
570 pgman->SetPropertyValue(wxT("IntProperty"),1024);
571 pgman->SetPropertyValue(wxT("FloatProperty"),1024.0000000001);
572 pgman->SetPropertyValue(wxT("BoolProperty"),FALSE);
573 pgman->SetPropertyValue(wxT("EnumProperty"),120);
1c4293cb
VZ
574 pgman->SetPropertyValue(wxT("ArrayStringProperty"),test_arrstr_1);
575 wxColour emptyCol;
576 pgman->SetPropertyValue(wxT("ColourProperty"),emptyCol);
577 pgman->SetPropertyValue(wxT("ColourProperty"),(wxObject*)wxBLACK);
effb029c
JS
578 pgman->SetPropertyValue(wxT("Size"),WXVARIANT(wxSize(150,150)));
579 pgman->SetPropertyValue(wxT("Position"),WXVARIANT(wxPoint(150,150)));
1c4293cb
VZ
580 pgman->SetPropertyValue(wxT("MultiChoiceProperty"),test_arrint_1);
581#if wxUSE_DATETIME
582 pgman->SetPropertyValue(wxT("DateProperty"),dt1);
583#endif
584
585 pgman->SelectPage(2);
586 pg = pgman->GetGrid();
587
588 if ( pg->GetPropertyValueAsString(wxT("StringProperty")) != wxT("Text1") )
589 RT_FAILURE();
590 if ( pg->GetPropertyValueAsInt(wxT("IntProperty")) != 1024 )
591 RT_FAILURE();
592 if ( pg->GetPropertyValueAsDouble(wxT("FloatProperty")) != 1024.0000000001 )
593 RT_FAILURE();
594 if ( pg->GetPropertyValueAsBool(wxT("BoolProperty")) != FALSE )
595 RT_FAILURE();
596 if ( pg->GetPropertyValueAsLong(wxT("EnumProperty")) != 120 )
597 RT_FAILURE();
598 if ( pg->GetPropertyValueAsArrayString(wxT("ArrayStringProperty")) != test_arrstr_1 )
599 RT_FAILURE();
1c4293cb
VZ
600 wxColour col;
601 col << pgman->GetPropertyValue(wxT("ColourProperty"));
602 if ( col != *wxBLACK )
603 RT_FAILURE();
d21fc5bf
VZ
604 wxVariant varSize(pg->GetPropertyValue(wxT("Size")));
605 if ( wxSizeRefFromVariant(varSize) != wxSize(150,150) )
1c4293cb 606 RT_FAILURE();
d21fc5bf
VZ
607 wxVariant varPos(pg->GetPropertyValue(wxT("Position")));
608 if ( wxPointRefFromVariant(varPos) != wxPoint(150,150) )
1c4293cb
VZ
609 RT_FAILURE();
610 if ( !(pg->GetPropertyValueAsArrayInt(wxT("MultiChoiceProperty")) == test_arrint_1) )
611 RT_FAILURE();
612#if wxUSE_DATETIME
613 if ( !(pg->GetPropertyValueAsDateTime(wxT("DateProperty")) == dt1) )
614 RT_FAILURE();
615#endif
616
617 pgman->SetPropertyValue(wxT("IntProperty"),wxLL(10000000000));
618 if ( pg->GetPropertyValueAsLongLong(wxT("IntProperty")) != wxLL(10000000000) )
619 RT_FAILURE();
620
621 pg->SetPropertyValue(wxT("StringProperty"),wxT("Text2"));
622 pg->SetPropertyValue(wxT("IntProperty"),512);
623 pg->SetPropertyValue(wxT("FloatProperty"),512.0);
624 pg->SetPropertyValue(wxT("BoolProperty"),TRUE);
625 pg->SetPropertyValue(wxT("EnumProperty"),80);
626 pg->SetPropertyValue(wxT("ArrayStringProperty"),test_arrstr_2);
1c4293cb 627 pg->SetPropertyValue(wxT("ColourProperty"),(wxObject*)wxWHITE);
effb029c
JS
628 pg->SetPropertyValue(wxT("Size"),WXVARIANT(wxSize(300,300)));
629 pg->SetPropertyValue(wxT("Position"),WXVARIANT(wxPoint(300,300)));
1c4293cb
VZ
630 pg->SetPropertyValue(wxT("MultiChoiceProperty"),test_arrint_2);
631#if wxUSE_DATETIME
632 pg->SetPropertyValue(wxT("DateProperty"),dt2);
633#endif
634
635 //pg = (wxPropertyGrid*) NULL;
636
637 pgman->SelectPage(0);
638
639 if ( pgman->GetPropertyValueAsString(wxT("StringProperty")) != wxT("Text2") )
640 RT_FAILURE();
641 if ( pgman->GetPropertyValueAsInt(wxT("IntProperty")) != 512 )
642 RT_FAILURE();
643 if ( pgman->GetPropertyValueAsDouble(wxT("FloatProperty")) != 512.0 )
644 RT_FAILURE();
645 if ( pgman->GetPropertyValueAsBool(wxT("BoolProperty")) != TRUE )
646 RT_FAILURE();
647 if ( pgman->GetPropertyValueAsLong(wxT("EnumProperty")) != 80 )
648 RT_FAILURE();
649 if ( pgman->GetPropertyValueAsArrayString(wxT("ArrayStringProperty")) != test_arrstr_2 )
650 RT_FAILURE();
1c4293cb
VZ
651 col << pgman->GetPropertyValue(wxT("ColourProperty"));
652 if ( col != *wxWHITE )
653 RT_FAILURE();
d21fc5bf
VZ
654 varSize = pgman->GetPropertyValue(wxT("Size"));
655 if ( wxSizeRefFromVariant(varSize) != wxSize(300,300) )
1c4293cb 656 RT_FAILURE();
d21fc5bf
VZ
657 varPos = pgman->GetPropertyValue(wxT("Position"));
658 if ( wxPointRefFromVariant(varPos) != wxPoint(300,300) )
1c4293cb
VZ
659 RT_FAILURE();
660 if ( !(pgman->GetPropertyValueAsArrayInt(wxT("MultiChoiceProperty")) == test_arrint_2) )
661 RT_FAILURE();
662#if wxUSE_DATETIME
663 if ( !(pgman->GetPropertyValueAsDateTime(wxT("DateProperty")) == dt2) )
664 RT_FAILURE();
665#endif
666
667 pgman->SetPropertyValue(wxT("IntProperty"),wxLL(-80000000000));
668 if ( pgman->GetPropertyValueAsLongLong(wxT("IntProperty")) != wxLL(-80000000000) )
669 RT_FAILURE();
8f18b252
JS
670
671 // Make sure children of composite parent get updated as well
84dcb416 672 // Original string value: "Lamborghini Diablo SV; 5707; [300; 3.9; 8.6] 300000; Not Convertible"
8f18b252 673
f3793429 674 //
8f18b252 675 // This updates children as well
84dcb416 676 wxString nvs = "Lamborghini Diablo XYZ; 5707; [100; 3.9; 8.6] 3000002; Convertible";
f3793429 677 pgman->SetPropertyValue("Car", nvs);
8f18b252 678
f3793429 679 if ( pgman->GetPropertyValueAsString("Car.Model") != "Lamborghini Diablo XYZ" )
8f18b252 680 {
f3793429 681 wxLogDebug("Did not match: Car.Model=%s", pgman->GetPropertyValueAsString("Car.Model").c_str());
8f18b252
JS
682 RT_FAILURE();
683 }
684
f3793429 685 if ( pgman->GetPropertyValueAsInt("Car.Speeds.Max. Speed (mph)") != 100 )
8f18b252 686 {
f3793429 687 wxLogDebug("Did not match: Car.Speeds.Max. Speed (mph)=%s", pgman->GetPropertyValueAsString("Car.Speeds.Max. Speed (mph)").c_str());
8f18b252
JS
688 RT_FAILURE();
689 }
690
f3793429 691 if ( pgman->GetPropertyValueAsInt("Car.Price ($)") != 3000002 )
8f18b252 692 {
f3793429 693 wxLogDebug("Did not match: Car.Price ($)=%s", pgman->GetPropertyValueAsString("Car.Price ($)").c_str());
8f18b252
JS
694 RT_FAILURE();
695 }
84dcb416
JS
696
697 if ( !pgman->GetPropertyValueAsBool("Car.Convertible") )
698 {
699 wxLogDebug("Did not match: Car.Convertible=%s", pgman->GetPropertyValueAsString("Car.Convertible").c_str());
700 RT_FAILURE();
701 }
1c4293cb
VZ
702 }
703
704 {
705 RT_START_TEST(SetPropertyValueUnspecified)
706
707 // Null variant setter tests
708 pgman->SetPropertyValueUnspecified(wxT("StringProperty"));
709 pgman->SetPropertyValueUnspecified(wxT("IntProperty"));
710 pgman->SetPropertyValueUnspecified(wxT("FloatProperty"));
711 pgman->SetPropertyValueUnspecified(wxT("BoolProperty"));
712 pgman->SetPropertyValueUnspecified(wxT("EnumProperty"));
713 pgman->SetPropertyValueUnspecified(wxT("ArrayStringProperty"));
1c4293cb
VZ
714 pgman->SetPropertyValueUnspecified(wxT("ColourProperty"));
715 pgman->SetPropertyValueUnspecified(wxT("Size"));
716 pgman->SetPropertyValueUnspecified(wxT("Position"));
717 pgman->SetPropertyValueUnspecified(wxT("MultiChoiceProperty"));
718#if wxUSE_DATETIME
719 pgman->SetPropertyValueUnspecified(wxT("DateProperty"));
720#endif
721 }
722
fc72fab6
JS
723 {
724 //
725 // Test multiple selection
726 RT_START_TEST(MULTIPLE_SELECTION)
727 if ( !(pgman->GetExtraStyle() & wxPG_EX_MULTIPLE_SELECTION) )
728 CreateGrid( -1, wxPG_EX_MULTIPLE_SELECTION);
729 pgman = m_pPropGridManager;
730
731 wxPropertyGrid* pg = pgman->GetGrid();
732
733 wxPGProperty* prop1 = pg->GetProperty(wxT("Label"));
734 wxPGProperty* prop2 = pg->GetProperty(wxT("Cell Text Colour"));
735 wxPGProperty* prop3 = pg->GetProperty(wxT("Height"));
736 wxPGProperty* catProp = pg->GetProperty(wxT("Appearance"));
737
738 RT_ASSERT( prop1 && prop2 && prop3 );
739
740 pg->ClearSelection();
741 pg->AddToSelection(prop1);
742 pg->AddToSelection(prop2);
743 pg->AddToSelection(prop3);
744
745 // Adding category to selection should fail silently
746 pg->AddToSelection(catProp);
747
748 wxArrayPGProperty selectedProperties = pg->GetSelectedProperties();
749
750 RT_ASSERT( selectedProperties.size() == 3 )
751 RT_ASSERT( pg->IsPropertySelected(prop1) )
752 RT_ASSERT( pg->IsPropertySelected(prop2) )
753 RT_ASSERT( pg->IsPropertySelected(prop3) )
754 RT_ASSERT( !pg->IsPropertySelected(catProp) )
755
756 pg->RemoveFromSelection(prop1);
757 wxArrayPGProperty selectedProperties2 = pg->GetSelectedProperties();
758
759 RT_ASSERT( selectedProperties2.size() == 2 )
760 RT_ASSERT( !pg->IsPropertySelected(prop1) )
761 RT_ASSERT( pg->IsPropertySelected(prop2) )
762 RT_ASSERT( pg->IsPropertySelected(prop3) )
763
764 pg->ClearSelection();
765
766 wxArrayPGProperty selectedProperties3 = pg->GetSelectedProperties();
767
768 RT_ASSERT( selectedProperties3.size() == 0 )
769 RT_ASSERT( !pg->IsPropertySelected(prop1) )
770 RT_ASSERT( !pg->IsPropertySelected(prop2) )
771 RT_ASSERT( !pg->IsPropertySelected(prop3) )
772
773 pg->SelectProperty(prop2);
774
775 RT_ASSERT( !pg->IsPropertySelected(prop1) )
776 RT_ASSERT( pg->IsPropertySelected(prop2) )
777 RT_ASSERT( !pg->IsPropertySelected(prop3) )
778 }
779
e9fb1910
JS
780 {
781 //
782 // Test label editing
783 RT_START_TEST(LABEL_EDITING)
784
785 wxPropertyGrid* pg = pgman->GetGrid();
786
787 // Just mostly test that these won't crash
788 pg->MakeColumnEditable(0, true);
789 pg->MakeColumnEditable(2, true);
790 pg->MakeColumnEditable(0, false);
791 pg->MakeColumnEditable(2, false);
792 pg->SelectProperty(wxT("Height"));
793 pg->BeginLabelEdit(0);
794 pg->BeginLabelEdit(0);
795 pg->EndLabelEdit(0);
796 pg->EndLabelEdit(0);
797
798 // Recreate grid
799 CreateGrid( -1, -1 );
800 pgman = m_pPropGridManager;
801 }
802
1802a91d
JS
803 {
804 RT_START_TEST(Attributes)
805
806 wxPGProperty* prop = pgman->GetProperty(wxT("StringProperty"));
807 prop->SetAttribute(wxT("Dummy Attribute"), (long)15);
808
809 if ( prop->GetAttribute(wxT("Dummy Attribute")).GetLong() != 15 )
810 RT_FAILURE();
811
812 prop->SetAttribute(wxT("Dummy Attribute"), wxVariant());
813
814 if ( !prop->GetAttribute(wxT("Dummy Attribute")).IsNull() )
815 RT_FAILURE();
816 }
817
1c4293cb
VZ
818 {
819 wxPropertyGridPage* page1;
820 wxPropertyGridPage* page2;
821 wxPropertyGridPage* page3;
822 wxVariant pg1_values;
823 wxVariant pg2_values;
824 wxVariant pg3_values;
825
826 {
827 RT_START_TEST(GetPropertyValues)
828
829 page1 = pgman->GetPage(0);
830 pg1_values = page1->GetPropertyValues(wxT("Page1"),NULL,wxPG_KEEP_STRUCTURE);
831 page2 = pgman->GetPage(1);
832 pg2_values = page2->GetPropertyValues(wxT("Page2"),NULL,wxPG_KEEP_STRUCTURE);
833 page3 = pgman->GetPage(2);
834 pg3_values = page3->GetPropertyValues(wxT("Page3"),NULL,wxPG_KEEP_STRUCTURE);
835 }
836
837 {
838 RT_START_TEST(SetPropertyValues)
839
840 page1->SetPropertyValues(pg3_values);
841 page2->SetPropertyValues(pg1_values);
842 page3->SetPropertyValues(pg2_values);
843 }
844 }
845
846 if ( !(pgman->GetWindowStyleFlag()&wxPG_HIDE_CATEGORIES) )
847 {
848 RT_START_TEST(Collapse_and_GetFirstCategory_and_GetNextCategory)
849
850 for ( i=0; i<3; i++ )
851 {
852 wxPropertyGridPage* page = pgman->GetPage(i);
853
854 wxPropertyGridIterator it;
855
856 for ( it = page->GetIterator( wxPG_ITERATE_CATEGORIES );
857 !it.AtEnd();
858 it++ )
859 {
860 wxPGProperty* p = *it;
861
862 if ( !page->IsPropertyCategory(p) )
863 RT_FAILURE();
864
865 page->Collapse( p );
866
867 t.Printf(wxT("Collapsing: %s\n"),page->GetPropertyLabel(p).c_str());
868 ed->AppendText(t);
869 }
870 }
871 }
872
873 {
874 RT_START_TEST(Save_And_RestoreEditableState)
875
876 for ( i=0; i<3; i++ )
877 {
878 pgman->SelectPage(i);
879
880 wxString stringState = pgman->SaveEditableState();
881 bool res = pgman->RestoreEditableState(stringState);
882 if ( !res )
883 RT_FAILURE();
884 }
885 }
886
887 //if ( !(pgman->GetWindowStyleFlag()&wxPG_HIDE_CATEGORIES) )
888 {
889 RT_START_TEST(Expand_and_GetFirstCategory_and_GetNextCategory)
890
891 for ( i=0; i<3; i++ )
892 {
893 wxPropertyGridPage* page = pgman->GetPage(i);
894
895 wxPropertyGridIterator it;
896
897 for ( it = page->GetIterator( wxPG_ITERATE_CATEGORIES );
898 !it.AtEnd();
899 it++ )
900 {
901 wxPGProperty* p = *it;
902
903 if ( !page->IsPropertyCategory(p) )
904 RT_FAILURE();
905
906 page->Expand( p );
907
908 t.Printf(wxT("Expand: %s\n"),page->GetPropertyLabel(p).c_str());
909 ed->AppendText(t);
910 }
911 }
912 }
913
939d9364
JS
914 {
915 RT_START_TEST(Choice_Manipulation)
916
917 wxPGProperty* enumProp = pgman->GetProperty(wxT("EnumProperty"));
918
919 pgman->SelectPage(2);
920 pgman->SelectProperty(enumProp);
921 wxASSERT(pgman->GetGrid()->GetSelection() == enumProp);
922
923 const wxPGChoices& choices = enumProp->GetChoices();
924 int ind = enumProp->InsertChoice(wxT("New Choice"), choices.GetCount()/2);
925 enumProp->DeleteChoice(ind);
926
927 // Recreate the original grid
928 CreateGrid( -1, -1 );
929 pgman = m_pPropGridManager;
930 }
931
1c4293cb
VZ
932 //if ( !(pgman->GetWindowStyleFlag()&wxPG_HIDE_CATEGORIES) )
933 {
934 RT_START_TEST(RandomCollapse)
935
936 // Select the most error prone page as visible.
937 pgman->SelectPage(1);
938
939 for ( i=0; i<3; i++ )
940 {
941 wxArrayPtrVoid arr;
942
943 wxPropertyGridPage* page = pgman->GetPage(i);
944
945 wxPropertyGridIterator it;
946
947 for ( it = page->GetIterator( wxPG_ITERATE_CATEGORIES );
948 !it.AtEnd();
949 it++ )
950 {
951 arr.Add((void*)*it);
952 }
953
954 if ( arr.GetCount() )
955 {
956 size_t n;
957
958 pgman->Collapse( (wxPGProperty*)arr.Item(0) );
959
960 for ( n=arr.GetCount()-1; n>0; n-- )
961 {
962 pgman->Collapse( (wxPGProperty*)arr.Item(n) );
963 }
964 }
965
966 }
967 }
968
969 {
970 RT_START_TEST(EnsureVisible)
971 pgman->EnsureVisible(wxT("Cell Colour"));
972 }
973
f915d44b
JS
974 {
975 RT_START_TEST(RemoveProperty)
976
977 wxPGProperty* p;
978
979 wxPGProperty* origParent =
980 pgman->GetProperty(wxT("Window Styles"))->GetParent();
981
982 p = pgman->RemoveProperty(wxT("Window Styles"));
983 pgman->Refresh();
984 pgman->Update();
985
986 pgman->AppendIn(origParent, p);
987 pgman->Refresh();
988 pgman->Update();
989 }
990
43396981
JS
991 {
992 RT_START_TEST(SortFunction)
993
994 wxPGProperty* p;
995
996 // Make sure indexes are as supposed
997
998 p = pgman->GetProperty(wxT("User Name"));
999 if ( p->GetIndexInParent() != 3 )
1000 RT_FAILURE();
1001
1002 p = pgman->GetProperty(wxT("User Id"));
1003 if ( p->GetIndexInParent() != 2 )
1004 RT_FAILURE();
1005
1006 p = pgman->GetProperty(wxT("User Home"));
1007 if ( p->GetIndexInParent() != 1 )
1008 RT_FAILURE();
1009
1010 p = pgman->GetProperty(wxT("Operating System"));
1011 if ( p->GetIndexInParent() != 0 )
1012 RT_FAILURE();
1013
1014 pgman->GetGrid()->SetSortFunction(MyPropertySortFunction);
1015
1016 pgman->GetGrid()->SortChildren(wxT("Environment"));
1017
1018 // Make sure indexes have been reversed
1019 p = pgman->GetProperty(wxT("User Name"));
1020 if ( p->GetIndexInParent() != 0 )
1021 RT_FAILURE();
1022
1023 p = pgman->GetProperty(wxT("User Id"));
1024 if ( p->GetIndexInParent() != 1 )
1025 RT_FAILURE();
1026
1027 p = pgman->GetProperty(wxT("User Home"));
1028 if ( p->GetIndexInParent() != 2 )
1029 RT_FAILURE();
1030
1031 p = pgman->GetProperty(wxT("Operating System"));
1032 if ( p->GetIndexInParent() != 3 )
1033 RT_FAILURE();
1034 }
1035
1c4293cb
VZ
1036 {
1037 RT_START_TEST(SetPropertyBackgroundColour)
1038 wxCommandEvent evt;
1039 evt.SetInt(1); // IsChecked() will return TRUE.
1040 evt.SetId(ID_COLOURSCHEME4);
1041 OnCatColours(evt);
1042 OnColourScheme(evt);
1043 }
1044
1c4293cb 1045 {
8dee26e1
JS
1046 RT_START_TEST(Clear)
1047
1048 // Manager clear
1049 pgman->SelectProperty("Label");
1c4293cb
VZ
1050 pgman->Clear();
1051
1052 if ( pgman->GetPageCount() )
1053 RT_FAILURE();
8dee26e1
JS
1054
1055 if ( pgman->GetGrid()->GetRoot()->GetChildCount() )
1056 RT_FAILURE();
1057
1058 // Recreate the original grid
1059 CreateGrid( -1, -1 );
1060 pgman = m_pPropGridManager;
1061
1062 // Grid clear
1063 pgman->SelectProperty("Label");
1064 pgman->GetGrid()->Clear();
1065
1066 if ( pgman->GetGrid()->GetRoot()->GetChildCount() )
1067 RT_FAILURE();
1c4293cb
VZ
1068
1069 // Recreate the original grid
1070 CreateGrid( -1, -1 );
1071 pgman = m_pPropGridManager;
1072 }
1073
fc72fab6 1074 /*{
1c4293cb
VZ
1075 // TODO: This test fails.
1076 RT_START_TEST(SetSplitterPosition)
1077
1078 InitPanel();
1079
1080 const int trySplitterPos = 50;
1081
1082 int style = wxPG_AUTO_SORT; // wxPG_SPLITTER_AUTO_CENTER;
1083 pgman = m_pPropGridManager =
1084 new wxPropertyGridManager(m_panel, wxID_ANY,
1085 wxDefaultPosition,
1086 wxDefaultSize,
1087 style );
1088
1089 PopulateGrid();
1090 pgman->SetSplitterPosition(trySplitterPos);
1091
1092 if ( pgman->GetGrid()->GetSplitterPosition() != trySplitterPos )
1093 RT_FAILURE_MSG(wxString::Format(wxT("Splitter position was %i (should have been %i)"),(int)pgman->GetGrid()->GetSplitterPosition(),trySplitterPos).c_str());
1094
1095 m_topSizer->Add( m_pPropGridManager, 1, wxEXPAND );
1096 FinalizePanel();
1097
1098 wxSize sz = GetSize();
1099 wxSize origSz = sz;
1100 sz.x += 5;
1101 sz.y += 5;
1102
1103 if ( pgman->GetGrid()->GetSplitterPosition() != trySplitterPos )
1104 RT_FAILURE_MSG(wxString::Format(wxT("Splitter position was %i (should have been %i)"),(int)pgman->GetGrid()->GetSplitterPosition(),trySplitterPos).c_str());
1105
1106 SetSize(origSz);
1107
1108 // Recreate the original grid
1109 CreateGrid( -1, -1 );
1110 pgman = m_pPropGridManager;
fc72fab6 1111 }*/
1c4293cb
VZ
1112
1113 {
1114 RT_START_TEST(HideProperty)
1115
1116 wxPropertyGridPage* page = pgman->GetPage(0);
1117
1118 srand(0x1234);
1119
1120 wxArrayPGProperty arr1;
fc72fab6 1121
1c4293cb
VZ
1122 arr1 = GetPropertiesInRandomOrder(page);
1123
1124 if ( !_failed_ )
1125 {
1126 for ( i=0; i<arr1.size(); i++ )
1127 {
1128 wxPGProperty* p = arr1[i];
1129 page->HideProperty(p, true);
1130
1131 wxString s = wxString::Format(wxT("HideProperty(%i, %s)"), i, p->GetLabel().c_str());
1132 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1133 if ( _failed_ )
1134 break;
1135 }
1136 }
1137
1138 if ( !_failed_ )
1139 {
1140 wxArrayPGProperty arr2 = GetPropertiesInRandomOrder(page);
1141
1142 for ( i=0; i<arr2.size(); i++ )
1143 {
1144 wxPGProperty* p = arr2[i];
1145 page->HideProperty(p, false);
1146
1147 wxString s = wxString::Format(wxT("ShowProperty(%i, %s)"), i, p->GetLabel().c_str());
1148 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1149 if ( _failed_ )
1150 break;
1151 }
1152 }
1153
1154 //
1155 // Let's do some more, for better consistency
1156 arr1 = GetPropertiesInRandomOrder(page);
1157
1158 if ( !_failed_ )
1159 {
1160 for ( i=0; i<arr1.size(); i++ )
1161 {
1162 wxPGProperty* p = arr1[i];
1163 page->HideProperty(p, true);
1164
1165 wxString s = wxString::Format(wxT("HideProperty(%i, %s)"), i, p->GetLabel().c_str());
1166 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1167 if ( _failed_ )
1168 break;
1169 }
1170 }
1171
1172 if ( !_failed_ )
1173 {
1174 wxArrayPGProperty arr2 = GetPropertiesInRandomOrder(page);
1175
1176 for ( i=0; i<arr2.size(); i++ )
1177 {
1178 wxPGProperty* p = arr2[i];
1179 page->HideProperty(p, false);
1180
1181 wxString s = wxString::Format(wxT("ShowProperty(%i, %s)"), i, p->GetLabel().c_str());
1182 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1183 if ( _failed_ )
1184 break;
1185 }
1186 }
1187
1188 //
1189 // Ok, this time only hide half of them
1190 arr1 = GetPropertiesInRandomOrder(page);
1c4293cb 1191 arr1.resize(arr1.size()/2);
1c4293cb
VZ
1192
1193 if ( !_failed_ )
1194 {
1195 for ( i=0; i<arr1.size(); i++ )
1196 {
1197 wxPGProperty* p = arr1[i];
1198 page->HideProperty(p, true);
1199
1200 wxString s = wxString::Format(wxT("HideProperty(%i, %s)"), i, p->GetLabel().c_str());
1201 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1202 if ( _failed_ )
1203 break;
1204 }
1205 }
1206
1207 if ( !_failed_ )
1208 {
1209 wxArrayPGProperty arr2 = GetPropertiesInRandomOrder(page);
1210
1211 for ( i=0; i<arr2.size(); i++ )
1212 {
1213 wxPGProperty* p = arr2[i];
1214 page->HideProperty(p, false);
1215
1216 wxString s = wxString::Format(wxT("ShowProperty(%i, %s)"), i, p->GetLabel().c_str());
1217 RT_VALIDATE_VIRTUAL_HEIGHT(page, s)
1218 if ( _failed_ )
1219 break;
1220 }
1221 }
1222
1223 // Recreate the original grid
1224 CreateGrid( -1, -1 );
1225 pgman = m_pPropGridManager;
1226 }
1227
1228 if ( fullTest )
1229 {
1230 RT_START_TEST(MultipleColumns)
1231
1232 // Test with multiple columns
1233 // FIXME: Does not display changes.
1234 for ( i=3; i<12; i+=2 )
1235 {
1236 RT_MSG(wxString::Format(wxT("%i columns"),i));
1237 CreateGrid( -1, -1 );
1238 pgman = m_pPropGridManager;
1239 pgman->SetColumnCount(i);
1240 Refresh();
1241 Update();
1242 wxMilliSleep(500);
1243 }
1244 }
1245
1246 if ( fullTest )
1247 {
1248 RT_START_TEST(WindowStyles)
1249
1250 // Recreate grid with all possible (single) flags
1251 wxASSERT(wxPG_AUTO_SORT == 0x000000010);
1252
1253 for ( i=4; i<16; i++ )
1254 {
1255 int flag = 1<<i;
1256 RT_MSG(wxString::Format(wxT("Style: 0x%X"),flag));
1257 CreateGrid( flag, -1 );
1258 pgman = m_pPropGridManager;
1259 Update();
1260 wxMilliSleep(500);
1261 }
1262
1263 wxASSERT(wxPG_EX_INIT_NOCAT == 0x00001000);
1264
08c1613f 1265 for ( i=12; i<27; i++ )
1c4293cb
VZ
1266 {
1267 int flag = 1<<i;
1268 RT_MSG(wxString::Format(wxT("ExStyle: 0x%X"),flag));
1269 CreateGrid( -1, flag );
1270 pgman = m_pPropGridManager;
1271 Update();
1272 wxMilliSleep(500);
1273 }
1274
1275 // Recreate the original grid
1276 CreateGrid( -1, -1 );
1277 pgman = m_pPropGridManager;
1278 }
1279
1280 RT_START_TEST(none)
1281
1282 bool retVal;
1283
1284 if ( failures || errorMessages.size() )
1285 {
1286 retVal = false;
1287
1288 wxString s;
1289#ifdef __WXDEBUG__
1290 if ( failures )
1291#endif
1292 s = wxString::Format(wxT("%i tests failed!!!"), failures);
1293#ifdef __WXDEBUG__
1294 else
1295 s = wxString::Format(wxT("All tests were succesfull, but there were %i warnings!"), wxPGGlobalVars->m_warnings);
1296#endif
1297 RT_MSG(s)
1298 for ( i=0; i<errorMessages.size(); i++ )
1299 RT_MSG(errorMessages[i])
1300 wxMessageBox(s, wxT("Some Tests Failed"));
1301 }
1302 else
1303 {
1304 RT_MSG(wxT("All tests succesfull"))
1305 retVal = true;
1306
1307 if ( !interactive )
1308 dlg->Close();
1309 }
1310
1311 pgman->SelectPage(0);
1312
1313 // Test may screw up the toolbar, so we need to refresh it.
1314 wxToolBar* toolBar = pgman->GetToolBar();
1315 if ( toolBar )
1316 toolBar->Refresh();
1317
1318 return retVal;
1319}
1320
1321// -----------------------------------------------------------------------