]> 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 c2b5e5b953bf6891d12390dc5b9421e2610750da..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)
 
@@ -775,6 +830,29 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
         RT_ASSERT( !pg->IsPropertySelected(prop3) )
     }
 
+    {
+        //
+        // Test label editing
+        RT_START_TEST(LABEL_EDITING)
+
+        wxPropertyGrid* pg = pgman->GetGrid();
+
+        // Just mostly test that these won't crash
+        pg->MakeColumnEditable(0, true);
+        pg->MakeColumnEditable(2, true);
+        pg->MakeColumnEditable(0, false);
+        pg->MakeColumnEditable(2, false);
+        pg->SelectProperty(wxT("Height"));
+        pg->BeginLabelEdit(0);
+        pg->BeginLabelEdit(0);
+        pg->EndLabelEdit(0);
+        pg->EndLabelEdit(0);
+
+        // Recreate grid
+        CreateGrid( -1, -1 );
+        pgman = m_pPropGridManager;
+    }
+
     {
         RT_START_TEST(Attributes)
 
@@ -1237,7 +1315,7 @@ bool FormMain::RunTests( bool fullTest, bool interactive )
 
         wxASSERT(wxPG_EX_INIT_NOCAT == 0x00001000);
 
-        for ( i=12; i<26; i++ )
+        for ( i=12; i<27; i++ )
         {
             int flag = 1<<i;
             RT_MSG(wxString::Format(wxT("ExStyle: 0x%X"),flag));