2010-06-21 17:03:47 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: tests/interactive/output.cpp
|
|
|
|
// Purpose: Miscellaneous tests NOT requiring user input, just user checks
|
|
|
|
// Author: Francesco Montorsi (extracted from console sample)
|
|
|
|
// Created: 2010-06-21
|
|
|
|
// Copyright: (c) 2010 wxWidgets team
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// declarations
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "testprec.h"
|
|
|
|
|
|
|
|
|
2010-06-21 17:46:29 -04:00
|
|
|
#include "wx/app.h"
|
2010-06-21 19:32:34 -04:00
|
|
|
#include "wx/wxcrt.h" // for wxPuts
|
|
|
|
#include "wx/wxcrtvararg.h" // for wxPrintf
|
2010-06-21 17:46:29 -04:00
|
|
|
|
2010-06-21 17:03:47 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// conditional compilation
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#define TEST_DYNLIB
|
2020-05-08 02:01:56 -04:00
|
|
|
#if wxUSE_MIMETYPE
|
2010-06-21 17:03:47 -04:00
|
|
|
#define TEST_MIME
|
2020-05-08 02:01:56 -04:00
|
|
|
#endif
|
2010-06-21 17:03:47 -04:00
|
|
|
#define TEST_INFO_FUNCTIONS
|
|
|
|
#define TEST_STACKWALKER
|
|
|
|
#define TEST_STDPATHS
|
|
|
|
#define TEST_VOLUME
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// test class
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class InteractiveOutputTestCase : public CppUnit::TestCase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
InteractiveOutputTestCase() { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
CPPUNIT_TEST_SUITE( InteractiveOutputTestCase );
|
|
|
|
CPPUNIT_TEST( TestDllListLoaded );
|
|
|
|
CPPUNIT_TEST( TestMimeEnum );
|
|
|
|
CPPUNIT_TEST( TestMimeAssociate );
|
|
|
|
CPPUNIT_TEST( TestMimeFilename );
|
|
|
|
CPPUNIT_TEST( TestOsInfo );
|
|
|
|
CPPUNIT_TEST( TestPlatformInfo );
|
|
|
|
CPPUNIT_TEST( TestUserInfo );
|
|
|
|
CPPUNIT_TEST( TestStackWalk );
|
|
|
|
CPPUNIT_TEST( TestStandardPaths );
|
|
|
|
CPPUNIT_TEST( TestFSVolume );
|
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
|
|
|
|
void TestDllListLoaded();
|
|
|
|
void TestMimeEnum();
|
|
|
|
void TestMimeAssociate();
|
|
|
|
void TestMimeFilename();
|
|
|
|
void TestOsInfo();
|
|
|
|
void TestPlatformInfo();
|
|
|
|
void TestUserInfo();
|
|
|
|
void TestStackWalk();
|
|
|
|
void TestStandardPaths();
|
|
|
|
void TestFSVolume();
|
|
|
|
|
|
|
|
wxDECLARE_NO_COPY_CLASS(InteractiveOutputTestCase);
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// CppUnit macros
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
Replace CppUnit with Catch for unit tests
Drop the legacy CppUnit testing framework used for the unit tests.
Replacing it with Catch has the advantage of not requiring CppUnit
libraries to be installed on the system in order to be able to run
tests (Catch is header-only and a copy of it is now included in the
main repository itself) and, in the future, of being able to write
the tests in a much more natural way.
For now, however, avoid changing the existing tests code as much as
[reasonably] possible to avoid introducing bugs in them and provide
the CppUnit compatibility macros in the new wx/catch_cppunit.h header
which allow to preserve the 99% of the existing code unchanged. Some
of the required changes are:
- Decompose asserts using "a && b" conditions into multiple asserts
checking "a" and "b" independently. This would have been better
even with CppUnit (to know which part of condition exactly failed)
and is required with Catch.
- Use extra parentheses around such conditions when they can't be
easily decomposed in the arrays test, due to the use of macros.
This is not ideal from the point of view of messages given when
the tests fail but will do for now.
- Rewrite asserts using "a || b" as a combination of condition
checks and assert macros. Again, this is better anyhow, and is
required with Catch. Incidentally, this allowed to fix a bug in
the "exec" unit test which didn't leave enough time for the new
process to be launched before trying to kill it.
- Remove multiple CPPUNIT_TEST_SUITE_NAMED_REGISTRATION() macros,
our emulation of this macro can be used only once.
- Provide string conversions using Catch-specific StringMaker for
a couple of types.
- Replace custom wxImage comparison with a Catch-specific matcher
class.
- Remove most of test running logic from test.cpp, in particular don't
parse command line ourselves any longer but use Catch built-in
command line parser. This is a source of a minor regression:
previously, both "Foo" and "FooTestCase" could be used as the name of
the test to run, but now only the latter is accepted.
2017-11-01 14:15:24 -04:00
|
|
|
wxREGISTER_UNIT_TEST_WITH_TAGS(InteractiveOutputTestCase,
|
|
|
|
"[!hide][interactive][output]");
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
// implementation
|
|
|
|
// ============================================================================
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxDllLoader
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2012-03-04 15:31:42 -05:00
|
|
|
#if !defined(__WINDOWS__) && !defined(__UNIX__)
|
2010-06-21 17:03:47 -04:00
|
|
|
#undef TEST_DYNLIB
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "wx/dynlib.h"
|
|
|
|
|
|
|
|
void InteractiveOutputTestCase::TestDllListLoaded()
|
|
|
|
{
|
|
|
|
#ifdef TEST_DYNLIB
|
|
|
|
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];
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf("%-45s", details.GetPath());
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
void *addr wxDUMMY_INITIALIZE(NULL);
|
|
|
|
size_t len wxDUMMY_INITIALIZE(0);
|
|
|
|
if ( details.GetAddress(&addr, &len) )
|
|
|
|
{
|
2018-07-29 05:58:01 -04:00
|
|
|
wxPrintf(" %p:%p", addr, (void *)((char *)addr + len));
|
2010-06-21 17:03:47 -04:00
|
|
|
}
|
|
|
|
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf(" %s\n", details.GetVersion());
|
2010-06-21 17:03:47 -04:00
|
|
|
}
|
2010-07-12 18:50:41 -04:00
|
|
|
|
2010-06-21 17:03:47 -04:00
|
|
|
wxPuts(wxEmptyString);
|
|
|
|
#endif // TEST_DYNLIB
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// MIME types
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/mimetype.h"
|
|
|
|
|
|
|
|
void InteractiveOutputTestCase::TestMimeEnum()
|
|
|
|
{
|
|
|
|
#ifdef TEST_MIME
|
|
|
|
wxPuts(wxT("*** Testing wxMimeTypesManager::EnumAllFileTypes() ***\n"));
|
|
|
|
|
|
|
|
wxArrayString mimetypes;
|
|
|
|
|
|
|
|
size_t count = wxTheMimeTypesManager->EnumAllFileTypes(mimetypes);
|
|
|
|
|
2018-07-29 05:58:01 -04:00
|
|
|
wxPrintf(wxT("*** All %zu known filetypes: ***\n"), count);
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
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"),
|
2018-07-29 05:14:23 -04:00
|
|
|
mimetypes[n]);
|
2010-06-21 17:03:47 -04:00
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf(wxT(" %s: %s (%s)\n"), mimetypes[n], desc, extsAll);
|
2010-06-21 17:03:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
wxPuts(wxEmptyString);
|
|
|
|
#endif // TEST_MIME
|
|
|
|
}
|
|
|
|
|
|
|
|
void InteractiveOutputTestCase::TestMimeFilename()
|
|
|
|
{
|
|
|
|
#ifdef TEST_MIME
|
|
|
|
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 )
|
|
|
|
{
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf(wxT("WARNING: extension '%s' is unknown.\n"), ext);
|
2010-06-21 17:03:47 -04:00
|
|
|
}
|
|
|
|
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('"');
|
|
|
|
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf(wxT("To open %s (%s) run:\n %s\n"), fname, desc, cmd);
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
delete ft;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wxPuts(wxEmptyString);
|
|
|
|
#endif // TEST_MIME
|
|
|
|
}
|
|
|
|
|
|
|
|
void InteractiveOutputTestCase::TestMimeAssociate()
|
|
|
|
{
|
|
|
|
#ifdef TEST_MIME
|
|
|
|
wxPuts(wxT("*** Testing creation of filetype association ***\n"));
|
|
|
|
|
2010-10-01 09:05:42 -04:00
|
|
|
wxFileTypeInfo ftInfo("application/x-xyz");
|
|
|
|
ftInfo.SetOpenCommand("xyzview '%s'");
|
|
|
|
ftInfo.SetDescription("XYZ File");
|
|
|
|
ftInfo.AddExtension(".xyz");
|
2010-06-21 17:03:47 -04:00
|
|
|
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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/utils.h"
|
|
|
|
|
|
|
|
void InteractiveOutputTestCase::TestOsInfo()
|
|
|
|
{
|
|
|
|
#ifdef TEST_INFO_FUNCTIONS
|
|
|
|
wxPuts(wxT("*** Testing OS info functions ***\n"));
|
|
|
|
|
|
|
|
int major, minor;
|
|
|
|
wxGetOsVersion(&major, &minor);
|
|
|
|
wxPrintf(wxT("Running under: %s, version %d.%d\n"),
|
2018-07-29 05:14:23 -04:00
|
|
|
wxGetOsDescription(), major, minor);
|
2010-06-21 17:03:47 -04:00
|
|
|
|
2018-07-29 05:58:01 -04:00
|
|
|
wxPrintf(wxT("%lld free bytes of memory left.\n"), wxGetFreeMemory());
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
wxPrintf(wxT("Host name is %s (%s).\n"),
|
2018-07-29 05:14:23 -04:00
|
|
|
wxGetHostName(), wxGetFullHostName());
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
wxPuts(wxEmptyString);
|
|
|
|
#endif // TEST_INFO_FUNCTIONS
|
|
|
|
}
|
|
|
|
|
|
|
|
void InteractiveOutputTestCase::TestPlatformInfo()
|
|
|
|
{
|
|
|
|
#ifdef TEST_INFO_FUNCTIONS
|
|
|
|
wxPuts(wxT("*** Testing wxPlatformInfo functions ***\n"));
|
|
|
|
|
|
|
|
// get this platform
|
|
|
|
wxPlatformInfo plat;
|
|
|
|
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf(wxT("Operating system family name is: %s\n"), plat.GetOperatingSystemFamilyName());
|
|
|
|
wxPrintf(wxT("Operating system name is: %s\n"), plat.GetOperatingSystemIdName());
|
|
|
|
wxPrintf(wxT("Port ID name is: %s\n"), plat.GetPortIdName());
|
|
|
|
wxPrintf(wxT("Port ID short name is: %s\n"), plat.GetPortIdShortName());
|
2020-11-21 10:48:42 -05:00
|
|
|
wxPrintf(wxT("Architecture bitness is: %s\n"), plat.GetBitnessName());
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf(wxT("Endianness is: %s\n"), plat.GetEndiannessName());
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
wxPuts(wxEmptyString);
|
|
|
|
#endif // TEST_INFO_FUNCTIONS
|
|
|
|
}
|
|
|
|
|
|
|
|
void InteractiveOutputTestCase::TestUserInfo()
|
|
|
|
{
|
|
|
|
#ifdef TEST_INFO_FUNCTIONS
|
|
|
|
wxPuts(wxT("*** Testing user info functions ***\n"));
|
|
|
|
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf(wxT("User id is:\t%s\n"), wxGetUserId());
|
|
|
|
wxPrintf(wxT("User name is:\t%s\n"), wxGetUserName());
|
|
|
|
wxPrintf(wxT("Home dir is:\t%s\n"), wxGetHomeDir());
|
|
|
|
wxPrintf(wxT("Email address:\t%s\n"), wxGetEmailAddress());
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
wxPuts(wxEmptyString);
|
|
|
|
#endif // TEST_INFO_FUNCTIONS
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// stack backtrace
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2010-06-21 19:32:34 -04:00
|
|
|
#if wxUSE_STACKWALKER
|
|
|
|
|
2010-06-21 17:03:47 -04:00
|
|
|
#include "wx/stackwalk.h"
|
|
|
|
|
|
|
|
class StackDump : public wxStackWalker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
StackDump(const char *argv0)
|
|
|
|
: wxStackWalker(argv0)
|
|
|
|
{
|
|
|
|
}
|
2010-07-12 18:50:41 -04:00
|
|
|
|
2018-09-21 13:46:49 -04:00
|
|
|
virtual void Walk(size_t skip = 1, size_t maxdepth = wxSTACKWALKER_MAX_DEPTH) wxOVERRIDE
|
2010-06-21 17:03:47 -04:00
|
|
|
{
|
|
|
|
wxPuts(wxT("Stack dump:"));
|
|
|
|
|
|
|
|
wxStackWalker::Walk(skip, maxdepth);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2018-09-21 13:46:49 -04:00
|
|
|
virtual void OnStackFrame(const wxStackFrame& frame) wxOVERRIDE
|
2010-06-21 17:03:47 -04:00
|
|
|
{
|
2018-07-29 05:58:01 -04:00
|
|
|
wxPrintf("[%2zu] ", frame.GetLevel());
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
wxString name = frame.GetName();
|
|
|
|
if ( !name.empty() )
|
|
|
|
{
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf("%-20.40s", name);
|
2010-06-21 17:03:47 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-07-29 05:58:01 -04:00
|
|
|
wxPrintf("0x%p", frame.GetAddress());
|
2010-06-21 17:03:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( frame.HasSourceLocation() )
|
|
|
|
{
|
2018-07-29 05:58:01 -04:00
|
|
|
wxPrintf("\t%s:%zu", frame.GetFileName(), frame.GetLine());
|
2010-06-21 17:03:47 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
puts("");
|
|
|
|
|
|
|
|
wxString type, val;
|
|
|
|
for ( size_t n = 0; frame.GetParam(n, &type, &name, &val); n++ )
|
|
|
|
{
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf("\t%s %s = %s\n", type, name, val);
|
2010-06-21 17:03:47 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2010-06-21 19:32:34 -04:00
|
|
|
#endif
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
void InteractiveOutputTestCase::TestStackWalk()
|
|
|
|
{
|
|
|
|
#ifdef TEST_STACKWALKER
|
2010-06-21 19:32:34 -04:00
|
|
|
#if wxUSE_STACKWALKER
|
2010-06-21 17:03:47 -04:00
|
|
|
wxPuts(wxT("*** Testing wxStackWalker ***"));
|
|
|
|
|
2010-07-13 10:13:12 -04:00
|
|
|
wxString progname(wxTheApp->argv[0]);
|
|
|
|
StackDump dump(progname.utf8_str());
|
2010-06-21 17:03:47 -04:00
|
|
|
dump.Walk();
|
2010-07-12 18:50:41 -04:00
|
|
|
|
2010-06-21 17:03:47 -04:00
|
|
|
wxPuts("\n");
|
2010-06-21 19:32:34 -04:00
|
|
|
#endif
|
2010-06-21 17:03:47 -04:00
|
|
|
#endif // TEST_STACKWALKER
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// standard paths
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/stdpaths.h"
|
|
|
|
#include "wx/wxchar.h" // wxPrintf
|
|
|
|
|
|
|
|
void InteractiveOutputTestCase::TestStandardPaths()
|
|
|
|
{
|
|
|
|
#ifdef TEST_STDPATHS
|
|
|
|
wxPuts(wxT("*** Testing wxStandardPaths ***"));
|
|
|
|
|
|
|
|
wxTheApp->SetAppName(wxT("console"));
|
|
|
|
|
|
|
|
wxStandardPathsBase& stdp = wxStandardPaths::Get();
|
2018-07-29 05:14:23 -04:00
|
|
|
wxPrintf(wxT("Config dir (sys):\t%s\n"), stdp.GetConfigDir());
|
|
|
|
wxPrintf(wxT("Config dir (user):\t%s\n"), stdp.GetUserConfigDir());
|
|
|
|
wxPrintf(wxT("Data dir (sys):\t\t%s\n"), stdp.GetDataDir());
|
|
|
|
wxPrintf(wxT("Data dir (sys local):\t%s\n"), stdp.GetLocalDataDir());
|
|
|
|
wxPrintf(wxT("Data dir (user):\t%s\n"), stdp.GetUserDataDir());
|
|
|
|
wxPrintf(wxT("Data dir (user local):\t%s\n"), stdp.GetUserLocalDataDir());
|
|
|
|
wxPrintf(wxT("Documents dir:\t\t%s\n"), stdp.GetDocumentsDir());
|
|
|
|
wxPrintf(wxT("Cache dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Cache));
|
|
|
|
wxPrintf(wxT("Desktop dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Desktop));
|
|
|
|
wxPrintf(wxT("Downloads dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Downloads));
|
|
|
|
wxPrintf(wxT("Music dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Music));
|
|
|
|
wxPrintf(wxT("Pictures dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Pictures));
|
|
|
|
wxPrintf(wxT("Videos dir:\t\t%s\n"), stdp.GetUserDir(wxStandardPaths::Dir_Videos));
|
|
|
|
wxPrintf(wxT("Executable path:\t%s\n"), stdp.GetExecutablePath());
|
|
|
|
wxPrintf(wxT("Plugins dir:\t\t%s\n"), stdp.GetPluginsDir());
|
|
|
|
wxPrintf(wxT("Resources dir:\t\t%s\n"), stdp.GetResourcesDir());
|
2010-06-21 17:03:47 -04:00
|
|
|
wxPrintf(wxT("Localized res. dir:\t%s\n"),
|
2018-07-29 05:14:23 -04:00
|
|
|
stdp.GetLocalizedResourcesDir(wxT("fr")));
|
2010-06-21 17:03:47 -04:00
|
|
|
wxPrintf(wxT("Message catalogs dir:\t%s\n"),
|
|
|
|
stdp.GetLocalizedResourcesDir
|
|
|
|
(
|
|
|
|
wxT("fr"),
|
|
|
|
wxStandardPaths::ResourceCat_Messages
|
2018-07-29 05:14:23 -04:00
|
|
|
));
|
2010-07-12 18:50:41 -04:00
|
|
|
|
2010-06-21 17:03:47 -04:00
|
|
|
wxPuts("\n");
|
|
|
|
#endif // TEST_STDPATHS
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxVolume tests
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#if !defined(__WIN32__) || !wxUSE_FSVOLUME
|
|
|
|
#undef TEST_VOLUME
|
|
|
|
#endif
|
|
|
|
|
2010-06-21 17:46:29 -04:00
|
|
|
#ifdef TEST_VOLUME
|
2010-06-21 17:03:47 -04:00
|
|
|
|
2010-06-21 17:46:29 -04:00
|
|
|
#include "wx/volume.h"
|
2010-06-21 17:03:47 -04:00
|
|
|
static const wxChar *volumeKinds[] =
|
|
|
|
{
|
|
|
|
wxT("floppy"),
|
|
|
|
wxT("hard disk"),
|
|
|
|
wxT("CD-ROM"),
|
|
|
|
wxT("DVD-ROM"),
|
|
|
|
wxT("network volume"),
|
|
|
|
wxT("other volume"),
|
|
|
|
};
|
|
|
|
|
2010-06-21 17:46:29 -04:00
|
|
|
#endif
|
|
|
|
|
2010-06-21 17:03:47 -04:00
|
|
|
void InteractiveOutputTestCase::TestFSVolume()
|
|
|
|
{
|
|
|
|
#ifdef TEST_VOLUME
|
|
|
|
wxPuts(wxT("*** Testing wxFSVolume class ***"));
|
|
|
|
|
|
|
|
wxArrayString volumes = wxFSVolume::GetVolumes();
|
|
|
|
size_t count = volumes.GetCount();
|
|
|
|
|
|
|
|
if ( !count )
|
|
|
|
{
|
|
|
|
wxPuts(wxT("ERROR: no mounted volumes?"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-29 05:58:01 -04:00
|
|
|
wxPrintf(wxT("%zu mounted volumes found:\n"), count);
|
2010-06-21 17:03:47 -04:00
|
|
|
|
|
|
|
for ( size_t n = 0; n < count; n++ )
|
|
|
|
{
|
|
|
|
wxFSVolume vol(volumes[n]);
|
|
|
|
if ( !vol.IsOk() )
|
|
|
|
{
|
|
|
|
wxPuts(wxT("ERROR: couldn't create volume"));
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2018-07-29 05:58:01 -04:00
|
|
|
wxPrintf(wxT("%zu: %s (%s), %s, %s, %s\n"),
|
2010-06-21 17:03:47 -04:00
|
|
|
n + 1,
|
2018-07-29 05:14:23 -04:00
|
|
|
vol.GetDisplayName(),
|
|
|
|
vol.GetName(),
|
2010-06-21 17:03:47 -04:00
|
|
|
volumeKinds[vol.GetKind()],
|
|
|
|
vol.IsWritable() ? wxT("rw") : wxT("ro"),
|
|
|
|
vol.GetFlags() & wxFS_VOL_REMOVABLE ? wxT("removable")
|
|
|
|
: wxT("fixed"));
|
|
|
|
}
|
2010-07-12 18:50:41 -04:00
|
|
|
|
2010-06-21 17:03:47 -04:00
|
|
|
wxPuts("\n");
|
|
|
|
#endif // TEST_VOLUME
|
|
|
|
}
|
|
|
|
|