]> git.saurik.com Git - wxWidgets.git/commitdiff
added test of wxFSVolume
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 27 Mar 2002 23:31:51 +0000 (23:31 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 27 Mar 2002 23:31:51 +0000 (23:31 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14828 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/console/console.cpp

index fba92070c9ac5efd387d0fbc7301719dd2f60a5c..96f432813c70f876958462c944dc3374239efa4c 100644 (file)
@@ -83,6 +83,7 @@
     #define TEST_THREADS
     #define TEST_TIMER
     // #define TEST_VCARD            -- don't enable this (VZ)
+    #define TEST_VOLUME
     #define TEST_WCHAR
     #define TEST_ZIP
     #define TEST_ZLIB
@@ -90,7 +91,7 @@
     #undef TEST_ALL
     static const bool TEST_ALL = TRUE;
 #else
-    #define TEST_FILETIME
+    #define TEST_VOLUME
 
     static const bool TEST_ALL = FALSE;
 #endif
@@ -3298,6 +3299,65 @@ static void TestVCardWrite()
 
 #endif // TEST_VCARD
 
+// ----------------------------------------------------------------------------
+// wxVolume tests
+// ----------------------------------------------------------------------------
+
+#if !wxUSE_FSVOLUME
+    #undef TEST_VOLUME
+#endif
+
+#ifdef TEST_VOLUME
+
+#include "wx/volume.h"
+
+static const wxChar *volumeKinds[] =
+{
+    _T("floppy"),
+    _T("hard disk"),
+    _T("CD-ROM"),
+    _T("DVD-ROM"),
+    _T("network volume"),
+    _T("other volume"),
+};
+
+static void TestFSVolume()
+{
+    wxPuts(_T("*** Testing wxFSVolume class ***"));
+
+    wxArrayString volumes = wxFSVolume::GetVolumes();
+    size_t count = volumes.GetCount();
+
+    if ( !count )
+    {
+        wxPuts(_T("ERROR: no mounted volumes?"));
+        return;
+    }
+
+    wxPrintf(_T("%u mounted volumes found:\n"), count);
+
+    for ( size_t n = 0; n < count; n++ )
+    {
+        wxFSVolume vol(volumes[n]);
+        if ( !vol.IsOk() )
+        {
+            wxPuts(_T("ERROR: couldn't create volume"));
+            continue;
+        }
+
+        wxPrintf(_T("%u: %s (%s), %s, %s, %s\n"),
+                 n + 1,
+                 vol.GetDisplayName().c_str(),
+                 vol.GetName().c_str(),
+                 volumeKinds[vol.GetKind()],
+                 vol.IsWritable() ? _T("rw") : _T("ro"),
+                 vol.GetFlags() & wxFS_VOL_REMOVABLE ? _T("removable")
+                                                     : _T("fixed"));
+    }
+}
+
+#endif // TEST_VOLUME
+
 // ----------------------------------------------------------------------------
 // wide char (Unicode) support
 // ----------------------------------------------------------------------------
@@ -5830,6 +5890,10 @@ int main(int argc, char **argv)
     TestVCardWrite();
 #endif // TEST_VCARD
 
+#ifdef TEST_VOLUME
+    TestFSVolume();
+#endif // TEST_VOLUME
+
 #ifdef TEST_WCHAR
     TestUtf8();
     TestEncodingConverter();