1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <sal/types.h>
21 #include <cppunit/simpleheader.hxx>
23 #include <rtl/ustring.hxx>
26 # define TEST_PATH_1 "c:\\"
27 # define TEST_PATH_2 "c:\\mnt\\MSDN"
28 # define TEST_PATH_3 "c:\\Program Files"
29 # define TEST_PATH_4 "\\\\Tra-1\\mnt\\c"
30 # define TEST_PATH_5 "\\\\Tra-1\\mnt"
31 # define TEST_PATH_6 "\\\\Tra-1\\mnt\\c\\"
33 # define TEST_PATH_1 "/net/athene/export/home/tra"
34 # define TEST_PATH_2 "/net/athene/export/home/tra/"
35 # define TEST_PATH_3 "/"
36 # define TEST_PATH_4 "."
37 # define TEST_PATH_5 "/net/athene/export/home/tra/projects"
38 # define TEST_PATH_6 "/blah"
41 void test_getVolumeInformation(const rtl::OUString
& path_url
)
44 memset((void*)&vi
, 0, sizeof(vi
));
45 vi
.uStructSize
= sizeof(vi
);
46 vi
.pDeviceHandle
= NULL
;
48 oslFileError err
= osl_getVolumeInformation(
51 osl_VolumeInfo_Mask_Attributes
|
52 osl_VolumeInfo_Mask_TotalSpace
|
53 osl_VolumeInfo_Mask_UsedSpace
|
54 osl_VolumeInfo_Mask_FreeSpace
|
55 osl_VolumeInfo_Mask_MaxNameLength
|
56 osl_VolumeInfo_Mask_MaxPathLength
|
57 osl_VolumeInfo_Mask_FileSystemName
|
58 osl_VolumeInfo_Mask_DeviceHandle
);
60 CPPUNIT_ASSERT_MESSAGE
62 "osl_getVolumeInformation failed",
63 err
== osl_File_E_None
67 class TestClass_osl_getVolumeInformation
: public CppUnit::TestFixture
71 /*-------------------------------------
72 Start a process and join with this
73 process specify a timeout so that
74 osl_joinProcessWithTimeout returns
75 osl_Process_E_TimedOut
76 -------------------------------------*/
78 void test_osl_getVolumeInformation()
80 rtl::OUString path
= rtl::OUString(TEST_PATH_1
);
81 rtl::OUString path_url
;
82 osl_getFileURLFromSystemPath(path
.pData
, &path_url
.pData
);
83 test_getVolumeInformation(path_url
);
85 path
= rtl::OUString(TEST_PATH_2
);
86 osl_getFileURLFromSystemPath(path
.pData
, &path_url
.pData
);
87 test_getVolumeInformation(path_url
);
89 path
= rtl::OUString(TEST_PATH_3
);
90 osl_getFileURLFromSystemPath(path
.pData
, &path_url
.pData
);
91 test_getVolumeInformation(path_url
);
93 path
= rtl::OUString(TEST_PATH_4
);
94 osl_getFileURLFromSystemPath(path
.pData
, &path_url
.pData
);
95 test_getVolumeInformation(path_url
);
97 path
= rtl::OUString(TEST_PATH_5
);
98 osl_getFileURLFromSystemPath(path
.pData
, &path_url
.pData
);
99 test_getVolumeInformation(path_url
);
101 path
= rtl::OUString(TEST_PATH_6
);
102 osl_getFileURLFromSystemPath(path
.pData
, &path_url
.pData
);
103 test_getVolumeInformation(path_url
);
106 CPPUNIT_TEST_SUITE( TestClass_osl_getVolumeInformation
);
107 CPPUNIT_TEST( test_osl_getVolumeInformation
);
108 CPPUNIT_TEST_SUITE_END( );
111 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( TestClass_osl_getVolumeInformation
, "Test osl_getVolumeInformation");
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */