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