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 <cppunit/simpleheader.hxx> 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 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 CPPUNIT_ASSERT_MESSAGE 71 ( 72 "osl_getVolumeInformation failed", 73 err == osl_File_E_None 74 ); 75 } 76 77 //------------------------------ 78 // 79 //------------------------------ 80 81 class TestClass_osl_getVolumeInformation : public CppUnit::TestFixture 82 { 83 public: 84 85 /*------------------------------------- 86 Start a process and join with this 87 process specify a timeout so that 88 osl_joinProcessWithTimeout returns 89 osl_Process_E_TimedOut 90 -------------------------------------*/ 91 92 void test_osl_getVolumeInformation() 93 { 94 rtl::OUString path = rtl::OUString::createFromAscii(TEST_PATH_1); 95 rtl::OUString path_url; 96 osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 97 test_getVolumeInformation(path_url); 98 99 path = rtl::OUString::createFromAscii(TEST_PATH_2); 100 osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 101 test_getVolumeInformation(path_url); 102 103 path = rtl::OUString::createFromAscii(TEST_PATH_3); 104 osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 105 test_getVolumeInformation(path_url); 106 107 path = rtl::OUString::createFromAscii(TEST_PATH_4); 108 osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 109 test_getVolumeInformation(path_url); 110 111 path = rtl::OUString::createFromAscii(TEST_PATH_5); 112 osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 113 test_getVolumeInformation(path_url); 114 115 path = rtl::OUString::createFromAscii(TEST_PATH_6); 116 osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 117 test_getVolumeInformation(path_url); 118 } 119 120 CPPUNIT_TEST_SUITE( TestClass_osl_getVolumeInformation ); 121 CPPUNIT_TEST( test_osl_getVolumeInformation ); 122 CPPUNIT_TEST_SUITE_END( ); 123 }; 124 125 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestClass_osl_getVolumeInformation, "Test osl_getVolumeInformation"); 126 127 NOADDITIONAL; 128 129