+IMPLEMENT_APP_NO_MAIN(TestApp)
+
+
+// ----------------------------------------------------------------------------
+// global functions
+// ----------------------------------------------------------------------------
+
+#ifdef wxUSE_VC_CRTDBG
+
+static int TestCrtReportHook(int reportType, char *message, int *)
+{
+ if ( reportType != _CRT_ASSERT )
+ return FALSE;
+
+ throw CrtAssertFailure(message);
+}
+
+#endif // wxUSE_VC_CRTDBG
+
+#if wxDEBUG_LEVEL
+
+static void TestAssertHandler(const wxString& file,
+ int line,
+ const wxString& func,
+ const wxString& cond,
+ const wxString& msg)
+{
+ throw TestAssertFailure(file, line, func, cond, msg);
+}
+
+#endif // wxDEBUG_LEVEL
+
+int main(int argc, char **argv)
+{
+ // tests can be ran non-interactively so make sure we don't show any assert
+ // dialog boxes -- neither our own nor from MSVC debug CRT -- which would
+ // prevent them from completing
+
+#if wxDEBUG_LEVEL
+ wxSetAssertHandler(TestAssertHandler);
+#endif // wxDEBUG_LEVEL
+
+#ifdef wxUSE_VC_CRTDBG
+ _CrtSetReportHook(TestCrtReportHook);
+#endif // wxUSE_VC_CRTDBG
+
+ try
+ {
+ return wxEntry(argc, argv);
+ }
+ catch ( ... )
+ {
+ cerr << "\n" << GetExceptionMessage() << endl;
+ }
+
+ return -1;
+}
+
+extern void SetFilterEventFunc(FilterEventFunc func)
+{
+ wxGetApp().SetFilterEventFunc(func);
+}
+
+extern void SetProcessEventFunc(ProcessEventFunc func)
+{
+ wxGetApp().SetProcessEventFunc(func);
+}
+
+extern bool IsNetworkAvailable()
+{
+ // NOTE: we could use wxDialUpManager here if it was in wxNet; since it's in
+ // wxCore we use a simple rough test:
+
+ wxSocketBase::Initialize();
+
+ wxIPV4address addr;
+ if (!addr.Hostname("www.google.com") || !addr.Service("www"))
+ {
+ wxSocketBase::Shutdown();
+ return false;
+ }
+
+ wxSocketClient sock;
+ sock.SetTimeout(10); // 10 secs
+ bool online = sock.Connect(addr);
+
+ wxSocketBase::Shutdown();
+
+ return online;
+}
+
+// helper of OnRun(): gets the test with the given name, returning NULL (and
+// not an empty test suite) if there is no such test
+static Test *GetTestByName(const wxString& name)
+{
+ Test *
+ test = TestFactoryRegistry::getRegistry(string(name.mb_str())).makeTest();
+ if ( test )
+ {
+ TestSuite * const suite = dynamic_cast<TestSuite *>(test);
+ if ( !suite || !suite->countTestCases() )
+ {
+ // it's a bogus test, don't use it
+ delete test;
+ test = NULL;
+ }
+ }
+
+ return test;
+}
+
+
+// ----------------------------------------------------------------------------
+// TestApp
+// ----------------------------------------------------------------------------