-static void TestDirTraverse()
-{
- wxPuts(wxT("*** Testing wxDir::Traverse() ***"));
-
- // enum all files
- wxArrayString files;
- size_t n = wxDir::GetAllFiles(TESTDIR, &files);
- wxPrintf(wxT("There are %u files under '%s'\n"), n, TESTDIR);
- if ( n > 1 )
- {
- wxPrintf(wxT("First one is '%s'\n"), files[0u].c_str());
- wxPrintf(wxT(" last one is '%s'\n"), files[n - 1].c_str());
- }
-
- // enum again with custom traverser
- wxPuts(wxT("Now enumerating directories:"));
- wxDir dir(TESTDIR);
- DirPrintTraverser traverser;
- dir.Traverse(traverser, wxEmptyString, wxDIR_DIRS | wxDIR_HIDDEN);
-}
-
-#if TEST_ALL
-
-static void TestDirExists()
-{
- wxPuts(wxT("*** Testing wxDir::Exists() ***"));
-
- static const wxChar *dirnames[] =
- {
- wxT("."),
-#if defined(__WXMSW__)
- wxT("c:"),
- wxT("c:\\"),
- wxT("\\\\share\\file"),
- wxT("c:\\dos"),
- wxT("c:\\dos\\"),
- wxT("c:\\dos\\\\"),
- wxT("c:\\autoexec.bat"),
-#elif defined(__UNIX__)
- wxT("/"),
- wxT("//"),
- wxT("/usr/bin"),
- wxT("/usr//bin"),
- wxT("/usr///bin"),
-#endif
- };
-
- for ( size_t n = 0; n < WXSIZEOF(dirnames); n++ )
- {
- wxPrintf(wxT("%-40s: %s\n"),
- dirnames[n],
- wxDir::Exists(dirnames[n]) ? wxT("exists")
- : wxT("doesn't exist"));
- }
-}
-
-#endif // TEST_ALL
-
-#endif // TEST_DIR
-
-// ----------------------------------------------------------------------------
-// wxDllLoader
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_DYNLIB
-
-#include "wx/dynlib.h"
-
-#if defined(__WXMSW__) || defined(__UNIX__)
-
-static void TestDllListLoaded()
-{
- wxPuts(wxT("*** testing wxDynamicLibrary::ListLoaded() ***\n"));
-
- wxPuts("Loaded modules:");
- wxDynamicLibraryDetailsArray dlls = wxDynamicLibrary::ListLoaded();
- const size_t count = dlls.GetCount();
- for ( size_t n = 0; n < count; ++n )
- {
- const wxDynamicLibraryDetails& details = dlls[n];
- printf("%-45s", (const char *)details.GetPath().mb_str());
-
- void *addr wxDUMMY_INITIALIZE(NULL);
- size_t len wxDUMMY_INITIALIZE(0);
- if ( details.GetAddress(&addr, &len) )
- {
- printf(" %08lx:%08lx",
- (unsigned long)addr, (unsigned long)((char *)addr + len));
- }
-
- printf(" %s\n", (const char *)details.GetVersion().mb_str());
- }
-
- wxPuts(wxEmptyString);
-}
-
-#endif
-
-#endif // TEST_DYNLIB
-
-// ----------------------------------------------------------------------------
-// MIME types
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_MIME
-
-#include "wx/mimetype.h"
-
-static void TestMimeEnum()
-{
- wxPuts(wxT("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
-
- wxArrayString mimetypes;
-
- size_t count = wxTheMimeTypesManager->EnumAllFileTypes(mimetypes);
-
- wxPrintf(wxT("*** All %u known filetypes: ***\n"), count);
-
- wxArrayString exts;
- wxString desc;
-
- for ( size_t n = 0; n < count; n++ )
- {
- wxFileType *filetype =
- wxTheMimeTypesManager->GetFileTypeFromMimeType(mimetypes[n]);
- if ( !filetype )
- {
- wxPrintf(wxT(" nothing known about the filetype '%s'!\n"),
- mimetypes[n].c_str());
- continue;
- }
-
- filetype->GetDescription(&desc);
- filetype->GetExtensions(exts);
-
- filetype->GetIcon(NULL);
-
- wxString extsAll;
- for ( size_t e = 0; e < exts.GetCount(); e++ )
- {
- if ( e > 0 )
- extsAll << wxT(", ");
- extsAll += exts[e];
- }
-
- wxPrintf(wxT(" %s: %s (%s)\n"),
- mimetypes[n].c_str(), desc.c_str(), extsAll.c_str());
- }
-
- wxPuts(wxEmptyString);
-}
-
-static void TestMimeFilename()
-{
- wxPuts(wxT("*** Testing MIME type from filename query ***\n"));
-
- static const wxChar *filenames[] =
- {
- wxT("readme.txt"),
- wxT("document.pdf"),
- wxT("image.gif"),
- wxT("picture.jpeg"),
- };
-
- for ( size_t n = 0; n < WXSIZEOF(filenames); n++ )
- {
- const wxString fname = filenames[n];
- wxString ext = fname.AfterLast(wxT('.'));
- wxFileType *ft = wxTheMimeTypesManager->GetFileTypeFromExtension(ext);
- if ( !ft )
- {
- wxPrintf(wxT("WARNING: extension '%s' is unknown.\n"), ext.c_str());
- }
- else
- {
- wxString desc;
- if ( !ft->GetDescription(&desc) )
- desc = wxT("<no description>");
-
- wxString cmd;
- if ( !ft->GetOpenCommand(&cmd,
- wxFileType::MessageParameters(fname, wxEmptyString)) )
- cmd = wxT("<no command available>");
- else
- cmd = wxString(wxT('"')) + cmd + wxT('"');
-
- wxPrintf(wxT("To open %s (%s) run:\n %s\n"),
- fname.c_str(), desc.c_str(), cmd.c_str());
-
- delete ft;
- }
- }
-
- wxPuts(wxEmptyString);
-}
-
-static void TestMimeAssociate()
-{
- wxPuts(wxT("*** Testing creation of filetype association ***\n"));
-
- wxFileTypeInfo ftInfo(
- wxT("application/x-xyz"),
- wxT("xyzview '%s'"), // open cmd
- wxT(""), // print cmd
- wxT("XYZ File"), // description
- wxT(".xyz"), // extensions
- wxNullPtr // end of extensions
- );
- ftInfo.SetShortDesc(wxT("XYZFile")); // used under Win32 only
-
- wxFileType *ft = wxTheMimeTypesManager->Associate(ftInfo);
- if ( !ft )
- {
- wxPuts(wxT("ERROR: failed to create association!"));
- }
- else
- {
- // TODO: read it back
- delete ft;
- }
-
- wxPuts(wxEmptyString);
-}
-
-#endif // TEST_MIME
-
-
-// ----------------------------------------------------------------------------
-// misc information functions
-// ----------------------------------------------------------------------------
-
-#ifdef TEST_INFO_FUNCTIONS
-
-#include "wx/utils.h"
-
-#if TEST_INTERACTIVE
-static void TestDiskInfo()