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