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