]> git.saurik.com Git - wxWidgets.git/blobdiff - tests/test.cpp
add missing wxUSE_DEFERRED_SIZING tests (closes #10766)
[wxWidgets.git] / tests / test.cpp
index ca527e17ec2cc441a049e311dcfd96bf36a32ce8..2f7f71903cd0fa024d8d14824ce7d9c35e853932 100644 (file)
     #include "wx/msw/msvcrt.h"
 #endif
 
+#ifdef __WXOSX__
+    #include "wx/osx/private.h"
+#endif
+
 using namespace std;
 
 using CppUnit::Test;
@@ -216,6 +220,15 @@ public:
 private:
     void List(Test *test, const string& parent = "") const;
 
+    // call List() if m_list or runner.addTest() otherwise
+    void AddTest(CppUnit::TestRunner& runner, Test *test)
+    {
+        if (m_list)
+            List(test);
+        else
+            runner.addTest(test);
+    }
+
     // command lines options/parameters
     bool m_list;
     bool m_longlist;
@@ -349,11 +362,6 @@ bool TestApp::OnCmdLineParsed(wxCmdLineParser& parser)
         for (size_t i = 0; i < parser.GetParamCount(); i++)
             m_registries.push_back(parser.GetParam(i));
     }
-    else
-    {
-        // FIXME: this is an ugly and unnecessary hack
-        m_registries.push_back("");
-    }
 
     m_longlist = parser.Found("longlist");
     m_list = m_longlist || parser.Found("list");
@@ -432,6 +440,13 @@ static Test *GetTestByName(const wxString& name)
 //
 int TestApp::OnRun()
 {
+#if wxUSE_GUI
+#ifdef __WXOSX__
+    // make sure there's always an autorelease pool ready
+    wxMacAutoreleasePool autoreleasepool;
+#endif
+#endif
+
 #if wxUSE_LOG
     // Switch off logging unless --verbose
     bool verbose = wxLog::GetVerbose();
@@ -442,19 +457,17 @@ int TestApp::OnRun()
 
     CppUnit::TextTestRunner runner;
 
-    for (size_t i = 0; i < m_registries.size(); i++)
+    if ( m_registries.empty() )
     {
-        Test *test;
-
-        wxString reg = m_registries[i];
-        if ( reg.empty() )
-        {
-            // no test name, run all the tests
-            test = TestFactoryRegistry::getRegistry().makeTest();
-        }
-        else // test name specified, run just this test
+        // run or list all tests
+        AddTest(runner, TestFactoryRegistry::getRegistry().makeTest());
+    }
+    else // run only the selected tests
+    {
+        for (size_t i = 0; i < m_registries.size(); i++)
         {
-            test = GetTestByName(reg);
+            const wxString reg = m_registries[i];
+            Test *test = GetTestByName(reg);
 
             if ( !test && !reg.EndsWith("TestCase") )
             {
@@ -466,12 +479,9 @@ int TestApp::OnRun()
                 cerr << "No such test suite: " << string(reg.mb_str()) << endl;
                 return 2;
             }
-        }
 
-        if (m_list)
-            List(test);
-        else
-            runner.addTest(test);
+            AddTest(runner, test);
+        }
     }
 
     if ( m_list )