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 10cdf0e10cSrcweir * 1187d2adbcSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 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. 19cdf0e10cSrcweir * 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 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: 80*c27c15f7SDamjan Jovanovic }; 81cdf0e10cSrcweir 82cdf0e10cSrcweir /*------------------------------------- 83cdf0e10cSrcweir Start a process and join with this 84cdf0e10cSrcweir process specify a timeout so that 85cdf0e10cSrcweir osl_joinProcessWithTimeout returns 86cdf0e10cSrcweir osl_Process_E_TimedOut 87cdf0e10cSrcweir -------------------------------------*/ 88cdf0e10cSrcweir 89cdf0e10cSrcweir void test_osl_getVolumeInformation() 90cdf0e10cSrcweir { 91cdf0e10cSrcweir rtl::OUString path = rtl::OUString::createFromAscii(TEST_PATH_1); 92cdf0e10cSrcweir rtl::OUString path_url; 93cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 94cdf0e10cSrcweir test_getVolumeInformation(path_url); 95cdf0e10cSrcweir 96cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_2); 97cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 98cdf0e10cSrcweir test_getVolumeInformation(path_url); 99cdf0e10cSrcweir 100cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_3); 101cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 102cdf0e10cSrcweir test_getVolumeInformation(path_url); 103cdf0e10cSrcweir 104cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_4); 105cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 106cdf0e10cSrcweir test_getVolumeInformation(path_url); 107cdf0e10cSrcweir 108cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_5); 109cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 110cdf0e10cSrcweir test_getVolumeInformation(path_url); 111cdf0e10cSrcweir 112cdf0e10cSrcweir path = rtl::OUString::createFromAscii(TEST_PATH_6); 113cdf0e10cSrcweir osl_getFileURLFromSystemPath(path.pData, &path_url.pData); 114cdf0e10cSrcweir test_getVolumeInformation(path_url); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 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