1*87d2adbcSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*87d2adbcSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*87d2adbcSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*87d2adbcSAndrew Rist * distributed with this work for additional information 6*87d2adbcSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*87d2adbcSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*87d2adbcSAndrew Rist * "License"); you may not use this file except in compliance 9*87d2adbcSAndrew Rist * with the License. You may obtain a copy of the License at 10*87d2adbcSAndrew Rist * 11*87d2adbcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*87d2adbcSAndrew Rist * 13*87d2adbcSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*87d2adbcSAndrew Rist * software distributed under the License is distributed on an 15*87d2adbcSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*87d2adbcSAndrew Rist * KIND, either express or implied. See the License for the 17*87d2adbcSAndrew Rist * specific language governing permissions and limitations 18*87d2adbcSAndrew Rist * under the License. 19*87d2adbcSAndrew Rist * 20*87d2adbcSAndrew Rist *************************************************************/ 21*87d2adbcSAndrew Rist 22*87d2adbcSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sal.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <cppunit/simpleheader.hxx> 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 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 70cdf0e10cSrcweir CPPUNIT_ASSERT_MESSAGE 71cdf0e10cSrcweir ( 72cdf0e10cSrcweir "osl_getVolumeInformation failed", 73cdf0e10cSrcweir err == osl_File_E_None 74cdf0e10cSrcweir ); 75cdf0e10cSrcweir } 76cdf0e10cSrcweir 77cdf0e10cSrcweir //------------------------------ 78cdf0e10cSrcweir // 79cdf0e10cSrcweir //------------------------------ 80cdf0e10cSrcweir 81cdf0e10cSrcweir class TestClass_osl_getVolumeInformation : public CppUnit::TestFixture 82cdf0e10cSrcweir { 83cdf0e10cSrcweir public: 84cdf0e10cSrcweir 85cdf0e10cSrcweir /*------------------------------------- 86cdf0e10cSrcweir Start a process and join with this 87cdf0e10cSrcweir process specify a timeout so that 88cdf0e10cSrcweir osl_joinProcessWithTimeout returns 89cdf0e10cSrcweir osl_Process_E_TimedOut 90cdf0e10cSrcweir -------------------------------------*/ 91cdf0e10cSrcweir 92cdf0e10cSrcweir void test_osl_getVolumeInformation() 93cdf0e10cSrcweir { 94cdf0e10cSrcweir rtl::OUString path = rtl::OUString::createFromAscii(TEST_PATH_1); 95cdf0e10cSrcweir rtl::OUString path_url; 96cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 97cdf0e10cSrcweir test_getVolumeInformation(path_url); 98cdf0e10cSrcweir 99cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_2); 100cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 101cdf0e10cSrcweir test_getVolumeInformation(path_url); 102cdf0e10cSrcweir 103cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_3); 104cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 105cdf0e10cSrcweir test_getVolumeInformation(path_url); 106cdf0e10cSrcweir 107cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_4); 108cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 109cdf0e10cSrcweir test_getVolumeInformation(path_url); 110cdf0e10cSrcweir 111cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_5); 112cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 113cdf0e10cSrcweir test_getVolumeInformation(path_url); 114cdf0e10cSrcweir 115cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_6); 116cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 117cdf0e10cSrcweir test_getVolumeInformation(path_url); 118cdf0e10cSrcweir } 119cdf0e10cSrcweir 120cdf0e10cSrcweir CPPUNIT_TEST_SUITE( TestClass_osl_getVolumeInformation ); 121cdf0e10cSrcweir CPPUNIT_TEST( test_osl_getVolumeInformation ); 122cdf0e10cSrcweir CPPUNIT_TEST_SUITE_END( ); 123cdf0e10cSrcweir }; 124cdf0e10cSrcweir 125cdf0e10cSrcweir CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestClass_osl_getVolumeInformation, "Test osl_getVolumeInformation"); 126cdf0e10cSrcweir 127cdf0e10cSrcweir NOADDITIONAL; 128cdf0e10cSrcweir 129