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 #ifndef INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
21 #define INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
26 #include <sal/types.h>
28 #include <rtl/ustring.hxx>
30 #include <cppunit/extensions/HelperMacros.h>
32 static OUString
getTempDirectoryURL_()
35 CPPUNIT_ASSERT_EQUAL_MESSAGE("couldn't get system temp URL",
36 osl::FileBase::E_None
, osl::FileBase::getTempDirURL(aDir
));
37 // This resolves symlinks in the temp path if any
38 CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None
,
39 osl::FileBase::getAbsoluteFileURL(aDir
, aDir
, aDir
));
43 static OUString
getTempDirectorySys_()
46 CPPUNIT_ASSERT_EQUAL_MESSAGE("couldn't get system temp directory",
47 osl::FileBase::E_None
, osl::FileBase::getSystemPathFromFileURL(getTempDirectoryURL_(), aDir
));
56 // common used string resource
57 // these common used string will be used as assist resource in test
58 // they are mostly OS independent, some of the resource can be reused
59 // so, a common test data repository will be better since it can be
60 // shared among all test code
62 const char pBuffer_Char
[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
63 const char pBuffer_Number
[] = "1234567890";
64 const char pBuffer_Blank
[] = "";
66 // OS dependent/independent definitions/includes
67 // we use FILE_PREFIX for URL prefix,
68 // TEST_PLATFORM for test platform initial,
69 // TEST_PLATFORM_ROOT for root dir in comrresponding platform,
70 // TEST_PLATFORM_TEMP for temp dir in comrresponding platform,
71 // PATH_LIST_DELIMITER for separator of path list in comrresponding platform,
72 // PATH_SEPARATOR for separator in URL or system path in comrresponding platform,
73 // PATH_MAX/MAX_PATH for max path length in comrresponding platform,
75 // OS independent const definition
77 # define FILE_PREFIX "file:///"
78 # define TEST_FILE_SIZE 1024
80 // OS dependent declaration and includes
82 #if ( defined UNX ) //Unix
88 # include <sys/stat.h>
89 # if !defined(MACOSX) && !defined(IOS) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__NetBSD__) && !defined (DRAGONFLY) && !defined(HAIKU)
90 # include <sys/statfs.h>
92 # include <sys/param.h>
94 # include <sys/mount.h>
97 # if !defined(ANDROID)
98 # include <sys/statvfs.h>
100 # include <sys/types.h>
101 # define TEST_PLATFORM_ROOT "/"
102 # define PATH_LIST_DELIMITER ":"
103 # define PATH_SEPARATOR "/"
106 #if defined(_WIN32) // Windows
108 # define PATH_MAX MAX_PATH
109 # define TEST_PLATFORM_ROOT "c:/"
110 # define PATH_LIST_DELIMITER ";"
111 # define PATH_SEPARATOR "/"
114 // OS independent file definition
116 OUString
aNullURL( u
""_ustr
);
117 OUString
aSlashURL( u
"" PATH_SEPARATOR
""_ustr
);
118 OUString
aPreURL( u
"" FILE_PREFIX
""_ustr
);
119 OUString
aRootURL( u
"" FILE_PREFIX TEST_PLATFORM_ROOT
""_ustr
);
121 OUString
aTempDirectorySys(getTempDirectorySys_());
122 OUString
aTempDirectoryURL(getTempDirectoryURL_());
123 OUString
aUserDirectorySys( aTempDirectorySys
+ "" );
124 OUString
aUserDirectoryURL( aTempDirectoryURL
+ "" );
126 // common used URL:temp, canonical, root, relative, link,etc
128 OUString
aCanURL1( aTempDirectoryURL
+ "/canonical.name" );
130 RTL_CONSTASCII_USTRINGPARAM("ca@#;+.,$///78no\0ni..name"));
131 OUString
aCanURL3( u
"ca@#;+.,$//tmp/678nonical//name"_ustr
);
132 OUString
aCanURL4( u
"canonical.name"_ustr
);
133 OUString
aTmpName1( u
"tmpdir"_ustr
);
134 OUString
aTmpName2( u
"tmpname"_ustr
);
135 OUString
aTmpName3( aTempDirectoryURL
+ "/tmpdir" );
136 OUString
aTmpName4( aTempDirectoryURL
+ "/tmpdir/tmpname" );
137 OUString
aTmpName5( aTempDirectoryURL
+ "/tmpdir/../tmpdir/./tmpname" );
138 OUString
aTmpName6( aTempDirectoryURL
+ "/tmpname" );
139 OUString
aTmpName7( aTempDirectoryURL
+ "/noaccess" );
140 OUString
aTmpName8( aTempDirectoryURL
+ "/tmpname/tmpdir" );
141 OUString
aTmpName9( aTempDirectoryURL
+ "/tmpdir/../tmpdir/./" );
142 OUString
aTmpName10(aTempDirectoryURL
+ u
"/\xE6\x9C\xAA\xE5\x91\xBD\xE5\x90\x8Dzhgb18030");
144 OUString
aRelURL1( u
"relative/file1"_ustr
);
145 OUString
aRelURL2( u
"relative/./file2"_ustr
);
146 OUString
aRelURL3( u
"relative/../file3"_ustr
);
147 OUString
aRelURL4( u
"././relative/../file4"_ustr
);
148 OUString
aRelURL5( aTempDirectoryURL
+ "/./../" );
149 OUString
aLnkURL1( aTempDirectoryURL
+ "/link.file" );
150 OUString
aHidURL1( u
".hiddenfile"_ustr
);
152 // common used System Path:temp, root,etc
154 OUString
aRootSys( u
"" TEST_PLATFORM_ROOT
""_ustr
);
155 OUString
aSysPath1( aTempDirectorySys
+ "/system.path" );
156 OUString
aSysPath2( aTempDirectorySys
+ "/system/path" );
157 OUString
aSysPath3( aTempDirectorySys
+ "/tmpdir" );
158 OUString
aSysPath4( aTempDirectorySys
+ "/tmpname" );
159 OUString
aSysPath5( aTempDirectorySys
+ u
"/\xE6\x9C\xAA\xE5\x91\xBD\xE5\x90\x8Dzhgb18030" );
160 OUString
aSysPathLnk( aTempDirectorySys
+ "/link.file" );
161 OUString
aFifoSys( aTempDirectorySys
+ "/tmpdir/fifo" );
163 // FileType URL, we pick some canonical file in corresponding system for test:
164 // socket, link, etc.
165 // Note that this may be changed in the different platform, so be careful to use.
167 #if ( defined UNX ) // Unix
168 OUString
aTypeURL1( u
"" FILE_PREFIX
"dev/ccv"_ustr
); //socket Solaris/Linux
169 OUString
aTypeURL2( u
"" FILE_PREFIX
"devices/pseudo/tcp@0:tcp"_ustr
); //special Solaris/Linux
170 OUString
aTypeURL3( u
"" FILE_PREFIX
"lib"_ustr
); //link Solaris
172 OUString
aTypeURL1( u
"" FILE_PREFIX
""_ustr
);
173 OUString
aTypeURL2( u
"" FILE_PREFIX
""_ustr
);
174 OUString
aTypeURL3( u
"" FILE_PREFIX
""_ustr
);
177 // Volume device URL, we pick some canonical volume device for test:
178 // UNIX file system, Floppy Disk, Proc file system, Temp file system, Compact Disk.
180 #if ( defined UNX ) // Unix
181 OUString
aVolURL1( u
"" FILE_PREFIX
""_ustr
); //ufs Solaris/Linux
183 OUString
aVolURL2( u
"" FILE_PREFIX
"dev/fd"_ustr
); //fd Solaris
185 OUString
aVolURL2( u
"" FILE_PREFIX
"dev/floppy/0u1440"_ustr
); //fd0 Linux
187 OUString
aVolURL3( u
"" FILE_PREFIX
"proc"_ustr
); //proc Solaris/Linux
188 OUString
aVolURL4( u
"" FILE_PREFIX
"staroffice"_ustr
); //nfs Solaris/Linux
189 OUString
aVolURL5( u
"" FILE_PREFIX
"tmp"_ustr
); //tmpfs Solaris
190 OUString
aVolURL6( u
"" FILE_PREFIX
"cdrom"_ustr
); //cd Solaris
192 OUString
aVolURL1( u
"" FILE_PREFIX
"c:/"_ustr
);
193 OUString
aVolURL2( u
"" FILE_PREFIX
"a:/"_ustr
);
194 OUString
aVolURL3( u
"" FILE_PREFIX
""_ustr
);
195 OUString
aVolURL4( u
"" FILE_PREFIX
""_ustr
);
196 OUString
aVolURL5( u
"" FILE_PREFIX
"c:/temp"_ustr
);
197 OUString
aVolURL6( u
"" FILE_PREFIX
"e:/"_ustr
);
204 #endif // INCLUDED_SAL_QA_OSL_FILE_OSL_FILE_CONST_H
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */