update dev300-m58
[ooovba.git] / sal / workben / t_osl_getVolInfo.cxx
blobc50a8e41d39cf7f6e06472c2598bf42cab93e491
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: t_osl_getVolInfo.cxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sal.hxx"
34 #include <cppunit/simpleheader.hxx>
35 #include <osl/file.h>
36 #include <rtl/ustring.hxx>
38 #ifdef WNT
39 # define TEST_PATH_1 "c:\\"
40 # define TEST_PATH_2 "c:\\mnt\\MSDN"
41 # define TEST_PATH_3 "c:\\Program Files"
42 # define TEST_PATH_4 "\\\\Tra-1\\mnt\\c"
43 # define TEST_PATH_5 "\\\\Tra-1\\mnt"
44 # define TEST_PATH_6 "\\\\Tra-1\\mnt\\c\\"
45 #else // UNX
46 # define TEST_PATH_1 "/net/athene/export/home/tra"
47 # define TEST_PATH_2 "/net/athene/export/home/tra/"
48 # define TEST_PATH_3 "/"
49 # define TEST_PATH_4 "."
50 # define TEST_PATH_5 "/net/athene/export/home/tra/projects"
51 # define TEST_PATH_6 "/blah"
52 #endif
54 //------------------------------
55 //
56 //------------------------------
58 void test_getVolumeInformation(const rtl::OUString& path_url)
60 oslVolumeInfo vi;
61 memset((void*)&vi, 0, sizeof(vi));
62 vi.uStructSize = sizeof(vi);
63 vi.pDeviceHandle = NULL;
65 oslFileError err = osl_getVolumeInformation(
66 path_url.pData,
67 &vi,
68 osl_VolumeInfo_Mask_Attributes |
69 osl_VolumeInfo_Mask_TotalSpace |
70 osl_VolumeInfo_Mask_UsedSpace |
71 osl_VolumeInfo_Mask_FreeSpace |
72 osl_VolumeInfo_Mask_MaxNameLength |
73 osl_VolumeInfo_Mask_MaxPathLength |
74 osl_VolumeInfo_Mask_FileSystemName |
75 osl_VolumeInfo_Mask_DeviceHandle);
77 CPPUNIT_ASSERT_MESSAGE
79 "osl_getVolumeInformation failed",
80 err == osl_File_E_None
81 );
84 //------------------------------
85 //
86 //------------------------------
88 class TestClass_osl_getVolumeInformation : public CppUnit::TestFixture
90 public:
92 /*-------------------------------------
93 Start a process and join with this
94 process specify a timeout so that
95 osl_joinProcessWithTimeout returns
96 osl_Process_E_TimedOut
97 -------------------------------------*/
99 void test_osl_getVolumeInformation()
101 rtl::OUString path = rtl::OUString::createFromAscii(TEST_PATH_1);
102 rtl::OUString path_url;
103 osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
104 test_getVolumeInformation(path_url);
106 path = rtl::OUString::createFromAscii(TEST_PATH_2);
107 osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
108 test_getVolumeInformation(path_url);
110 path = rtl::OUString::createFromAscii(TEST_PATH_3);
111 osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
112 test_getVolumeInformation(path_url);
114 path = rtl::OUString::createFromAscii(TEST_PATH_4);
115 osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
116 test_getVolumeInformation(path_url);
118 path = rtl::OUString::createFromAscii(TEST_PATH_5);
119 osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
120 test_getVolumeInformation(path_url);
122 path = rtl::OUString::createFromAscii(TEST_PATH_6);
123 osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
124 test_getVolumeInformation(path_url);
127 CPPUNIT_TEST_SUITE( TestClass_osl_getVolumeInformation );
128 CPPUNIT_TEST( test_osl_getVolumeInformation );
129 CPPUNIT_TEST_SUITE_END( );
132 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestClass_osl_getVolumeInformation, "Test osl_getVolumeInformation");
134 NOADDITIONAL;