]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/propgrid/tests.cpp
Fix crash by checking if icon is valid before drawing it, fixes #12376: PATCH for...
[wxWidgets.git] / samples / propgrid / tests.cpp
index 8efbe0f39247f85109507b8cb3f829d471dd5901..7d04a32313b158243ad2b576d88fd5c1914592c1 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     2007-05-16
 // RCS-ID:      $Id$
 // Copyright:   (c) Jaakko Salli
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 #include "wx/wxprec.h"
@@ -106,7 +106,7 @@ public:
 void FormMain::AddTestProperties( wxPropertyGridPage* pg )
 {
     pg->Append( new MyColourProperty(wxT("CustomColourProperty"), wxPG_LABEL, *wxGREEN) );
-    pg->GetProperty(wxT("CustomColourProperty"))->SetFlag(wxPG_PROP_AUTO_UNSPECIFIED);
+    pg->GetProperty(wxT("CustomColourProperty"))->SetAutoUnspecified(true);
     pg->SetPropertyEditor( wxT("CustomColourProperty"), wxPGEditor_ComboBox );
 
     pg->SetPropertyHelpString(wxT("CustomColourProperty"),
@@ -162,8 +162,9 @@ void FormMain::OnDumpList( wxCommandEvent& WXUNUSED(event) )
     const int spacing = 8;
     wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
     wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
-    wxTextCtrl* ed = new wxTextCtrl(dlg,11,text,
-        wxDefaultPosition,wxDefaultSize,wxTE_MULTILINE|wxTE_READONLY);
+    wxTextCtrl* ed = new wxTextCtrl(dlg, 11, text,
+                                    wxDefaultPosition, wxDefaultSize,
+                                    wxTE_MULTILINE);
     rowsizer->Add( ed, 1, wxEXPAND|wxALL, spacing );
     topsizer->Add( rowsizer, 1, wxEXPAND, 0 );
     rowsizer = new wxBoxSizer( wxHORIZONTAL );
@@ -342,8 +343,9 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
     const int spacing = 8;
     wxBoxSizer* topsizer = new wxBoxSizer( wxVERTICAL );
     wxBoxSizer* rowsizer = new wxBoxSizer( wxHORIZONTAL );
-    wxTextCtrl* ed = new wxTextCtrl(dlg,11,wxEmptyString,
-        wxDefaultPosition,wxDefaultSize,wxTE_MULTILINE|wxTE_READONLY);
+    wxTextCtrl* ed = new wxTextCtrl(dlg, 11, wxEmptyString,
+                                    wxDefaultPosition, wxDefaultSize,
+                                    wxTE_MULTILINE);
     rowsizer->Add( ed, 1, wxEXPAND|wxALL, spacing );
     topsizer->Add( rowsizer, 1, wxEXPAND, 0 );
     rowsizer = new wxBoxSizer( wxHORIZONTAL );
@@ -499,6 +501,59 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
         pgman = m_pPropGridManager;
     }
 
+    {
+        //
+        // Test wxAny<->wxVariant conversion
+        RT_START_TEST(WXVARIANT_TO_WXANY_CONVERSION)
+
+        wxPGProperty* prop;
+        wxAny any;
+
+#if wxUSE_DATETIME
+        prop = pgman->GetProperty("DateProperty");
+        wxDateTime testTime = wxDateTime::Now();
+        any = testTime;
+        prop->SetValue(any);
+        if ( wxANY_AS(prop->GetValue().GetAny(), wxDateTime) != testTime )
+            RT_FAILURE();
+#endif
+
+        prop = pgman->GetProperty("IntProperty");
+        int testInt = 25537983;
+        any = testInt;
+        prop->SetValue(any);
+        if ( wxANY_AS(prop->GetValue().GetAny(), int) != testInt )
+            RT_FAILURE();
+#ifdef wxLongLong_t
+        if ( wxANY_AS(prop->GetValue().GetAny(), wxLongLong_t) != testInt )
+            RT_FAILURE();
+#endif
+
+        prop = pgman->GetProperty("StringProperty");
+        wxString testString = "asd934jfyn3";
+        any = testString;
+        prop->SetValue(any);
+        if ( wxANY_AS(prop->GetValue().GetAny(), wxString) != testString )
+            RT_FAILURE();
+
+        // Test with a type generated with IMPLEMENT_VARIANT_OBJECT()
+        prop = pgman->GetProperty("ColourProperty");
+        wxColour testCol = *wxCYAN;
+        any = testCol;
+        prop->SetValue(any);
+        if ( wxANY_AS(prop->GetValue().GetAny(), wxColour) != testCol )
+            RT_FAILURE();
+
+        // Test with a type with custom wxVariantData defined by
+        // wxPG headers.
+        prop = pgman->GetProperty("Position");
+        wxPoint testPoint(199, 199);
+        any = testPoint;
+        prop->SetValue(any);
+        if ( wxANY_AS(prop->GetValue().GetAny(), wxPoint) != testPoint )
+            RT_FAILURE();
+    }
+
     {
         RT_START_TEST(GetPropertyValues)