187d2adbcSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
387d2adbcSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
487d2adbcSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
587d2adbcSAndrew Rist  * distributed with this work for additional information
687d2adbcSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
787d2adbcSAndrew Rist  * to you under the Apache License, Version 2.0 (the
887d2adbcSAndrew Rist  * "License"); you may not use this file except in compliance
987d2adbcSAndrew Rist  * with the License.  You may obtain a copy of the License at
1087d2adbcSAndrew Rist  *
1187d2adbcSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
1287d2adbcSAndrew Rist  *
1387d2adbcSAndrew Rist  * Unless required by applicable law or agreed to in writing,
1487d2adbcSAndrew Rist  * software distributed under the License is distributed on an
1587d2adbcSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1687d2adbcSAndrew Rist  * KIND, either express or implied.  See the License for the
1787d2adbcSAndrew Rist  * specific language governing permissions and limitations
1887d2adbcSAndrew Rist  * under the License.
1987d2adbcSAndrew Rist  *
2087d2adbcSAndrew Rist  *************************************************************/
2187d2adbcSAndrew Rist 
2287d2adbcSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sal.hxx"
26cdf0e10cSrcweir 
27*c27c15f7SDamjan Jovanovic #include "gtest/gtest.h"
28cdf0e10cSrcweir #include <osl/file.h>
29cdf0e10cSrcweir #include <rtl/ustring.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #ifdef WNT
32cdf0e10cSrcweir #   define  TEST_PATH_1 "c:\\"
33cdf0e10cSrcweir #   define  TEST_PATH_2 "c:\\mnt\\MSDN"
34cdf0e10cSrcweir #   define  TEST_PATH_3 "c:\\Program Files"
35cdf0e10cSrcweir #   define  TEST_PATH_4 "\\\\Tra-1\\mnt\\c"
36cdf0e10cSrcweir #   define  TEST_PATH_5 "\\\\Tra-1\\mnt"
37cdf0e10cSrcweir #   define  TEST_PATH_6 "\\\\Tra-1\\mnt\\c\\"
38cdf0e10cSrcweir #else // UNX
39cdf0e10cSrcweir #   define  TEST_PATH_1 "/net/athene/export/home/tra"
40cdf0e10cSrcweir #   define  TEST_PATH_2 "/net/athene/export/home/tra/"
41cdf0e10cSrcweir #   define  TEST_PATH_3 "/"
42cdf0e10cSrcweir #   define  TEST_PATH_4 "."
43cdf0e10cSrcweir #   define  TEST_PATH_5 "/net/athene/export/home/tra/projects"
44cdf0e10cSrcweir #   define  TEST_PATH_6 "/blah"
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir 
47cdf0e10cSrcweir //------------------------------
48cdf0e10cSrcweir //
49cdf0e10cSrcweir //------------------------------
50cdf0e10cSrcweir 
test_getVolumeInformation(const rtl::OUString & path_url)51cdf0e10cSrcweir void test_getVolumeInformation(const rtl::OUString& path_url)
52cdf0e10cSrcweir     {
53cdf0e10cSrcweir         oslVolumeInfo vi;
54cdf0e10cSrcweir         memset((void*)&vi, 0, sizeof(vi));
55cdf0e10cSrcweir         vi.uStructSize   = sizeof(vi);
56cdf0e10cSrcweir         vi.pDeviceHandle = NULL;
57cdf0e10cSrcweir 
58cdf0e10cSrcweir         oslFileError err = osl_getVolumeInformation(
59cdf0e10cSrcweir             path_url.pData,
60cdf0e10cSrcweir             &vi,
61cdf0e10cSrcweir             osl_VolumeInfo_Mask_Attributes |
62cdf0e10cSrcweir             osl_VolumeInfo_Mask_TotalSpace |
63cdf0e10cSrcweir             osl_VolumeInfo_Mask_UsedSpace |
64cdf0e10cSrcweir             osl_VolumeInfo_Mask_FreeSpace |
65cdf0e10cSrcweir             osl_VolumeInfo_Mask_MaxNameLength |
66cdf0e10cSrcweir             osl_VolumeInfo_Mask_MaxPathLength |
67cdf0e10cSrcweir             osl_VolumeInfo_Mask_FileSystemName |
68cdf0e10cSrcweir             osl_VolumeInfo_Mask_DeviceHandle);
69cdf0e10cSrcweir 
70*c27c15f7SDamjan Jovanovic         ASSERT_TRUE( err == osl_File_E_None ) << "osl_getVolumeInformation failed";
71cdf0e10cSrcweir     }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir //------------------------------
74cdf0e10cSrcweir //
75cdf0e10cSrcweir //------------------------------
76cdf0e10cSrcweir 
77*c27c15f7SDamjan Jovanovic class TestClass_osl_getVolumeInformation : public ::testing::Test
78cdf0e10cSrcweir {
79cdf0e10cSrcweir public:
80cdf0e10cSrcweir };
81*c27c15f7SDamjan Jovanovic 
82*c27c15f7SDamjan Jovanovic /*-------------------------------------
83*c27c15f7SDamjan Jovanovic     Start a process and join with this
84*c27c15f7SDamjan Jovanovic     process specify a timeout so that
85*c27c15f7SDamjan Jovanovic     osl_joinProcessWithTimeout returns
86*c27c15f7SDamjan Jovanovic     osl_Process_E_TimedOut
87*c27c15f7SDamjan Jovanovic  -------------------------------------*/
88cdf0e10cSrcweir 
test_osl_getVolumeInformation()89*c27c15f7SDamjan Jovanovic void test_osl_getVolumeInformation()
90*c27c15f7SDamjan Jovanovic {
91*c27c15f7SDamjan Jovanovic     rtl::OUString path = rtl::OUString::createFromAscii(TEST_PATH_1);
92*c27c15f7SDamjan Jovanovic     rtl::OUString path_url;
93*c27c15f7SDamjan Jovanovic     osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
94*c27c15f7SDamjan Jovanovic     test_getVolumeInformation(path_url);
95*c27c15f7SDamjan Jovanovic 
96*c27c15f7SDamjan Jovanovic     path = rtl::OUString::createFromAscii(TEST_PATH_2);
97*c27c15f7SDamjan Jovanovic     osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
98*c27c15f7SDamjan Jovanovic     test_getVolumeInformation(path_url);
99*c27c15f7SDamjan Jovanovic 
100*c27c15f7SDamjan Jovanovic     path = rtl::OUString::createFromAscii(TEST_PATH_3);
101*c27c15f7SDamjan Jovanovic     osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
102*c27c15f7SDamjan Jovanovic     test_getVolumeInformation(path_url);
103*c27c15f7SDamjan Jovanovic 
104*c27c15f7SDamjan Jovanovic     path = rtl::OUString::createFromAscii(TEST_PATH_4);
105*c27c15f7SDamjan Jovanovic     osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
106*c27c15f7SDamjan Jovanovic     test_getVolumeInformation(path_url);
107*c27c15f7SDamjan Jovanovic 
108*c27c15f7SDamjan Jovanovic     path = rtl::OUString::createFromAscii(TEST_PATH_5);
109*c27c15f7SDamjan Jovanovic     osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
110*c27c15f7SDamjan Jovanovic     test_getVolumeInformation(path_url);
111*c27c15f7SDamjan Jovanovic 
112*c27c15f7SDamjan Jovanovic     path = rtl::OUString::createFromAscii(TEST_PATH_6);
113*c27c15f7SDamjan Jovanovic     osl_getFileURLFromSystemPath(path.pData, &path_url.pData);
114*c27c15f7SDamjan Jovanovic     test_getVolumeInformation(path_url);
115*c27c15f7SDamjan Jovanovic }
116cdf0e10cSrcweir 
main(int argc,char ** argv)117*c27c15f7SDamjan Jovanovic int main(int argc, char **argv)
118*c27c15f7SDamjan Jovanovic {
119*c27c15f7SDamjan Jovanovic     ::testing::InitGoogleTest(&argc, argv);
120*c27c15f7SDamjan Jovanovic     return RUN_ALL_TESTS();
121*c27c15f7SDamjan Jovanovic }
122