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