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