Bug Summary

File:sal/qa/osl/file/osl_File.cxx
Location:line 2959, column 13
Description:Called C++ object pointer is null

Annotated Source Code

1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*************************************************************************
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 *
8 * OpenOffice.org - a multi-platform office productivity suite
9 *
10 * This file is part of OpenOffice.org.
11 *
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
15 *
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
21 *
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
26 *
27 ************************************************************************/
28
29//------------------------------------------------------------------------
30// include files
31//------------------------------------------------------------------------
32#include <sal/types.h>
33#include <rtl/ustring.hxx>
34#include <rtl/ustrbuf.hxx>
35
36#include "osl/thread.h"
37
38#include "rtl/ustrbuf.hxx"
39#include <osl/file.hxx>
40#include <osl/detail/file.h>
41#include <osl_File_Const.h>
42
43#include <cppunit/TestFixture.h>
44#include <cppunit/extensions/HelperMacros.h>
45#include <cppunit/plugin/TestPlugIn.h>
46
47#include <boost/scoped_ptr.hpp>
48
49#ifdef WNT
50#include <windows.h>
51#endif
52
53using namespace osl;
54
55using ::rtl::OUString;
56using ::rtl::OUStringToOString;
57using ::rtl::OString;
58using ::rtl::OStringToOUString;
59
60//------------------------------------------------------------------------
61// helper functions
62//------------------------------------------------------------------------
63
64/** detailed wrong message.
65*/
66inline ::rtl::OString errorToString( const ::osl::FileBase::RC _nError )
67{
68 ::rtl::OString sResult;
69 switch ( _nError ) {
70 case ::osl::FileBase::E_None:
71 sResult = "Success";
72 break;
73 case ::osl::FileBase::E_PERM:
74 sResult = "Operation not permitted";
75 break;
76 case ::osl::FileBase::E_NOENT:
77 sResult = "No such file or directory";
78 break;
79 case ::osl::FileBase::E_EXIST:
80 sResult = "Already Exist";
81 break;
82 case ::osl::FileBase::E_ACCES:
83 sResult = "Permission denied";
84 break;
85 case ::osl::FileBase::E_INVAL:
86 sResult = "The format of the parameters was not valid";
87 break;
88 case ::osl::FileBase::E_NOTDIR:
89 sResult = "Not a directory";
90 break;
91 case ::osl::FileBase::E_ISDIR:
92 sResult = "Is a directory";
93 break;
94 case ::osl::FileBase::E_BADF:
95 sResult = "Bad file";
96 break;
97 case ::osl::FileBase::E_NOTEMPTY:
98 sResult = "The directory is not empty";
99 break;
100 default:
101 sResult = "Unknown Error";
102 break;
103 }
104 return sResult;
105}
106
107rtl::OString errorToStr( ::osl::FileBase::RC const& nError)
108{
109 rtl::OString suBuf;
110 suBuf += "The returned error is: " ;
111 suBuf += errorToString(nError);
112 suBuf += "!\n";
113 return suBuf;
114}
115
116/** print a file type name.
117*/
118inline void printFileType( const ::osl::FileStatus::Type nType )
119{
120 printf( "#printFileType# " );
121 switch ( nType ) {
122 case ::osl::FileStatus::Directory:
123 printf( "This file is a: Directory.\n" );
124 break;
125 case ::osl::FileStatus::Volume:
126 printf( "This file is a: volume device.\n" );
127 break;
128 case ::osl::FileStatus::Regular:
129 printf( "This file is a: regular file.\n" );
130 break;
131 case ::osl::FileStatus::Fifo:
132 printf( "This file is a: fifo.\n" );
133 break;
134 case ::osl::FileStatus::Socket:
135 printf( "This file is a: socket.\n" );
136 break;
137 case ::osl::FileStatus::Link:
138 printf( "This file is a: link file.\n" );
139 break;
140 case ::osl::FileStatus::Special:
141 printf( "This file is a: special.\n" );
142 break;
143 case ::osl::FileStatus::Unknown:
144 printf( "The file type is unknown %d \n", nType );
145 break;
146 }
147}
148
149/** print a file attributes.
150*/
151inline void printFileAttributes( const sal_Int64 nAttributes )
152{
153 printf( "#printFileAttributes# This file is a: (" );
154 if ( ( nAttributes | osl_File_Attribute_ReadOnly0x00000001 ) == nAttributes )
155 printf( " ReadOnly " );
156 if ( ( nAttributes | osl_File_Attribute_Hidden0x00000002 ) == nAttributes )
157 printf( " Hidden " );
158 if ( ( nAttributes | osl_File_Attribute_Executable0x00000010 ) == nAttributes )
159 printf( " Executable " );
160 if ( ( nAttributes | osl_File_Attribute_GrpWrite0x00000020 ) == nAttributes )
161 printf( " GrpWrite " );
162 if ( ( nAttributes | osl_File_Attribute_GrpRead0x00000040 ) == nAttributes )
163 printf( " GrpRead " );
164 if ( ( nAttributes | osl_File_Attribute_GrpExe0x00000080 ) == nAttributes )
165 printf( " GrpExe " );
166 if ( ( nAttributes | osl_File_Attribute_OwnWrite0x00000100 ) == nAttributes )
167 printf( " OwnWrite " );
168 if ( ( nAttributes | osl_File_Attribute_OwnRead0x00000200 ) == nAttributes )
169 printf( " OwnRead " );
170 if ( ( nAttributes | osl_File_Attribute_OwnExe0x00000400 ) == nAttributes )
171 printf( " OwnExe " );
172 if ( ( nAttributes | osl_File_Attribute_OthWrite0x00000800 ) == nAttributes )
173 printf( " OthWrite " );
174 if ( ( nAttributes | osl_File_Attribute_OthRead0x00001000 ) == nAttributes )
175 printf( " OthRead " );
176 if ( ( nAttributes | osl_File_Attribute_OthExe0x00002000 ) == nAttributes )
177 printf( " OthExe " );
178 printf( ") file!\n" );
179}
180
181/** print an output wrong message.
182*/
183inline void printError( const ::osl::FileBase::RC nError )
184{
185 printf( "#printError# " );
186 printf( "%s\n", errorToStr(nError).getStr() );
187}
188
189/** print an signed Integer Number.
190*/
191inline void printInt( sal_Int64 i )
192{
193 printf( "#printInt_i64# " );
194 printf( "The Integer64 is %" SAL_PRIdINT64"lld" "\n", i);
195}
196
197/** print an unsigned Integer Number.
198*/
199inline void printInt( sal_uInt64 i )
200{
201 printf( "#printInt_u64# " );
202 printf( "The unsigned Integer64 is %" SAL_PRIuUINT64"llu" "\n", i);
203}
204
205/** print Boolean value.
206*/
207inline void printBool( sal_Bool bOk )
208{
209 printf( "#printBool# " );
210 ( sal_True((sal_Bool)1) == bOk ) ? printf( "YES!\n" ): printf( "NO!\n" );
211}
212
213/** print struct TimeValue in local time format.
214*/
215inline void printTime( TimeValue *tv )
216{
217 oslDateTime *pDateTime = ( oslDateTime* )malloc( sizeof( oslDateTime ) ) ;
218 CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pDateTime != NULL )( CppUnit::Asserter::failIf( !(pDateTime != __null), CppUnit::
Message( "assertion failed", "Expression: " "pDateTime != NULL"
, "Error in printTime() function,malloc " ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 218
) ) )
;
219 TimeValue *pLocalTV = ( TimeValue* )malloc( sizeof( TimeValue ) );
220 CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,malloc ", pLocalTV != NULL )( CppUnit::Asserter::failIf( !(pLocalTV != __null), CppUnit::
Message( "assertion failed", "Expression: " "pLocalTV != NULL"
, "Error in printTime() function,malloc " ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 220
) ) )
;
221
222 CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_getLocalTimeFromSystemTime ",sal_True == osl_getLocalTimeFromSystemTime( tv, pLocalTV ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == osl_getLocalTimeFromSystemTime
( tv, pLocalTV )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == osl_getLocalTimeFromSystemTime( tv, pLocalTV )"
, "Error in printTime() function,osl_getLocalTimeFromSystemTime "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 222 ) ) )
;
223 CPPUNIT_ASSERT_MESSAGE( "Error in printTime() function,osl_gepDateTimeFromTimeValue ",sal_True == osl_getDateTimeFromTimeValue( pLocalTV, pDateTime ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == osl_getDateTimeFromTimeValue
( pLocalTV, pDateTime )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == osl_getDateTimeFromTimeValue( pLocalTV, pDateTime )"
, "Error in printTime() function,osl_gepDateTimeFromTimeValue "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 223 ) ) )
;
224
225 printf( "#printTime# " );
226 printf( " Time is: %d/%d/%d ", pDateTime->Month, pDateTime->Day, pDateTime->Year);
227 switch ( pDateTime->DayOfWeek )
228 {
229 case 0: printf("Sun. "); break;
230 case 1: printf("Mon. "); break;
231 case 2: printf("Tue. "); break;
232 case 3: printf("Thr. "); break;
233 case 4: printf("Wen. "); break;
234 case 5: printf("Fri. "); break;
235 case 6: printf("Sat. "); break;
236 }
237 printf( " %d:%d:%d %d nsecs\n", pDateTime->Hours, pDateTime->Minutes, pDateTime->Seconds, (int) pDateTime->NanoSeconds);
238
239 free( pDateTime );
240 free( pLocalTV );
241}
242
243/** compare two TimeValue, unit is "ms", since Windows time precision is better than UNX.
244*/
245/* FIXME: the above assertion is bogus */
246
247#if ( defined UNX1 ) //precision of time in Windows is better than UNX
248# define delta2000 2000 //time precision, 2000ms
249#else
250# define delta2000 1800 //time precision, 1.8s
251#endif
252
253inline sal_Int64 t_abs64(sal_Int64 _nValue)
254{
255 // std::abs() seems to have some ambiguity problems (so-texas)
256 // return abs(_nValue);
257 printf("t_abs64(%ld)\n", (long) _nValue);
258 // CPPUNIT_ASSERT(_nValue < 2147483647);
259
260 if (_nValue < 0)
261 {
262 _nValue = -_nValue;
263 }
264 return _nValue;
265}
266
267inline sal_Bool t_compareTime( TimeValue *m_aEndTime, TimeValue *m_aStartTime, sal_Int32 nDelta)
268{
269 // sal_uInt64 uTimeValue;
270 // sal_Int64 iTimeValue;
271 //
272 // iTimeValue = t_abs64(( tv1->Seconds - tv2->Seconds) * 1000000000 + tv1->Nanosec - tv2->Nanosec);
273 // uTimeValue = ( iTimeValue / 1000000 );
274
275 sal_Int32 nDeltaSeconds = m_aEndTime->Seconds - m_aStartTime->Seconds;
276 sal_Int32 nDeltaNanoSec = sal_Int32(m_aEndTime->Nanosec) - sal_Int32(m_aStartTime->Nanosec);
277 if (nDeltaNanoSec < 0)
278 {
279 nDeltaNanoSec = 1000000000 + nDeltaNanoSec;
280 nDeltaSeconds--;
281 }
282
283 sal_Int32 nDeltaMilliSec = (nDeltaSeconds * 1000) + (nDeltaNanoSec / 1000000);
284 return ( nDeltaMilliSec < nDelta );
285}
286
287/** compare two OUString file name.
288*/
289inline sal_Bool compareFileName( const ::rtl::OUString & ustr1, const ::rtl::OUString & ustr2 )
290{
291 sal_Bool bOk;
292//on Windows, the seperatar is '\', so here change to '/', then compare
293#if defined (WNT )
294 ::rtl::OUString ustr1new,ustr2new;
295 sal_Unicode reverseSlash = (sal_Unicode)'\\';
296
297 if (ustr1.lastIndexOf(reverseSlash) != -1)
298 ustr1new = ustr1.replace(reverseSlash,(sal_Unicode)'/');
299 else
300 ustr1new = ustr1;
301 if (ustr2.lastIndexOf(reverseSlash) != -1)
302 ustr2new = ustr2.replace(reverseSlash,(sal_Unicode)'/');
303 else
304 ustr2new = ustr2;
305 bOk = ustr1new.equalsIgnoreAsciiCase( ustr2new ) ;
306#else
307 bOk = ustr1.equalsIgnoreAsciiCase( ustr2 );
308#endif
309 return bOk;
310}
311
312/** compare a OUString and an ASCII file name.
313*/
314inline sal_Bool compareFileName( const ::rtl::OUString & ustr, const sal_Char *astr )
315{
316 (void)ustr;
317 ::rtl::OUString ustr1 = rtl::OUString::createFromAscii( astr );
318 sal_Bool bOk = ustr1.equalsIgnoreAsciiCase( ustr1 ); // TODO: does it really compare with the same var?
319
320 return bOk;
321}
322
323/** simple version to judge if a file name or directory name is a URL or a system path, just to see if it
324 is start with "file:///";.
325*/
326inline sal_Bool isURL( const sal_Char *pathname )
327{
328 return ( 0 == strncmp( pathname, FILE_PREFIX"file:///", sizeof( FILE_PREFIX"file:///" ) - 1 ) );
329}
330
331/** simple version to judge if a file name or directory name is a URL or a system path, just to see if it
332 is start with "file:///";.
333*/
334inline sal_Bool isURL( const ::rtl::OUString pathname )
335{
336 return ( ( pathname.indexOf( aPreURL ) == 0 ) ? sal_True((sal_Bool)1) : sal_False((sal_Bool)0) );
337}
338
339/** concat two part to form a URL or system path, add PATH_SEPERATOR between them if necessary, add "file:///" to begining if necessary.
340*/
341inline void concatURL( ::rtl::OUString & pathname1, const ::rtl::OUString & pathname2 )
342{
343 //check if pathname1 is full qualified URL;
344 if ( !isURL( pathname1 ) )
345 {
346 ::rtl::OUString aPathName = pathname1.copy( 0 );
347 ::osl::FileBase::getFileURLFromSystemPath( pathname1, aPathName ); //convert if not full qualified URL
348 pathname1 = aPathName.copy( 0 );
349 }
350
351 sal_Int32 index = 0;
352 //check if '/' is in the end of pathname1 or at the begin of pathname2;
353 if ( ( ( index = pathname1.lastIndexOf( aSlashURL ) ) != ( pathname1.getLength() - 1 ) ) &&
354 ( ( index = pathname2.indexOf( aSlashURL ) ) != 0 ) )
355 pathname1 += aSlashURL;
356 pathname1 += pathname2;
357}
358
359/** create a temp test file using OUString name of full qualified URL or system path.
360*/
361inline void createTestFile( const ::rtl::OUString filename )
362{
363 ::rtl::OUString aPathURL = filename.copy( 0 );
364 ::osl::FileBase::RC nError;
365
366 if ( !isURL( filename ) )
367 ::osl::FileBase::getFileURLFromSystemPath( filename, aPathURL ); //convert if not full qualified URL
368
369 File aFile(aPathURL);
370 nError = aFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L | osl_File_OpenFlag_Create0x00000004L );
371 //CPPUNIT_ASSERT_MESSAGE( "In createTestFile Function: creation ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_EXIST ) );
372 if ( ( ::osl::FileBase::E_None != nError ) && ( nError != ::osl::FileBase::E_EXIST ))
373 {
374 printf("createTestFile failed!\n");
375 }
376 aFile.close();
377
378}
379
380/** create a temp test file using OUString name of full qualified URL or system path in a base directory.
381*/
382inline void createTestFile( const ::rtl::OUString basename, const ::rtl::OUString filename )
383{
384 ::rtl::OUString aBaseURL = basename.copy( 0 );
385
386 concatURL( aBaseURL, filename );
387 createTestFile( aBaseURL );
388}
389
390/** detete a temp test file using OUString name.
391*/
392inline void deleteTestFile( const ::rtl::OUString filename )
393{
394 // LLA: printf("deleteTestFile\n");
395 ::rtl::OUString aPathURL = filename.copy( 0 );
396 ::osl::FileBase::RC nError;
397
398 if ( !isURL( filename ) )
399 ::osl::FileBase::getFileURLFromSystemPath( filename, aPathURL ); //convert if not full qualified URL
400
401 nError = ::osl::File::setAttributes( aPathURL, osl_File_Attribute_GrpWrite0x00000020| osl_File_Attribute_OwnWrite0x00000100| osl_File_Attribute_OthWrite0x00000800 ); // if readonly, make writtenable.
402 CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: set writtenable ", ( ::osl::FileBase::E_None == nError ) || ( ::osl::FileBase::E_NOENT == nError ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError
) || ( ::osl::FileBase::E_NOENT == nError )), CppUnit::Message
( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError ) || ( ::osl::FileBase::E_NOENT == nError )"
, "In deleteTestFile Function: set writtenable " ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 402 ) ) )
;
403
404 nError = ::osl::File::remove( aPathURL );
405 CPPUNIT_ASSERT_MESSAGE( "In deleteTestFile Function: remove ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError
) || ( nError == ::osl::FileBase::E_NOENT )), CppUnit::Message
( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT )"
, "In deleteTestFile Function: remove " ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 405
) ) )
;
406}
407
408/** delete a temp test file using OUString name of full qualified URL or system path in a base directory.
409*/
410inline void deleteTestFile( const ::rtl::OUString basename, const ::rtl::OUString filename )
411{
412 ::rtl::OUString aBaseURL = basename.copy( 0 );
413
414 concatURL( aBaseURL, filename );
415 deleteTestFile( aBaseURL );
416}
417
418/** create a temp test directory using OUString name of full qualified URL or system path.
419*/
420inline void createTestDirectory( const ::rtl::OUString dirname )
421{
422 ::rtl::OUString aPathURL = dirname.copy( 0 );
423 ::osl::FileBase::RC nError;
424
425 if ( !isURL( dirname ) )
426 ::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL
427 nError = ::osl::Directory::create( aPathURL );
428 //CPPUNIT_ASSERT_MESSAGE( "In createTestDirectory Function: creation: ", ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_EXIST ) );
429 if ( ( ::osl::FileBase::E_None != nError ) && ( nError != ::osl::FileBase::E_EXIST ))
430 printf("createTestDirectory failed!\n");
431}
432
433/** create a temp test directory using OUString name of full qualified URL or system path in a base directory.
434*/
435inline void createTestDirectory( const ::rtl::OUString basename, const ::rtl::OUString dirname )
436{
437 ::rtl::OUString aBaseURL = basename.copy( 0 );
438 ::rtl::OString aString;
439
440 concatURL( aBaseURL, dirname );
441 createTestDirectory( aBaseURL );
442}
443
444/** delete a temp test directory using OUString name of full qualified URL or system path.
445*/
446inline void deleteTestDirectory( const ::rtl::OUString dirname )
447{
448 ::rtl::OUString aPathURL = dirname.copy( 0 );
449 ::osl::FileBase::RC nError;
450 if ( !isURL( dirname ) )
451 ::osl::FileBase::getFileURLFromSystemPath( dirname, aPathURL ); //convert if not full qualified URL
452
453 ::osl::Directory testDir( aPathURL );
454 if ( testDir.isOpen() == sal_True((sal_Bool)1) )
455 testDir.close(); //close if still open.
456
457 nError = ::osl::Directory::remove( aPathURL );
458
459 rtl::OString strError (RTL_CONSTASCII_STRINGPARAM("In deleteTestDirectory function: remove Directory ")(&("In deleteTestDirectory function: remove Directory ")[
0]), ((sal_Int32)(sizeof ("In deleteTestDirectory function: remove Directory "
) / sizeof (("In deleteTestDirectory function: remove Directory "
)[0]))-1)
);
460 strError += ::rtl::OUStringToOString( aPathURL, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
461 CPPUNIT_ASSERT_MESSAGE( strError.getStr(), ( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError
) || ( nError == ::osl::FileBase::E_NOENT )), CppUnit::Message
( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError ) || ( nError == ::osl::FileBase::E_NOENT )"
, strError.getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 461 ) ) )
;
462}
463
464/** delete a temp test directory using OUString name of full qualified URL or system path in a base directory.
465*/
466inline void deleteTestDirectory( const ::rtl::OUString basename, const ::rtl::OUString dirname )
467{
468 ::rtl::OUString aBaseURL = basename.copy( 0 );
469
470 concatURL( aBaseURL, dirname );
471 deleteTestDirectory( aBaseURL );
472}
473
474
475/** Check for the file and directory access right.
476*/
477typedef enum {
478 osl_Check_Mode_Exist,
479 osl_Check_Mode_OpenAccess,
480 osl_Check_Mode_ReadAccess,
481 osl_Check_Mode_WriteAccess
482} oslCheckMode;
483
484// not used here
485inline sal_Bool checkFile( const ::rtl::OUString & str, oslCheckMode nCheckMode )
486{
487 ::osl::FileBase::RC nError1, nError2;
488 ::osl::File testFile( str );
489 sal_Bool bCheckResult;
490
491 bCheckResult = sal_False((sal_Bool)0);
492 nError1 = testFile.open ( osl_File_OpenFlag_Read0x00000001L );
493 if ( ( ::osl::FileBase::E_NOENT != nError1 ) && ( ::osl::FileBase::E_ACCES != nError1 ) ){
494
495 switch ( nCheckMode ) {
496 case osl_Check_Mode_Exist:
497 /// check if the file is exist.
498 if ( ::osl::FileBase::E_None == nError1 )
499 bCheckResult = sal_True((sal_Bool)1);
500 break;
501 case osl_Check_Mode_OpenAccess:
502 /// check if the file is openable.
503 if ( ::osl::FileBase::E_None == nError1 )
504 bCheckResult = sal_True((sal_Bool)1);
505 break;
506 case osl_Check_Mode_WriteAccess:
507 /// check the file name and whether it can be written.
508 /// write chars into the file.
509 sal_uInt64 nCount_write;
510 nError2 = testFile.write( pBuffer_Char, 10, nCount_write );
511 if ( ::osl::FileBase::E_None == nError2 )
512 bCheckResult = sal_True((sal_Bool)1);
513 break;
514
515 default:
516 bCheckResult = sal_False((sal_Bool)0);
517 }/// swith
518
519 nError2 = testFile.close();
520 CPPUNIT_ASSERT_MESSAGE( " in CheckFile() function, close file ", nError2 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError2 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError2 == FileBase::E_None"
, " in CheckFile() function, close file " ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 520
) ) )
;
521
522 }
523
524 return bCheckResult;
525}
526
527//check if the file exist
528inline sal_Bool ifFileExist( const ::rtl::OUString & str )
529{
530 sal_Bool bCheckResult = sal_False((sal_Bool)0);
531
532/*#ifdef WNT
533 ::rtl::OUString aUStr = str.copy( 0 );
534 if ( isURL( str ) )
535 ::osl::FileBase::getSystemPathFromFileURL( str, aUStr );
536
537 ::rtl::OString aString = ::rtl::OUStringToOString( aUStr, RTL_TEXTENCODING_ASCII_US );
538 const char *path = aString.getStr();
539 if (( _access( path, 0 ) ) != -1 )
540 bCheckResult = sal_True;
541#else*/
542 ::rtl::OString aString = ::rtl::OUStringToOString( str, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
543 // const char *path = aString.getStr();
544 ::osl::File testFile( str );
545 bCheckResult = ( osl::FileBase::E_None == testFile.open( osl_File_OpenFlag_Read0x00000001L ) );
546 //if (bCheckResult)
547 //printf("%s exist!\n", path);
548 //else
549 //printf("%s not exist!\n", path);
550//#endif
551 return bCheckResult;
552
553}
554
555//check if the file can be writen
556inline sal_Bool ifFileCanWrite( const ::rtl::OUString & str )
557{
558 sal_Bool bCheckResult = sal_False((sal_Bool)0);
559 //on Windows, the file has no write right, but can be written
560#ifdef WNT
561 ::rtl::OUString aUStr = str.copy( 0 );
562 if ( isURL( str ) )
563 ::osl::FileBase::getSystemPathFromFileURL( str, aUStr );
564
565 ::rtl::OString aString = ::rtl::OUStringToOString( aUStr, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
566 const char *path = aString.getStr();
567 if (( _access( path, 2 ) ) != -1 )
568 bCheckResult = sal_True((sal_Bool)1);
569 //on UNX, just test if open success with osl_File_OpenFlag_Write
570#else
571 ::osl::File testFile( str );
572 bCheckResult = (osl::FileBase::E_None == testFile.open( osl_File_OpenFlag_Write0x00000002L ));
573#endif
574 return bCheckResult;
575}
576
577inline sal_Bool checkDirectory( const ::rtl::OUString & str, oslCheckMode nCheckMode )
578{
579 rtl::OUString aUString;
580 DirectoryItem rItem;
581 FileBase::RC rc;
582 sal_Bool bCheckResult= sal_False((sal_Bool)0);
583
584 //::std::auto_ptr<Directory> pDir( new Directory( str ) );
585 Directory aDir( str );
586 rc = aDir.open();
587
588 if ( ( ::osl::FileBase::E_NOENT != rc ) && ( ::osl::FileBase::E_ACCES != rc ) ){
589
590 switch ( nCheckMode ) {
591 case osl_Check_Mode_Exist:
592 if ( rc == ::osl::FileBase::E_None )
593 bCheckResult = sal_True((sal_Bool)1);
594 break;
595 case osl_Check_Mode_OpenAccess:
596 if ( rc == ::osl::FileBase::E_None )
597 bCheckResult = sal_True((sal_Bool)1);
598 break;
599 case osl_Check_Mode_ReadAccess:
600 //rc = pDir->getNextItem( rItem, 0 );
601 rc = aDir.getNextItem( rItem, 0 );
602 if ( ( rc == ::osl::FileBase::E_None ) || ( rc == ::osl::FileBase::E_NOENT ) )
603 bCheckResult = sal_True((sal_Bool)1);
604 else
605 bCheckResult = sal_False((sal_Bool)0);
606 break;
607 case osl_Check_Mode_WriteAccess:
608 ( ( aUString += str ) += aSlashURL ) += aTmpName2;
609 //if ( ( rc = pDir->create( aUString ) ) == ::osl::FileBase::E_None )
610 if ( ( rc = Directory::create( aUString ) ) == ::osl::FileBase::E_None )
611 {
612 bCheckResult = sal_True((sal_Bool)1);
613 //rc = pDir->remove( aUString );
614 rc = Directory::remove( aUString );
615 CPPUNIT_ASSERT( rc == ::osl::FileBase::E_None )( CppUnit::Asserter::failIf( !(rc == ::osl::FileBase::E_None)
, CppUnit::Message( "assertion failed", "Expression: " "rc == ::osl::FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 615 ) ) )
;
616 }
617 else
618 bCheckResult = sal_False((sal_Bool)0);
619 break;
620
621 default:
622 bCheckResult = sal_False((sal_Bool)0);
623 }// switch
624
625 rc = aDir.close();
626 CPPUNIT_ASSERT( rc == FileBase::E_None )( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 626 ) ) )
;
627
628 }//if
629
630 return bCheckResult;
631}
632
633/** construct error message
634*/
635inline ::rtl::OString outputError( const ::rtl::OString & returnVal, const ::rtl::OString & rightVal, const sal_Char * msg = "")
636{
637 ::rtl::OString aString;
638 if ( returnVal.equals( rightVal ) )
639 return aString;
640 aString += msg;
641 aString += ": the returned value is '";
642 aString += returnVal;
643 aString += "', but the value should be '";
644 aString += rightVal;
645 aString += "'.";
646 return aString;
647}
648
649/** Change file mode, two version in UNIX and Windows;.
650*/
651#if ( defined UNX1 ) //chmod() method is differ in Windows
652inline void changeFileMode( ::rtl::OUString & filepath, sal_Int32 mode )
653{
654 rtl::OString aString;
655 rtl::OUString aUStr = filepath.copy( 0 );
656
657 if ( isURL( filepath ) )
658 ::osl::FileBase::getSystemPathFromFileURL( filepath, aUStr );
659 aString = ::rtl::OUStringToOString( aUStr, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
660 chmod( aString.getStr(), mode );
661}
662#else //Windows version
663inline void changeFileMode( ::rtl::OUString & filepath, sal_Int32 mode )
664{
665 (void)filepath;
666 (void)mode;
667 printf("this method is not implemented yet");
668}
669#endif
670
671inline ::rtl::OUString getCurrentPID( void );
672
673
674
675//------------------------------------------------------------------------
676// Beginning of the test cases for FileBase class
677//------------------------------------------------------------------------
678namespace osl_FileBase
679{
680
681 //---------------------------------------------------------------------
682 // testing the method
683 // static inline RC getAbsoluteFileURL( const ::rtl::OUString& ustrBaseDirectoryURL,
684 // const ::rtl::OUString& ustrRelativeFileURL,
685 // ::rtl::OUString& ustrAbsoluteFileURL )
686 //---------------------------------------------------------------------
687
688 class getAbsoluteFileURL:public CppUnit::TestFixture
689 {
690 //::osl::FileBase aFileBase;
691 ::rtl::OUString aResultURL1, aResultURL2, aResultURL3, aResultURL4, aResultURL5, aResultURL6;
692 // ::osl::FileBase::RC nError;
693
694 public:
695
696 void check_getAbsoluteFileURL( rtl::OUString const& _suBaseURL, rtl::OString const& _sRelativeURL, ::osl::FileBase::RC _nAssumeError, rtl::OUString const& _suAssumeResultStr );
697
698 void getAbsoluteFileURL_001_1();
699 void getAbsoluteFileURL_001_2();
700 void getAbsoluteFileURL_001_3();
701 void getAbsoluteFileURL_001_4();
702 void getAbsoluteFileURL_001_5();
703 void getAbsoluteFileURL_001_6();
704 void getAbsoluteFileURL_001_7();
705 void getAbsoluteFileURL_001_8();
706 void getAbsoluteFileURL_002();
707 void getAbsoluteFileURL_003();
708 void getAbsoluteFileURL_004();
709
710 CPPUNIT_TEST_SUITE( getAbsoluteFileURL )public: typedef getAbsoluteFileURL TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getAbsoluteFileURL) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
711 CPPUNIT_TEST( getAbsoluteFileURL_001_1 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_001_1"), &
TestFixtureType::getAbsoluteFileURL_001_1, context.makeFixture
() ) ) )
;
712 CPPUNIT_TEST( getAbsoluteFileURL_001_2 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_001_2"), &
TestFixtureType::getAbsoluteFileURL_001_2, context.makeFixture
() ) ) )
;
713 CPPUNIT_TEST( getAbsoluteFileURL_001_3 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_001_3"), &
TestFixtureType::getAbsoluteFileURL_001_3, context.makeFixture
() ) ) )
;
714 CPPUNIT_TEST( getAbsoluteFileURL_001_4 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_001_4"), &
TestFixtureType::getAbsoluteFileURL_001_4, context.makeFixture
() ) ) )
;
715 CPPUNIT_TEST( getAbsoluteFileURL_001_5 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_001_5"), &
TestFixtureType::getAbsoluteFileURL_001_5, context.makeFixture
() ) ) )
;
716 CPPUNIT_TEST( getAbsoluteFileURL_001_6 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_001_6"), &
TestFixtureType::getAbsoluteFileURL_001_6, context.makeFixture
() ) ) )
;
717 CPPUNIT_TEST( getAbsoluteFileURL_001_7 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_001_7"), &
TestFixtureType::getAbsoluteFileURL_001_7, context.makeFixture
() ) ) )
;
718 CPPUNIT_TEST( getAbsoluteFileURL_001_8 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_001_8"), &
TestFixtureType::getAbsoluteFileURL_001_8, context.makeFixture
() ) ) )
;
719 CPPUNIT_TEST( getAbsoluteFileURL_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_002"), &
TestFixtureType::getAbsoluteFileURL_002, context.makeFixture(
) ) ) )
;
720 CPPUNIT_TEST( getAbsoluteFileURL_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_003"), &
TestFixtureType::getAbsoluteFileURL_003, context.makeFixture(
) ) ) )
;
721 CPPUNIT_TEST( getAbsoluteFileURL_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAbsoluteFileURL_004"), &
TestFixtureType::getAbsoluteFileURL_004, context.makeFixture(
) ) ) )
;
722 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
723
724 }; //class getAbsoluteFileURL
725
726 void getAbsoluteFileURL::check_getAbsoluteFileURL( rtl::OUString const& _suBaseURL, rtl::OString const& _sRelativeURL, ::osl::FileBase::RC _nAssumeError, rtl::OUString const& _suAssumeResultStr )
727 {
728 rtl::OUString suRelativeURL = rtl::OStringToOUString(_sRelativeURL, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)));
729 rtl::OString sBaseURL = rtl::OUStringToOString(_suBaseURL, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)));
730 rtl::OUString suResultURL;
731 osl::FileBase::RC nError = FileBase::getAbsoluteFileURL( _suBaseURL, suRelativeURL, suResultURL );
732 rtl::OString sResultURL = rtl::OUStringToOString( suResultURL, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)));
733 rtl::OString sError = errorToString(nError);
734 printf("getAbsoluteFileURL('%s','%s') deliver absolute URL: '%s', error '%s'\n", sBaseURL.getStr(), _sRelativeURL.getStr(),sResultURL.getStr(), sError.getStr() );
735 CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong: error number is wrong", nError == _nAssumeError )( CppUnit::Asserter::failIf( !(nError == _nAssumeError), CppUnit
::Message( "assertion failed", "Expression: " "nError == _nAssumeError"
, "Assumption is wrong: error number is wrong" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 735
) ) )
;
736 if ( nError == ::osl::FileBase::E_None )
737 {
738 sal_Bool bStrAreEqual = _suAssumeResultStr.equals( suResultURL );
739 CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong: ResultURL is not equal to expected URL ", bStrAreEqual == sal_True )( CppUnit::Asserter::failIf( !(bStrAreEqual == ((sal_Bool)1))
, CppUnit::Message( "assertion failed", "Expression: " "bStrAreEqual == sal_True"
, "Assumption is wrong: ResultURL is not equal to expected URL "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 739 ) ) )
;
740 }
741 }
742
743 void getAbsoluteFileURL::getAbsoluteFileURL_001_1()
744 {
745 rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString("/relative/file1") );
746 check_getAbsoluteFileURL( aUserDirectoryURL, "relative/file1",::osl::FileBase::E_None, suAssume );
747 }
748 void getAbsoluteFileURL::getAbsoluteFileURL_001_2()
749 {
750 rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString("/relative/file2") );
751 check_getAbsoluteFileURL( aUserDirectoryURL, "relative/./file2",::osl::FileBase::E_None, suAssume );
752 }
753 void getAbsoluteFileURL::getAbsoluteFileURL_001_3()
754 {
755 rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString("/file3") );
756 check_getAbsoluteFileURL( aUserDirectoryURL, "relative/../file3",::osl::FileBase::E_None, suAssume );
757 }
758 void getAbsoluteFileURL::getAbsoluteFileURL_001_4()
759 {
760 rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString("/file4") );
761 check_getAbsoluteFileURL( aUserDirectoryURL, "././relative/../file4",::osl::FileBase::E_None, suAssume );
762 }
763 void getAbsoluteFileURL::getAbsoluteFileURL_001_5()
764 {
765 rtl::OUString suAssume;
766#if ( defined UNX1 )
767 suAssume = aUserDirectoryURL.concat( rtl::OUString("/relative/") );
768#else
769 suAssume = aUserDirectoryURL.concat( rtl::OUString("/relative") );
770#endif
771 check_getAbsoluteFileURL( aUserDirectoryURL, "././relative/.",::osl::FileBase::E_None, suAssume );
772 }
773 void getAbsoluteFileURL::getAbsoluteFileURL_001_6()
774 {
775 rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString("/.relative") );
776 check_getAbsoluteFileURL( aUserDirectoryURL, "./.relative",::osl::FileBase::E_None, suAssume );
777 }
778 void getAbsoluteFileURL::getAbsoluteFileURL_001_7()
779 {
780 rtl::OUString suAssume;
781#if (defined UNX1 )
782 suAssume = aUserDirectoryURL.concat( rtl::OUString("/.a/") );
783#else //windows
784 suAssume = aUserDirectoryURL.concat( rtl::OUString("/.a") );
785#endif
786 check_getAbsoluteFileURL( aUserDirectoryURL, "./.a/mydir/..",::osl::FileBase::E_None, suAssume );
787 }
788 void getAbsoluteFileURL::getAbsoluteFileURL_001_8()
789 {
790 rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString("/tmp/ok") );
791#if ( defined UNX1 )
792 check_getAbsoluteFileURL( aUserDirectoryURL, "tmp//ok",::osl::FileBase::E_None, suAssume );
793#else
794 check_getAbsoluteFileURL( aUserDirectoryURL, "tmp//ok",::osl::FileBase::E_INVAL, suAssume );
795#endif
796 }
797 void getAbsoluteFileURL::getAbsoluteFileURL_002()
798 {
799#if ( defined UNX1 ) //Link is not defined in Windows
800 ::rtl::OUString aUStr_AbsURL, aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys );
801 ( ( aUStr_LnkFileSys += aSlashURL ) += getCurrentPID() ) += ::rtl::OUString("/link.file");
802 ( ( aUStr_SrcFileSys += aSlashURL ) += getCurrentPID() ) += ::rtl::OUString("/canonical.name");
803
804 rtl::OString strLinkFileName, strSrcFileName;
805 strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
806 strSrcFileName = OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
807
808 createTestFile( aCanURL1 );
809 sal_Int32 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() );
810 CPPUNIT_ASSERT( fd == 0 )( CppUnit::Asserter::failIf( !(fd == 0), CppUnit::Message( "assertion failed"
, "Expression: " "fd == 0"), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 810 ) ) )
;
811 rtl::OString sLnkURL = OUStringToOString( aLnkURL1, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
812 rtl::OUString suAssume = aUserDirectoryURL.concat( rtl::OUString("/canonical.name") );
813 check_getAbsoluteFileURL( aUserDirectoryURL, sLnkURL, ::osl::FileBase::E_None, suAssume );
814 deleteTestFile( aCanURL1 );
815 fd = remove( strLinkFileName.getStr() );
816 CPPUNIT_ASSERT( fd == 0 )( CppUnit::Asserter::failIf( !(fd == 0), CppUnit::Message( "assertion failed"
, "Expression: " "fd == 0"), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 816 ) ) )
;
817#endif
818 }
819 //please see line# 930
820 void getAbsoluteFileURL::getAbsoluteFileURL_003()
821 {
822 }
823 void getAbsoluteFileURL::getAbsoluteFileURL_004()
824 {
825 //create two level directories under $Temp/PID/
826 ::rtl::OUString aUStrUpBase = aUserDirectoryURL + ::rtl::OUString("/test1");
827 createTestDirectory( aUStrUpBase );
828 ::rtl::OUString aUStrBase = aUserDirectoryURL + ::rtl::OUString("/test1/dir1");
829 createTestDirectory( aUStrBase );
830
831 ::rtl::OUString suAssume = aUserDirectoryURL.concat( ::rtl::OUString("/mytestfile") );
832 check_getAbsoluteFileURL( aUStrBase, "../../mytestfile" , ::osl::FileBase::E_None, suAssume );
833 deleteTestDirectory( aUStrBase );
834 deleteTestDirectory( aUStrUpBase );
835 }
836 //---------------------------------------------------------------------
837 // testing two methods:
838 // static inline RC getSystemPathFromFileURL( const ::rtl::OUString& ustrFileURL,
839 // ::rtl::OUString& ustrSystemPath )
840 // static RC getFileURLFromSystemPath( const ::rtl::OUString & ustrSystemPath,
841 // ::rtl::OUString & ustrFileURL );
842 //---------------------------------------------------------------------
843 class SystemPath_FileURL:public CppUnit::TestFixture
844 {
845 //::osl::FileBase aFileBase;
846 // ::rtl::OUString aUStr;
847 // ::osl::FileBase::RC nError;
848
849 //void check_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sAssumeResultStr);
850 void check_SystemPath_FileURL(rtl::OString const& _sSource, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sAssumeResultStr, sal_Bool bDirection = sal_True((sal_Bool)1) );
851 void checkWNTBehaviour_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString );
852 void checkUNXBehaviour_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sUnixAssumeResultString );
853 void checkWNTBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString);
854 void checkUNXBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sUnixAssumeResultString);
855
856 public:
857 // test code.
858 void getSystemPathFromFileURL_001_1();
859 void getSystemPathFromFileURL_001_2();
860 void getSystemPathFromFileURL_001_21();
861 void getSystemPathFromFileURL_001_22();
862 void getSystemPathFromFileURL_001_3();
863 void getSystemPathFromFileURL_001_31();
864 void getSystemPathFromFileURL_001_4();
865 void getSystemPathFromFileURL_001_41();
866 void getSystemPathFromFileURL_001_5();
867 void getSystemPathFromFileURL_001_51();
868 void getSystemPathFromFileURL_001_52();
869 void getSystemPathFromFileURL_001_53();
870 void getSystemPathFromFileURL_001_6();
871 void getSystemPathFromFileURL_001_61();
872 void getSystemPathFromFileURL_001_7();
873 void getSystemPathFromFileURL_001_71();
874 void getSystemPathFromFileURL_001_8();
875 void getSystemPathFromFileURL_001_81();
876 void getSystemPathFromFileURL_001_9();
877 void getSystemPathFromFileURL_001_91();
878 void getSystemPathFromFileURL_001_92();
879 void getSystemPathFromFileURL_004();
880 void getSystemPathFromFileURL_005();
881
882 //test case fot getFileURLFromSystemPath
883 void getFileURLFromSystemPath_001();
884 void getFileURLFromSystemPath_002();
885 void getFileURLFromSystemPath_003();
886 void getFileURLFromSystemPath_004();
887 void getFileURLFromSystemPath_005();
888
889 CPPUNIT_TEST_SUITE( SystemPath_FileURL )public: typedef SystemPath_FileURL TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(SystemPath_FileURL) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
890 CPPUNIT_TEST( getSystemPathFromFileURL_001_1 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_1"
), &TestFixtureType::getSystemPathFromFileURL_001_1, context
.makeFixture() ) ) )
;
891 CPPUNIT_TEST( getSystemPathFromFileURL_001_2 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_2"
), &TestFixtureType::getSystemPathFromFileURL_001_2, context
.makeFixture() ) ) )
;
892 CPPUNIT_TEST( getSystemPathFromFileURL_001_21 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_21"
), &TestFixtureType::getSystemPathFromFileURL_001_21, context
.makeFixture() ) ) )
;
893 CPPUNIT_TEST( getSystemPathFromFileURL_001_22 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_22"
), &TestFixtureType::getSystemPathFromFileURL_001_22, context
.makeFixture() ) ) )
;
894 CPPUNIT_TEST( getSystemPathFromFileURL_001_3 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_3"
), &TestFixtureType::getSystemPathFromFileURL_001_3, context
.makeFixture() ) ) )
;
895 CPPUNIT_TEST( getSystemPathFromFileURL_001_31 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_31"
), &TestFixtureType::getSystemPathFromFileURL_001_31, context
.makeFixture() ) ) )
;
896 CPPUNIT_TEST( getSystemPathFromFileURL_001_4 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_4"
), &TestFixtureType::getSystemPathFromFileURL_001_4, context
.makeFixture() ) ) )
;
897 CPPUNIT_TEST( getSystemPathFromFileURL_001_41 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_41"
), &TestFixtureType::getSystemPathFromFileURL_001_41, context
.makeFixture() ) ) )
;
898 CPPUNIT_TEST( getSystemPathFromFileURL_001_5 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_5"
), &TestFixtureType::getSystemPathFromFileURL_001_5, context
.makeFixture() ) ) )
;
899 CPPUNIT_TEST( getSystemPathFromFileURL_001_51 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_51"
), &TestFixtureType::getSystemPathFromFileURL_001_51, context
.makeFixture() ) ) )
;
900 CPPUNIT_TEST( getSystemPathFromFileURL_001_52 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_52"
), &TestFixtureType::getSystemPathFromFileURL_001_52, context
.makeFixture() ) ) )
;
901 CPPUNIT_TEST( getSystemPathFromFileURL_001_53 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_53"
), &TestFixtureType::getSystemPathFromFileURL_001_53, context
.makeFixture() ) ) )
;
902 CPPUNIT_TEST( getSystemPathFromFileURL_001_6 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_6"
), &TestFixtureType::getSystemPathFromFileURL_001_6, context
.makeFixture() ) ) )
;
903 CPPUNIT_TEST( getSystemPathFromFileURL_001_61 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_61"
), &TestFixtureType::getSystemPathFromFileURL_001_61, context
.makeFixture() ) ) )
;
904 CPPUNIT_TEST( getSystemPathFromFileURL_001_7 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_7"
), &TestFixtureType::getSystemPathFromFileURL_001_7, context
.makeFixture() ) ) )
;
905 CPPUNIT_TEST( getSystemPathFromFileURL_001_71 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_71"
), &TestFixtureType::getSystemPathFromFileURL_001_71, context
.makeFixture() ) ) )
;
906 CPPUNIT_TEST( getSystemPathFromFileURL_001_8 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_8"
), &TestFixtureType::getSystemPathFromFileURL_001_8, context
.makeFixture() ) ) )
;
907 CPPUNIT_TEST( getSystemPathFromFileURL_001_81 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_81"
), &TestFixtureType::getSystemPathFromFileURL_001_81, context
.makeFixture() ) ) )
;
908 CPPUNIT_TEST( getSystemPathFromFileURL_001_9 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_9"
), &TestFixtureType::getSystemPathFromFileURL_001_9, context
.makeFixture() ) ) )
;
909 CPPUNIT_TEST( getSystemPathFromFileURL_001_91 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_91"
), &TestFixtureType::getSystemPathFromFileURL_001_91, context
.makeFixture() ) ) )
;
910 CPPUNIT_TEST( getSystemPathFromFileURL_001_92 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_001_92"
), &TestFixtureType::getSystemPathFromFileURL_001_92, context
.makeFixture() ) ) )
;
911 CPPUNIT_TEST( getSystemPathFromFileURL_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_004")
, &TestFixtureType::getSystemPathFromFileURL_004, context
.makeFixture() ) ) )
;
912 CPPUNIT_TEST( getSystemPathFromFileURL_005 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getSystemPathFromFileURL_005")
, &TestFixtureType::getSystemPathFromFileURL_005, context
.makeFixture() ) ) )
;
913 CPPUNIT_TEST( getFileURLFromSystemPath_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileURLFromSystemPath_001")
, &TestFixtureType::getFileURLFromSystemPath_001, context
.makeFixture() ) ) )
;
914 CPPUNIT_TEST( getFileURLFromSystemPath_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileURLFromSystemPath_002")
, &TestFixtureType::getFileURLFromSystemPath_002, context
.makeFixture() ) ) )
;
915 CPPUNIT_TEST( getFileURLFromSystemPath_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileURLFromSystemPath_003")
, &TestFixtureType::getFileURLFromSystemPath_003, context
.makeFixture() ) ) )
;
916 CPPUNIT_TEST( getFileURLFromSystemPath_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileURLFromSystemPath_004")
, &TestFixtureType::getFileURLFromSystemPath_004, context
.makeFixture() ) ) )
;
917 CPPUNIT_TEST( getFileURLFromSystemPath_005 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileURLFromSystemPath_005")
, &TestFixtureType::getFileURLFromSystemPath_005, context
.makeFixture() ) ) )
;
918 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
919 };// class SystemPath_FileURL
920
921
922 // if bDirection==sal_True, check getSystemPathFromFileURL
923 // if bDirection==sal_False, check getFileURLFromSystemPath
924 void SystemPath_FileURL::check_SystemPath_FileURL(rtl::OString const& _sSource, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sAssumeResultStr, sal_Bool bDirection)
925 {
926 // PRE: URL as String
927 rtl::OUString suSource;
928 rtl::OUString suStr;
929 suSource = rtl::OStringToOUString(_sSource, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)));
930 ::osl::FileBase::RC nError;
931 if ( bDirection == sal_True((sal_Bool)1) )
932 nError = osl::FileBase::getSystemPathFromFileURL( suSource, suStr );
933 else
934 nError = osl::FileBase::getFileURLFromSystemPath( suSource, suStr );
935
936 // if the given string is gt length 0,
937 // we check also this string
938 rtl::OString sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)));
939 rtl::OString sError = errorToString(nError);
940 if ( bDirection == sal_True((sal_Bool)1) )
941 printf("getSystemPathFromFileURL('%s') deliver system path: '%s', error '%s'\n", _sSource.getStr(), sStr.getStr(), sError.getStr() );
942 else
943 printf("getFileURLFromSystemPath('%s') deliver File URL: '%s', error '%s'\n", _sSource.getStr(), sStr.getStr(), sError.getStr() );
944
945 // rtl::OUString suStrEncode = rtl::Uri::encode(suStr, rtl_UriCharClassUnoParamValue, rtl_UriEncodeKeepEscapes, RTL_TEXTENCODING_UTF8);
946 // sStr = rtl::OUStringToOString(suStr, RTL_TEXTENCODING_UTF8);
947 // printf("UTF8: %s\n", sStr.getStr() );
948
949 if (!_sAssumeResultStr.isEmpty())
950 {
951 sal_Bool bStrAreEqual = _sAssumeResultStr.equals(sStr);
952 CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong",( CppUnit::Asserter::failIf( !(nError == _nAssumeError &&
bStrAreEqual == ((sal_Bool)1)), CppUnit::Message( "assertion failed"
, "Expression: " "nError == _nAssumeError && bStrAreEqual == sal_True"
, "Assumption is wrong" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 953 ) ) )
953 nError == _nAssumeError && bStrAreEqual == sal_True )( CppUnit::Asserter::failIf( !(nError == _nAssumeError &&
bStrAreEqual == ((sal_Bool)1)), CppUnit::Message( "assertion failed"
, "Expression: " "nError == _nAssumeError && bStrAreEqual == sal_True"
, "Assumption is wrong" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 953 ) ) )
;
954 }
955 else
956 {
957 CPPUNIT_ASSERT_MESSAGE( "Assumption is wrong", nError == _nAssumeError )( CppUnit::Asserter::failIf( !(nError == _nAssumeError), CppUnit
::Message( "assertion failed", "Expression: " "nError == _nAssumeError"
, "Assumption is wrong" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 957 ) ) )
;
958 }
959 }
960 void SystemPath_FileURL::checkWNTBehaviour_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString)
961 {
962#if ( defined WNT )
963 check_SystemPath_FileURL(_sURL, _nAssumeError, _sWNTAssumeResultString);
964#else
965 (void)_sURL;
966 (void)_nAssumeError;
967 (void)_sWNTAssumeResultString;
968#endif
969 }
970
971 void SystemPath_FileURL::checkUNXBehaviour_getSystemPathFromFileURL(rtl::OString const& _sURL, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sUnixAssumeResultString)
972 {
973#if ( defined UNX1 )
974 check_SystemPath_FileURL(_sURL, _nAssumeError, _sUnixAssumeResultString);
975#else
976 (void)_sURL;
977 (void)_nAssumeError;
978 (void)_sUnixAssumeResultString;
979#endif
980 }
981
982 void SystemPath_FileURL::checkWNTBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sWNTAssumeResultString)
983 {
984#if ( defined WNT )
985 check_SystemPath_FileURL(_sSysPath, _nAssumeError, _sWNTAssumeResultString, sal_False((sal_Bool)0) );
986#else
987 (void)_sSysPath;
988 (void)_nAssumeError;
989 (void)_sWNTAssumeResultString;
990#endif
991 }
992
993 void SystemPath_FileURL::checkUNXBehaviour_getFileURLFromSystemPath(rtl::OString const& _sSysPath, ::osl::FileBase::RC _nAssumeError, rtl::OString const& _sUnixAssumeResultString)
994 {
995#if ( defined UNX1 )
996 check_SystemPath_FileURL(_sSysPath, _nAssumeError, _sUnixAssumeResultString, sal_False((sal_Bool)0) );
997#else
998 (void)_sSysPath;
999 (void)_nAssumeError;
1000 (void)_sUnixAssumeResultString;
1001#endif
1002 }
1003
1004 /** LLA: Test for getSystemPathFromFileURL()
1005 this test is splitted into 2 different OS tests,
1006 the first function checkUNXBehaviour... runs only on Unix based Systems,
1007 the second only on windows based systems
1008 the first parameter are a file URL where we want to get the system path of,
1009 the second parameter is the assumed error of the osl_getSystemPathFromFileURL() function,
1010 the thrid parameter is the assumed result string, the string will only test, if it's length is greater 0
1011 */
1012
1013 void SystemPath_FileURL::getSystemPathFromFileURL_001_1()
1014 {
1015 rtl::OString sURL("");
1016 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1017 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1018 }
1019
1020 void SystemPath_FileURL::getSystemPathFromFileURL_001_2()
1021 {
1022 rtl::OString sURL("/");
1023 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1024 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "\\");
1025 }
1026 void SystemPath_FileURL::getSystemPathFromFileURL_001_21()
1027 {
1028 // rtl::OString sURL("%2f");
1029 rtl::OString sURL("%2F");
1030 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/"); // LLA: this is may be a BUG
1031 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1032 }
1033 void SystemPath_FileURL::getSystemPathFromFileURL_001_22()
1034 {
1035 rtl::OString sURL("file:///tmp%2Fmydir");
1036 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1037 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1038 }
1039 void SystemPath_FileURL::getSystemPathFromFileURL_001_3()
1040 {
1041 rtl::OString sURL("a");
1042 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "a");
1043 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "a");
1044 }
1045 void SystemPath_FileURL::getSystemPathFromFileURL_001_31()
1046 {
1047 rtl::OString sURL("tmpname");
1048 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "tmpname");
1049 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "tmpname");
1050 }
1051 void SystemPath_FileURL::getSystemPathFromFileURL_001_4()
1052 {
1053 rtl::OString sURL("file://");
1054 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "");
1055 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1056 }
1057 void SystemPath_FileURL::getSystemPathFromFileURL_001_41()
1058 {
1059 rtl::OString sURL("file://localhost/tmp");
1060 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "");
1061 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1062 }
1063 void SystemPath_FileURL::getSystemPathFromFileURL_001_5()
1064 {
1065 rtl::OString sURL("file:///tmp");
1066 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp");
1067 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1068 }
1069 void SystemPath_FileURL::getSystemPathFromFileURL_001_51()
1070 {
1071 rtl::OString sURL("file://c:/tmp");
1072 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:/tmp"); // LLA: this is may be a BUG
1073 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1074 }
1075 void SystemPath_FileURL::getSystemPathFromFileURL_001_52()
1076 {
1077 rtl::OString sURL("file:///c:/tmp");
1078 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp");
1079 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp");
1080 }
1081 void SystemPath_FileURL::getSystemPathFromFileURL_001_53()
1082 {
1083// LLA: is this a legal file path?
1084 rtl::OString sURL("file:///c|/tmp");
1085 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c|/tmp");
1086 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp");
1087 }
1088 void SystemPath_FileURL::getSystemPathFromFileURL_001_6()
1089 {
1090 rtl::OString sURL("file:///tmp/first");
1091 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp/first");
1092 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1093 }
1094 void SystemPath_FileURL::getSystemPathFromFileURL_001_61()
1095 {
1096 rtl::OString sURL("file:///c:/tmp/first");
1097 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp/first");
1098 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp\\first");
1099 }
1100 void SystemPath_FileURL::getSystemPathFromFileURL_001_7()
1101 {
1102 rtl::OString sURL("file:///tmp/../second");
1103 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp/../second"); // LLA: may be a BUG
1104 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1105 }
1106 void SystemPath_FileURL::getSystemPathFromFileURL_001_71()
1107 {
1108 rtl::OString sURL("file:///c:/tmp/../second");
1109 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp/../second");
1110 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp\\..\\second");
1111 }
1112 void SystemPath_FileURL::getSystemPathFromFileURL_001_8()
1113 {
1114 rtl::OString sURL("../tmp");
1115 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "../tmp");
1116 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "..\\tmp");
1117 }
1118 void SystemPath_FileURL::getSystemPathFromFileURL_001_81()
1119 {
1120 rtl::OString sURL("file://~/tmp");
1121 char* home_path;
1122 home_path = getenv("HOME");
1123 rtl::OString expResult(home_path);
1124 expResult += "/tmp";
1125 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, expResult );
1126 // checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "\\tmp");
1127 }
1128 void SystemPath_FileURL::getSystemPathFromFileURL_001_9()
1129 {
1130 rtl::OString sURL("file:///tmp/first%20second");
1131 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/tmp/first second");
1132 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1133 }
1134 void SystemPath_FileURL::getSystemPathFromFileURL_001_91()
1135 {
1136 rtl::OString sURL("file:///c:/tmp/first%20second");
1137 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "/c:/tmp/first second");
1138 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "c:\\tmp\\first second");
1139 }
1140
1141 void SystemPath_FileURL::getSystemPathFromFileURL_001_92()
1142 {
1143 rtl::OString sURL("ca@#;+.,$///78no%01ni..name");
1144 checkUNXBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_None, "");
1145 checkWNTBehaviour_getSystemPathFromFileURL(sURL, osl::FileBase::E_INVAL, "");
1146 }
1147
1148 //normal legal case
1149 void SystemPath_FileURL::getSystemPathFromFileURL_004()
1150 {
1151 ::rtl::OUString aUStr;
1152 ::rtl::OUString aUNormalURL( aTmpName6 );
1153 ::rtl::OUString aUResultURL ( aSysPath4 );
1154 ::osl::FileBase::RC nError = osl::FileBase::getSystemPathFromFileURL( aUNormalURL, aUStr );
1155
1156 sal_Bool bOk = compareFileName( aUStr, aUResultURL );
1157
1158 ::rtl::OString sError("test for getSystemPathFromFileURL(' ");
1159 sError += ::rtl::OUStringToOString( aUNormalURL, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
1160 sError += " ') function:use an absolute file URL, ";
1161 sError += outputError(::rtl::OUStringToOString( aUStr, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ),
1162 ::rtl::OUStringToOString( aUResultURL, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ));
1163
1164 CPPUNIT_ASSERT_MESSAGE(sError.getStr(), ( osl::FileBase::E_None == nError ) && ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError ) && ( sal_True == bOk )"
, sError.getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1164 ) ) )
;
1165
1166 }
1167
1168 //CJK charactors case
1169 void SystemPath_FileURL::getSystemPathFromFileURL_005()
1170 {
1171 ::rtl::OUString aUStr;
1172 createTestDirectory( aTmpName10 );
1173 ::rtl::OUString aUNormalURL( aTmpName10 );
1174 ::rtl::OUString aUResultURL ( aSysPath5 );
1175
1176 ::osl::FileBase::RC nError = osl::FileBase::getSystemPathFromFileURL( aUNormalURL, aUStr );
1177
1178 sal_Bool bOk = compareFileName( aUStr, aUResultURL );
1179
1180 ::rtl::OString sError("test for getSystemPathFromFileURL(' ");
1181 sError += ::rtl::OUStringToOString( aUNormalURL, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
1182 sError += " ') function:use a CJK coded absolute URL, ";
1183 sError += outputError(::rtl::OUStringToOString( aUStr, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ),
1184 ::rtl::OUStringToOString( aUResultURL, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) ));
1185 deleteTestDirectory( aTmpName10 );
1186
1187 CPPUNIT_ASSERT_MESSAGE( sError.getStr(), ( osl::FileBase::E_None == nError ) && ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError ) && ( sal_True == bOk )"
, sError.getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1187 ) ) )
;
1188 }
1189
1190 void SystemPath_FileURL::getFileURLFromSystemPath_001()
1191 {
1192 rtl::OString sSysPath("~/tmp");
1193 char* home_path;
1194 home_path = getenv("HOME");
1195 rtl::OString expResult(home_path);
1196 expResult = "file://"+ expResult + "/tmp";
1197 checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, expResult );
1198 checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "~/tmp");
1199 }
1200 void SystemPath_FileURL::getFileURLFromSystemPath_002()
1201 {
1202 rtl::OString sSysPath("c:/tmp");
1203 checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "c:/tmp");
1204 checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "file:///c:/tmp");
1205 }
1206 void SystemPath_FileURL::getFileURLFromSystemPath_003()
1207 {
1208 rtl::OString sSysPath("file:///temp");
1209 checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1210 checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1211 }
1212 void SystemPath_FileURL::getFileURLFromSystemPath_004()
1213 {
1214 rtl::OString sSysPath("//tmp//first start");
1215 checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_None, "file:///tmp/first%20start");
1216 checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1217 }
1218 void SystemPath_FileURL::getFileURLFromSystemPath_005()
1219 {
1220 rtl::OString sSysPath("");
1221 checkUNXBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1222 checkWNTBehaviour_getFileURLFromSystemPath(sSysPath, osl::FileBase::E_INVAL, "");
1223 }
1224 // start with "~user", not impletment
1225 // void SystemPath_FileURL::getFileURLFromSystemPath_006()
1226
1227
1228
1229
1230 //---------------------------------------------------------------------
1231 // testing the method
1232 // static inline RC searchFileURL( const ::rtl::OUString& ustrFileName,
1233 // const ::rtl::OUString& ustrSearchPath,
1234 // ::rtl::OUString& ustrFileURL )
1235 //---------------------------------------------------------------------
1236 class searchFileURL:public CppUnit::TestFixture
1237 {
1238 //::osl::FileBase aFileBase;
1239 ::rtl::OUString aUStr;
1240 ::osl::FileBase::RC nError1, nError2, nError3,nError4;
1241
1242 public:
1243
1244 // test code.
1245 void searchFileURL_001()
1246 {
1247 /* search file is passed by system filename */
1248 nError1 = ::osl::FileBase::searchFileURL( aTmpName1, aUserDirectorySys, aUStr );
1249 /* search file is passed by full qualified file URL */
1250 nError2 = ::osl::FileBase::searchFileURL( aCanURL1, aUserDirectorySys, aUStr );
1251 /* search file is passed by relative file path */
1252 nError3 = ::osl::FileBase::searchFileURL( aRelURL4, aUserDirectorySys, aUStr );
1253
1254 CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) ",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_NOENT == nError1
) && ( osl::FileBase::E_NOENT == nError2 ) &&
( osl::FileBase::E_NOENT == nError3 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_NOENT == nError1 ) && ( osl::FileBase::E_NOENT == nError2 ) && ( osl::FileBase::E_NOENT == nError3 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1257 ) ) )
1255 ( osl::FileBase::E_NOENT == nError1 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_NOENT == nError1
) && ( osl::FileBase::E_NOENT == nError2 ) &&
( osl::FileBase::E_NOENT == nError3 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_NOENT == nError1 ) && ( osl::FileBase::E_NOENT == nError2 ) && ( osl::FileBase::E_NOENT == nError3 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1257 ) ) )
1256 ( osl::FileBase::E_NOENT == nError2 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_NOENT == nError1
) && ( osl::FileBase::E_NOENT == nError2 ) &&
( osl::FileBase::E_NOENT == nError3 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_NOENT == nError1 ) && ( osl::FileBase::E_NOENT == nError2 ) && ( osl::FileBase::E_NOENT == nError3 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1257 ) ) )
1257 ( osl::FileBase::E_NOENT == nError3 ))( CppUnit::Asserter::failIf( !(( osl::FileBase::E_NOENT == nError1
) && ( osl::FileBase::E_NOENT == nError2 ) &&
( osl::FileBase::E_NOENT == nError3 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_NOENT == nError1 ) && ( osl::FileBase::E_NOENT == nError2 ) && ( osl::FileBase::E_NOENT == nError3 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched files that is not exist, but it reply invalid error, did not pass in (W32) "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1257 ) ) )
;
1258 }
1259
1260 void searchFileURL_002()
1261 {
1262 /* search file is passed by system filename */
1263 nError1 = ::osl::FileBase::searchFileURL( aTempDirectorySys, aRootSys, aUStr );
1264 sal_Bool bOk1 = compareFileName( aUStr, aTempDirectoryURL );
1265 /* search file is passed by full qualified file URL */
1266 nError2 = ::osl::FileBase::searchFileURL( aTempDirectoryURL, aRootSys, aUStr );
1267 sal_Bool bOk2 = compareFileName( aUStr, aTempDirectoryURL );
1268 /* search file is passed by relative file path */
1269 nError3 = ::osl::FileBase::searchFileURL( aRelURL5, aRootSys, aUStr );
1270 sal_Bool bOk3 = compareFileName( aUStr, aTempDirectoryURL );
1271 /* search file is passed by an exist file */
1272 createTestFile( aCanURL1 );
1273 nError4 = ::osl::FileBase::searchFileURL( aCanURL4, aUserDirectorySys, aUStr );
1274 sal_Bool bOk4 = compareFileName( aUStr, aCanURL1 );
1275 deleteTestFile( aCanURL1 );
1276
1277 CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist.",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_None == nError2 ) &&
( osl::FileBase::E_None == nError3 ) && ( osl::FileBase
::E_None == nError4 ) && ( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
) && ( ((sal_Bool)1) == bOk4 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_None == nError2 ) && ( osl::FileBase::E_None == nError3 ) && ( osl::FileBase::E_None == nError4 ) && ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) && ( sal_True == bOk4 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1285 ) ) )
1278 ( osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_None == nError2 ) &&
( osl::FileBase::E_None == nError3 ) && ( osl::FileBase
::E_None == nError4 ) && ( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
) && ( ((sal_Bool)1) == bOk4 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_None == nError2 ) && ( osl::FileBase::E_None == nError3 ) && ( osl::FileBase::E_None == nError4 ) && ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) && ( sal_True == bOk4 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1285 ) ) )
1279 ( osl::FileBase::E_None == nError2 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_None == nError2 ) &&
( osl::FileBase::E_None == nError3 ) && ( osl::FileBase
::E_None == nError4 ) && ( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
) && ( ((sal_Bool)1) == bOk4 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_None == nError2 ) && ( osl::FileBase::E_None == nError3 ) && ( osl::FileBase::E_None == nError4 ) && ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) && ( sal_True == bOk4 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1285 ) ) )
1280 ( osl::FileBase::E_None == nError3 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_None == nError2 ) &&
( osl::FileBase::E_None == nError3 ) && ( osl::FileBase
::E_None == nError4 ) && ( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
) && ( ((sal_Bool)1) == bOk4 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_None == nError2 ) && ( osl::FileBase::E_None == nError3 ) && ( osl::FileBase::E_None == nError4 ) && ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) && ( sal_True == bOk4 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1285 ) ) )
1281 ( osl::FileBase::E_None == nError4 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_None == nError2 ) &&
( osl::FileBase::E_None == nError3 ) && ( osl::FileBase
::E_None == nError4 ) && ( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
) && ( ((sal_Bool)1) == bOk4 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_None == nError2 ) && ( osl::FileBase::E_None == nError3 ) && ( osl::FileBase::E_None == nError4 ) && ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) && ( sal_True == bOk4 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1285 ) ) )
1282 ( sal_True == bOk1 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_None == nError2 ) &&
( osl::FileBase::E_None == nError3 ) && ( osl::FileBase
::E_None == nError4 ) && ( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
) && ( ((sal_Bool)1) == bOk4 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_None == nError2 ) && ( osl::FileBase::E_None == nError3 ) && ( osl::FileBase::E_None == nError4 ) && ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) && ( sal_True == bOk4 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1285 ) ) )
1283 ( sal_True == bOk2 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_None == nError2 ) &&
( osl::FileBase::E_None == nError3 ) && ( osl::FileBase
::E_None == nError4 ) && ( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
) && ( ((sal_Bool)1) == bOk4 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_None == nError2 ) && ( osl::FileBase::E_None == nError3 ) && ( osl::FileBase::E_None == nError4 ) && ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) && ( sal_True == bOk4 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1285 ) ) )
1284 ( sal_True == bOk3 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_None == nError2 ) &&
( osl::FileBase::E_None == nError3 ) && ( osl::FileBase
::E_None == nError4 ) && ( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
) && ( ((sal_Bool)1) == bOk4 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_None == nError2 ) && ( osl::FileBase::E_None == nError3 ) && ( osl::FileBase::E_None == nError4 ) && ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) && ( sal_True == bOk4 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1285 ) ) )
1285 ( sal_True == bOk4 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_None == nError2 ) &&
( osl::FileBase::E_None == nError3 ) && ( osl::FileBase
::E_None == nError4 ) && ( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
) && ( ((sal_Bool)1) == bOk4 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_None == nError2 ) && ( osl::FileBase::E_None == nError3 ) && ( osl::FileBase::E_None == nError4 ) && ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) && ( sal_True == bOk4 )"
, "test for searchFileURL function: system filename/URL filename/relative path, system directory, searched file already exist."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1285 ) ) )
;
1286 }
1287
1288
1289 void searchFileURL_003()
1290 {
1291 OSLTEST_DECLARE( SystemPathList, TEST_PLATFORM_ROOT ":" TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP ":" TEST_PLATFORM_ROOT "system/path" )::rtl::OUString aSystemPathList = rtl::OUString::createFromAscii
( ( "/" ":" "/" "tmp" ":" "/" "system/path" ) )
;
1292 nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr );
1293 sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL );
1294 CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is a list of system paths",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_True == bOk )"
, "test for searchFileURL function: search directory is a list of system paths"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1296 ) ) )
1295 ( osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_True == bOk )"
, "test for searchFileURL function: search directory is a list of system paths"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1296 ) ) )
1296 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_True == bOk )"
, "test for searchFileURL function: search directory is a list of system paths"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1296 ) ) )
;
1297 }
1298
1299 void searchFileURL_004()
1300 {
1301 OSLTEST_DECLARE( SystemPathList, TEST_PLATFORM_ROOT PATH_LIST_DELIMITER TEST_PLATFORM_ROOT TEST_PLATFORM_TEMP PATH_LIST_DELIMITER TEST_PLATFORM_ROOT "system/path/../name" )::rtl::OUString aSystemPathList = rtl::OUString::createFromAscii
( ( "/" ":" "/" "tmp" ":" "/" "system/path/../name" ) )
;
1302 nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aSystemPathList, aUStr );
1303 sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL );
1304 CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is a list of system paths",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_True == bOk )"
, "test for searchFileURL function: search directory is a list of system paths"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1306 ) ) )
1305 ( osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_True == bOk )"
, "test for searchFileURL function: search directory is a list of system paths"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1306 ) ) )
1306 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_True == bOk )"
, "test for searchFileURL function: search directory is a list of system paths"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1306 ) ) )
;
1307 }
1308
1309 void searchFileURL_005()
1310 {
1311 nError1 = ::osl::FileBase::searchFileURL( aUserDirectoryURL, aNullURL, aUStr );
1312 sal_Bool bOk = compareFileName( aUStr, aUserDirectoryURL );
1313 CPPUNIT_ASSERT_MESSAGE( "test for searchFileURL function: search directory is NULL",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_True == bOk )"
, "test for searchFileURL function: search directory is NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1315 ) ) )
1314 ( osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_True == bOk )"
, "test for searchFileURL function: search directory is NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1315 ) ) )
1315 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)1) == bOk )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_True == bOk )"
, "test for searchFileURL function: search directory is NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1315 ) ) )
;
1316 }
1317
1318 CPPUNIT_TEST_SUITE( searchFileURL )public: typedef searchFileURL TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(searchFileURL) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1319 CPPUNIT_TEST( searchFileURL_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "searchFileURL_001"), &TestFixtureType
::searchFileURL_001, context.makeFixture() ) ) )
;
1320 CPPUNIT_TEST( searchFileURL_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "searchFileURL_002"), &TestFixtureType
::searchFileURL_002, context.makeFixture() ) ) )
;
1321 CPPUNIT_TEST( searchFileURL_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "searchFileURL_003"), &TestFixtureType
::searchFileURL_003, context.makeFixture() ) ) )
;
1322 CPPUNIT_TEST( searchFileURL_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "searchFileURL_004"), &TestFixtureType
::searchFileURL_004, context.makeFixture() ) ) )
;
1323 CPPUNIT_TEST( searchFileURL_005 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "searchFileURL_005"), &TestFixtureType
::searchFileURL_005, context.makeFixture() ) ) )
;
1324 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1325 };// class searchFileURL
1326
1327
1328 //---------------------------------------------------------------------
1329 // testing the method
1330 // static inline RC getTempDirURL( ::rtl::OUString& ustrTempDirURL )
1331 //---------------------------------------------------------------------
1332 class getTempDirURL:public CppUnit::TestFixture
1333 {
1334 //::osl::FileBase aFileBase;
1335 ::rtl::OUString aUStr;
1336 ::osl::FileBase::RC nError;
1337
1338 public:
1339 // initialization
1340 void setUp()
1341 {
1342 nError = FileBase::getTempDirURL( aUStr );
1343 }
1344
1345 void tearDown()
1346 {
1347 }
1348
1349 // test code.
1350 void getTempDirURL_001()
1351 {
1352
1353 CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: excution",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_None == nError )"
, "test for getTempDirURL function: excution" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1354
) ) )
1354 ( osl::FileBase::E_None == nError ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_None == nError )"
, "test for getTempDirURL function: excution" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1354
) ) )
;
1355 }
1356
1357 void getTempDirURL_002()
1358 {
1359 CPPUNIT_ASSERT_MESSAGE( "test for getTempDirURL function: test for open and write access rights",( CppUnit::Asserter::failIf( !(checkDirectory( aUStr, osl_Check_Mode_OpenAccess
) && checkDirectory( aUStr, osl_Check_Mode_ReadAccess
) && checkDirectory( aUStr,osl_Check_Mode_WriteAccess
)), CppUnit::Message( "assertion failed", "Expression: " "checkDirectory( aUStr, osl_Check_Mode_OpenAccess ) && checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) && checkDirectory( aUStr,osl_Check_Mode_WriteAccess )"
, "test for getTempDirURL function: test for open and write access rights"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1362 ) ) )
1360 checkDirectory( aUStr, osl_Check_Mode_OpenAccess ) &&( CppUnit::Asserter::failIf( !(checkDirectory( aUStr, osl_Check_Mode_OpenAccess
) && checkDirectory( aUStr, osl_Check_Mode_ReadAccess
) && checkDirectory( aUStr,osl_Check_Mode_WriteAccess
)), CppUnit::Message( "assertion failed", "Expression: " "checkDirectory( aUStr, osl_Check_Mode_OpenAccess ) && checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) && checkDirectory( aUStr,osl_Check_Mode_WriteAccess )"
, "test for getTempDirURL function: test for open and write access rights"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1362 ) ) )
1361 checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) &&( CppUnit::Asserter::failIf( !(checkDirectory( aUStr, osl_Check_Mode_OpenAccess
) && checkDirectory( aUStr, osl_Check_Mode_ReadAccess
) && checkDirectory( aUStr,osl_Check_Mode_WriteAccess
)), CppUnit::Message( "assertion failed", "Expression: " "checkDirectory( aUStr, osl_Check_Mode_OpenAccess ) && checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) && checkDirectory( aUStr,osl_Check_Mode_WriteAccess )"
, "test for getTempDirURL function: test for open and write access rights"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1362 ) ) )
1362 checkDirectory( aUStr,osl_Check_Mode_WriteAccess ) )( CppUnit::Asserter::failIf( !(checkDirectory( aUStr, osl_Check_Mode_OpenAccess
) && checkDirectory( aUStr, osl_Check_Mode_ReadAccess
) && checkDirectory( aUStr,osl_Check_Mode_WriteAccess
)), CppUnit::Message( "assertion failed", "Expression: " "checkDirectory( aUStr, osl_Check_Mode_OpenAccess ) && checkDirectory( aUStr, osl_Check_Mode_ReadAccess ) && checkDirectory( aUStr,osl_Check_Mode_WriteAccess )"
, "test for getTempDirURL function: test for open and write access rights"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1362 ) ) )
;
1363 }
1364
1365 CPPUNIT_TEST_SUITE( getTempDirURL )public: typedef getTempDirURL TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getTempDirURL) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1366 CPPUNIT_TEST( getTempDirURL_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getTempDirURL_001"), &TestFixtureType
::getTempDirURL_001, context.makeFixture() ) ) )
;
1367 CPPUNIT_TEST( getTempDirURL_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getTempDirURL_002"), &TestFixtureType
::getTempDirURL_002, context.makeFixture() ) ) )
;
1368 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1369 };// class getTempDirURL
1370
1371
1372 //---------------------------------------------------------------------
1373 // testing the method
1374 // static inline RC createTempFile( ::rtl::OUString* pustrDirectoryURL,
1375 // oslFileHandle* pHandle,
1376 // ::rtl::OUString* pustrTempFileURL)
1377 //---------------------------------------------------------------------
1378 class createTempFile:public CppUnit::TestFixture
1379 {
1380 //::osl::FileBase aFileBase;
1381 ::osl::FileBase::RC nError1, nError2;
1382 sal_Bool bOK;
1383
1384 oslFileHandle *pHandle;
1385 ::rtl::OUString *pUStr_DirURL;
1386 ::rtl::OUString *pUStr_FileURL;
1387
1388 public:
1389
1390 // initialization
1391 void setUp()
1392 {
1393 pHandle = new oslFileHandle();
1394 pUStr_DirURL = new ::rtl::OUString( aUserDirectoryURL );
1395 pUStr_FileURL = new ::rtl::OUString();
1396 //*pUStr_DirURL = aUserDirectoryURL; /// create temp file in /tmp/PID or c:\temp\PID.*/
1397 }
1398
1399 void tearDown()
1400 {
1401 delete pUStr_DirURL;
1402 delete pUStr_FileURL;
1403 delete pHandle;
1404 }
1405
1406 // test code.
1407 void createTempFile_001()
1408 {
1409 nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL );
1410 ::osl::File testFile( *pUStr_FileURL );
1411 nError2 = testFile.open( osl_File_OpenFlag_Create0x00000004L );
1412 if ( osl::FileBase::E_EXIST == nError2 ) {
1413 osl_closeFile( *pHandle );
1414 deleteTestFile( *pUStr_FileURL );
1415 }
1416
1417 CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: create temp file and test the existence",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( pHandle != __null ) && ( osl::FileBase
::E_EXIST== nError2 )), CppUnit::Message( "assertion failed",
"Expression: " "( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST== nError2 )"
, "test for createTempFile function: create temp file and test the existence"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1418 ) ) )
1418 ( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST== nError2 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( pHandle != __null ) && ( osl::FileBase
::E_EXIST== nError2 )), CppUnit::Message( "assertion failed",
"Expression: " "( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST== nError2 )"
, "test for createTempFile function: create temp file and test the existence"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1418 ) ) )
;
1419 }
1420
1421 void createTempFile_002()
1422 {
1423 bOK = sal_False((sal_Bool)0);
1424 nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, pUStr_FileURL );
1425 ::osl::File testFile( *pUStr_FileURL );
1426 nError2 = testFile.open( osl_File_OpenFlag_Create0x00000004L );
1427
1428 CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( pHandle != __null ) && ( osl::FileBase
::E_EXIST == nError2 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST == nError2 )"
, "createTempFile function: create a temp file, but it does not exist"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1430 ) ) )
1429 ( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( pHandle != __null ) && ( osl::FileBase
::E_EXIST == nError2 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST == nError2 )"
, "createTempFile function: create a temp file, but it does not exist"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1430 ) ) )
1430 ( osl::FileBase::E_EXIST == nError2 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( pHandle != __null ) && ( osl::FileBase
::E_EXIST == nError2 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( pHandle != NULL ) && ( osl::FileBase::E_EXIST == nError2 )"
, "createTempFile function: create a temp file, but it does not exist"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1430 ) ) )
;
1431
1432 //check file if have the write permission
1433 if ( osl::FileBase::E_EXIST == nError2 ) {
1434 bOK = ifFileCanWrite( *pUStr_FileURL );
1435 osl_closeFile( *pHandle );
1436 deleteTestFile( *pUStr_FileURL );
1437 }
1438
1439 CPPUNIT_ASSERT_MESSAGE( "test for open and write access rights, in (W32), it did not have write access right, but it should be writtenable.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOK )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOK )"
, "test for open and write access rights, in (W32), it did not have write access right, but it should be writtenable."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1440 ) ) )
1440 ( sal_True == bOK ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOK )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOK )"
, "test for open and write access rights, in (W32), it did not have write access right, but it should be writtenable."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1440 ) ) )
;
1441 }
1442
1443 void createTempFile_003()
1444 {
1445 nError1 = FileBase::createTempFile( pUStr_DirURL, pHandle, 0 );
1446 //the temp file will be removed when return from createTempFile
1447 bOK = ( pHandle != NULL__null && pHandle != 0);
1448 if ( sal_True((sal_Bool)1) == bOK )
1449 osl_closeFile( *pHandle );
1450
1451 CPPUNIT_ASSERT_MESSAGE( "test for createTempFile function: set pUStrFileURL to 0 to let it remove the file after call.",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) &&( ((sal_Bool)1) == bOK )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) &&( sal_True == bOK )"
, "test for createTempFile function: set pUStrFileURL to 0 to let it remove the file after call."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1452 ) ) )
1452 ( ::osl::FileBase::E_None == nError1 ) &&( sal_True == bOK ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) &&( ((sal_Bool)1) == bOK )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) &&( sal_True == bOK )"
, "test for createTempFile function: set pUStrFileURL to 0 to let it remove the file after call."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1452 ) ) )
;
1453 }
1454 void createTempFile_004()
1455 {
1456 nError1 = FileBase::createTempFile( pUStr_DirURL, 0, pUStr_FileURL );
1457 bOK = ( pUStr_FileURL != 0);
1458 ::osl::File testFile( *pUStr_FileURL );
1459 nError2 = testFile.open( osl_File_OpenFlag_Create0x00000004L );
1460 deleteTestFile( *pUStr_FileURL );
1461 CPPUNIT_ASSERT_MESSAGE( "createTempFile function: create a temp file, but it does not exist",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_EXIST == nError2 ) &&
( ((sal_Bool)1) == bOK )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST == nError2 ) &&( sal_True == bOK )"
, "createTempFile function: create a temp file, but it does not exist"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1462 ) ) )
1462 ( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST == nError2 ) &&( sal_True == bOK ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_EXIST == nError2 ) &&
( ((sal_Bool)1) == bOK )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST == nError2 ) &&( sal_True == bOK )"
, "createTempFile function: create a temp file, but it does not exist"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1462 ) ) )
;
1463
1464 }
1465
1466 CPPUNIT_TEST_SUITE( createTempFile )public: typedef createTempFile TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(createTempFile) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1467 CPPUNIT_TEST( createTempFile_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "createTempFile_001"), &TestFixtureType
::createTempFile_001, context.makeFixture() ) ) )
;
1468 CPPUNIT_TEST( createTempFile_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "createTempFile_002"), &TestFixtureType
::createTempFile_002, context.makeFixture() ) ) )
;
1469 CPPUNIT_TEST( createTempFile_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "createTempFile_003"), &TestFixtureType
::createTempFile_003, context.makeFixture() ) ) )
;
1470 CPPUNIT_TEST( createTempFile_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "createTempFile_004"), &TestFixtureType
::createTempFile_004, context.makeFixture() ) ) )
;
1471 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1472 };// class createTempFile
1473
1474 // -----------------------------------------------------------------------------
1475 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getAbsoluteFileURL, "osl_FileBase" )static CppUnit::AutoRegisterSuite< osl_FileBase::getAbsoluteFileURL
> autoRegisterRegistry__1475("osl_FileBase")
;
1476 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::SystemPath_FileURL, "osl_FileBase" )static CppUnit::AutoRegisterSuite< osl_FileBase::SystemPath_FileURL
> autoRegisterRegistry__1476("osl_FileBase")
;
1477 // CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getFileURLFromSystemPath, "osl_FileBase" );
1478 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::searchFileURL, "osl_FileBase" )static CppUnit::AutoRegisterSuite< osl_FileBase::searchFileURL
> autoRegisterRegistry__1478("osl_FileBase")
;
1479 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::getTempDirURL, "osl_FileBase" )static CppUnit::AutoRegisterSuite< osl_FileBase::getTempDirURL
> autoRegisterRegistry__1479("osl_FileBase")
;
1480 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileBase::createTempFile, "osl_FileBase" )static CppUnit::AutoRegisterSuite< osl_FileBase::createTempFile
> autoRegisterRegistry__1480("osl_FileBase")
;
1481}// namespace osl_FileBase
1482
1483
1484//------------------------------------------------------------------------
1485// Beginning of the test cases for VolumeInfo class
1486//------------------------------------------------------------------------
1487namespace osl_VolumeInfo
1488{
1489
1490 //---------------------------------------------------------------------
1491 // testing the method
1492 // VolumeInfo( sal_uInt32 nMask ): _nMask( nMask )
1493 //---------------------------------------------------------------------
1494 class ctors : public CppUnit::TestFixture
1495 {
1496 ::rtl::OUString aUStr;
1497 ::osl::FileBase::RC nError1, nError2;
1498
1499 ::osl::VolumeDevice aVolumeDevice1;
1500
1501 public:
1502 // initialization
1503 void setUp()
1504 {
1505 }
1506
1507 void tearDown()
1508 {
1509 }
1510
1511 // test code.
1512 void ctors_001()
1513 {
1514 ::osl::VolumeInfo aVolumeInfo( 0 );
1515 nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo );
1516 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1516 ) ) )
;
1517 sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace();
1518 sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength();
1519 aUStr = aVolumeInfo.getFileSystemName();
1520
1521 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is empty",( CppUnit::Asserter::failIf( !(( 0 == uiTotalSpace ) &&
( 0 == uiMaxPathLength ) && ((sal_Bool)1) == compareFileName
( aUStr, aNullURL )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 == uiTotalSpace ) && ( 0 == uiMaxPathLength ) && sal_True == compareFileName( aUStr, aNullURL )"
, "test for ctors function: mask is empty" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1524
) ) )
1522 ( 0 == uiTotalSpace ) &&( CppUnit::Asserter::failIf( !(( 0 == uiTotalSpace ) &&
( 0 == uiMaxPathLength ) && ((sal_Bool)1) == compareFileName
( aUStr, aNullURL )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 == uiTotalSpace ) && ( 0 == uiMaxPathLength ) && sal_True == compareFileName( aUStr, aNullURL )"
, "test for ctors function: mask is empty" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1524
) ) )
1523 ( 0 == uiMaxPathLength ) &&( CppUnit::Asserter::failIf( !(( 0 == uiTotalSpace ) &&
( 0 == uiMaxPathLength ) && ((sal_Bool)1) == compareFileName
( aUStr, aNullURL )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 == uiTotalSpace ) && ( 0 == uiMaxPathLength ) && sal_True == compareFileName( aUStr, aNullURL )"
, "test for ctors function: mask is empty" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1524
) ) )
1524 sal_True == compareFileName( aUStr, aNullURL ) )( CppUnit::Asserter::failIf( !(( 0 == uiTotalSpace ) &&
( 0 == uiMaxPathLength ) && ((sal_Bool)1) == compareFileName
( aUStr, aNullURL )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 == uiTotalSpace ) && ( 0 == uiMaxPathLength ) && sal_True == compareFileName( aUStr, aNullURL )"
, "test for ctors function: mask is empty" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1524
) ) )
;
1525 }
1526
1527#if ( defined UNX1 )
1528 void ctors_002()
1529 {
1530 ::osl::VolumeInfo aVolumeInfo( osl_VolumeInfo_Mask_TotalSpace0x00000002L |
1531 osl_VolumeInfo_Mask_UsedSpace0x00000004L |
1532 osl_VolumeInfo_Mask_FileSystemName0x00000040L );
1533 nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo );
1534 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1534 ) ) )
;
1535 //CPPUNIT_ASSERT( aVolumeInfo.isValid( mask ) );
1536 sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace();
1537 sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace();
1538 aUStr = aVolumeInfo.getFileSystemName();
1539
1540 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields",( CppUnit::Asserter::failIf( !(( 0 != uiTotalSpace ) &&
( 0 != uiUsedSpace ) && ((sal_Bool)1) == compareFileName
( aUStr, "nfs" )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 != uiTotalSpace ) && ( 0 != uiUsedSpace ) && sal_True == compareFileName( aUStr, \"nfs\" )"
, "test for ctors function: mask is specified as certain valid fields, and get the masked fields"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1543 ) ) )
1541 ( 0 != uiTotalSpace ) &&( CppUnit::Asserter::failIf( !(( 0 != uiTotalSpace ) &&
( 0 != uiUsedSpace ) && ((sal_Bool)1) == compareFileName
( aUStr, "nfs" )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 != uiTotalSpace ) && ( 0 != uiUsedSpace ) && sal_True == compareFileName( aUStr, \"nfs\" )"
, "test for ctors function: mask is specified as certain valid fields, and get the masked fields"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1543 ) ) )
1542 ( 0 != uiUsedSpace ) &&( CppUnit::Asserter::failIf( !(( 0 != uiTotalSpace ) &&
( 0 != uiUsedSpace ) && ((sal_Bool)1) == compareFileName
( aUStr, "nfs" )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 != uiTotalSpace ) && ( 0 != uiUsedSpace ) && sal_True == compareFileName( aUStr, \"nfs\" )"
, "test for ctors function: mask is specified as certain valid fields, and get the masked fields"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1543 ) ) )
1543 sal_True == compareFileName( aUStr, "nfs" ) )( CppUnit::Asserter::failIf( !(( 0 != uiTotalSpace ) &&
( 0 != uiUsedSpace ) && ((sal_Bool)1) == compareFileName
( aUStr, "nfs" )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 != uiTotalSpace ) && ( 0 != uiUsedSpace ) && sal_True == compareFileName( aUStr, \"nfs\" )"
, "test for ctors function: mask is specified as certain valid fields, and get the masked fields"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1543 ) ) )
;
1544 }
1545#else /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume.
1546 void ctors_002()
1547 {
1548 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, and get the masked fields( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for ctors function: mask is specified as certain valid fields, and get the masked fields( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1549 ) ) )
1549 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for ctors function: mask is specified as certain valid fields, and get the masked fields( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1549 ) ) )
;
1550 }
1551#endif
1552
1553 void ctors_003()
1554 {
1555
1556 sal_Int32 mask1 = osl_VolumeInfo_Mask_FreeSpace0x00000008L;
1557 ::osl::VolumeInfo aVolumeInfo1( mask1 );
1558 nError1 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo1 );
1559 CPPUNIT_ASSERT( sal_True == aVolumeInfo1.isValid( mask1 ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo1.
isValid( mask1 )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo1.isValid( mask1 )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1559
) ) )
;
1560 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1560 ) ) )
;
1561
1562 sal_uInt64 uiTotalSpace1 = aVolumeInfo1.getTotalSpace();
1563 aUStr = aVolumeInfo1.getFileSystemName();
1564
1565 sal_Int32 mask2 = osl_VolumeInfo_Mask_TotalSpace0x00000002L;
1566 ::osl::VolumeInfo aVolumeInfo2( mask2 );
1567 nError2 = ::osl::Directory::getVolumeInfo( aRootURL, aVolumeInfo2 );
1568 CPPUNIT_ASSERT( sal_True == aVolumeInfo2.isValid( mask2 ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo2.
isValid( mask2 )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo2.isValid( mask2 )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1568
) ) )
;
1569 CPPUNIT_ASSERT( osl::FileBase::E_None == nError2 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError2"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1569 ) ) )
;
1570
1571 sal_uInt64 uiTotalSpace2 = aVolumeInfo2.getTotalSpace();
1572
1573 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is specified as certain valid fields, but get unmasked fields, use mask to FreeSpace, but I can get TotalSpace, did not pass in (UNX)(W32)",( CppUnit::Asserter::failIf( !(( 0 == uiTotalSpace1 ) &&
( 0 != uiTotalSpace2 ) && ((sal_Bool)1) == compareFileName
( aUStr, aNullURL )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 == uiTotalSpace1 ) && ( 0 != uiTotalSpace2 ) && sal_True == compareFileName( aUStr, aNullURL )"
, "test for ctors function: mask is specified as certain valid fields, but get unmasked fields, use mask to FreeSpace, but I can get TotalSpace, did not pass in (UNX)(W32)"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1575 ) ) )
1574 ( 0 == uiTotalSpace1 ) && ( 0 != uiTotalSpace2 ) &&( CppUnit::Asserter::failIf( !(( 0 == uiTotalSpace1 ) &&
( 0 != uiTotalSpace2 ) && ((sal_Bool)1) == compareFileName
( aUStr, aNullURL )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 == uiTotalSpace1 ) && ( 0 != uiTotalSpace2 ) && sal_True == compareFileName( aUStr, aNullURL )"
, "test for ctors function: mask is specified as certain valid fields, but get unmasked fields, use mask to FreeSpace, but I can get TotalSpace, did not pass in (UNX)(W32)"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1575 ) ) )
1575 sal_True == compareFileName( aUStr, aNullURL ) )( CppUnit::Asserter::failIf( !(( 0 == uiTotalSpace1 ) &&
( 0 != uiTotalSpace2 ) && ((sal_Bool)1) == compareFileName
( aUStr, aNullURL )), CppUnit::Message( "assertion failed", "Expression: "
"( 0 == uiTotalSpace1 ) && ( 0 != uiTotalSpace2 ) && sal_True == compareFileName( aUStr, aNullURL )"
, "test for ctors function: mask is specified as certain valid fields, but get unmasked fields, use mask to FreeSpace, but I can get TotalSpace, did not pass in (UNX)(W32)"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1575 ) ) )
;
1576 }
1577
1578 CPPUNIT_TEST_SUITE( ctors )public: typedef ctors TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(ctors) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
1579 CPPUNIT_TEST( ctors_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_001"), &TestFixtureType
::ctors_001, context.makeFixture() ) ) )
;
1580 CPPUNIT_TEST( ctors_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_002"), &TestFixtureType
::ctors_002, context.makeFixture() ) ) )
;
1581 CPPUNIT_TEST( ctors_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_003"), &TestFixtureType
::ctors_003, context.makeFixture() ) ) )
;
1582 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1583 };// class ctors
1584
1585
1586 //---------------------------------------------------------------------
1587 // testing the method
1588 // inline sal_Bool isValid( sal_uInt32 nMask ) const
1589 //---------------------------------------------------------------------
1590 class isValid : public CppUnit::TestFixture
1591 {
1592 ::osl::VolumeDevice aVolumeDevice;
1593 ::rtl::OUString aUStr;
1594 ::osl::FileBase::RC nError1;
1595
1596 public:
1597 // initialization
1598 void setUp()
1599 {
1600 }
1601
1602 void tearDown()
1603 {
1604
1605 }
1606
1607 // test code.
1608 void isValid_001()
1609 {
1610 sal_Int32 mask = 0;
1611 ::osl::VolumeInfo aVolumeInfo( mask );
1612 nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo );
1613 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1613 ) ) )
;
1614
1615 CPPUNIT_ASSERT_MESSAGE( "test for isValid function: no fields specified.",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )", "test for isValid function: no fields specified."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1616 ) ) )
1616 sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )", "test for isValid function: no fields specified."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1616 ) ) )
;
1617 }
1618
1619#if ( defined UNX1 )
1620 void isValid_002()
1621 {
1622 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L | osl_VolumeInfo_Mask_TotalSpace0x00000002L | osl_VolumeInfo_Mask_UsedSpace0x00000004L |
1623 osl_VolumeInfo_Mask_FreeSpace0x00000008L | osl_VolumeInfo_Mask_MaxNameLength0x00000010L |
1624 osl_VolumeInfo_Mask_MaxPathLength0x00000020L | osl_VolumeInfo_Mask_FileSystemName0x00000040L;
1625 ::osl::VolumeInfo aVolumeInfo( mask );
1626 nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo );
1627 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1627 ) ) )
;
1628
1629 CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )", "test for isValid function: all valid fields specified for a nfs volume."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1630 ) ) )
1630 sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )", "test for isValid function: all valid fields specified for a nfs volume."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1630 ) ) )
;
1631 }
1632#else /// Windows version,here we can not determine whichvolume in Windows is serve as an nfs volume.
1633 void isValid_002()
1634 {
1635 CPPUNIT_ASSERT_MESSAGE( "test for isValid function: all valid fields specified for a nfs volume.( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for isValid function: all valid fields specified for a nfs volume.( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1636 ) ) )
1636 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for isValid function: all valid fields specified for a nfs volume.( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1636 ) ) )
;
1637 }
1638#endif
1639
1640 void isValid_003()
1641 {
1642 ::osl::VolumeDevice aVolumeDevice1;
1643 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1644 ::osl::VolumeInfo aVolumeInfo( mask );
1645 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1646 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1646 ) ) )
;
1647 sal_Bool bOk1 = aVolumeInfo.isValid( mask );
1648
1649 nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo );
1650 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1650 ) ) )
;
1651 sal_Bool bOk2 = aVolumeInfo.isValid( mask );
1652
1653 CPPUNIT_ASSERT_MESSAGE( "test for isValid function: osl_VolumeInfo_Mask_Attributes, it should be valid for some volume such as /, floppy, cdrom, etc. but it did not pass",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 )), CppUnit::Message( "assertion failed"
, "Expression: " "( sal_True == bOk1 ) && ( sal_True == bOk2 )"
, "test for isValid function: osl_VolumeInfo_Mask_Attributes, it should be valid for some volume such as /, floppy, cdrom, etc. but it did not pass"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1654 ) ) )
1654 ( sal_True == bOk1 ) && ( sal_True == bOk2 ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 )), CppUnit::Message( "assertion failed"
, "Expression: " "( sal_True == bOk1 ) && ( sal_True == bOk2 )"
, "test for isValid function: osl_VolumeInfo_Mask_Attributes, it should be valid for some volume such as /, floppy, cdrom, etc. but it did not pass"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1654 ) ) )
;
1655 }
1656
1657 CPPUNIT_TEST_SUITE( isValid )public: typedef isValid TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(isValid) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
1658 CPPUNIT_TEST( isValid_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isValid_001"), &TestFixtureType
::isValid_001, context.makeFixture() ) ) )
;
1659 CPPUNIT_TEST( isValid_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isValid_002"), &TestFixtureType
::isValid_002, context.makeFixture() ) ) )
;
1660 CPPUNIT_TEST( isValid_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isValid_003"), &TestFixtureType
::isValid_003, context.makeFixture() ) ) )
;
1661 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1662 };// class isValid
1663
1664 //---------------------------------------------------------------------
1665 // testing the method
1666 // inline sal_Bool getRemoteFlag() const
1667 //---------------------------------------------------------------------
1668 class getRemoteFlag : public CppUnit::TestFixture
1669 {
1670 ::osl::VolumeDevice aVolumeDevice;
1671 ::rtl::OUString aUStr;
1672 ::osl::FileBase::RC nError1;
1673
1674 public:
1675 // test code.
1676 void getRemoteFlag_001()
1677 {
1678 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1679 ::osl::VolumeInfo aVolumeInfo( mask );
1680 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1681 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1681 ) ) )
;
1682 sal_Bool bOk = aVolumeInfo.getRemoteFlag();
1683
1684 CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is not remote.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getRemoteFlag function: get a volume device which is not remote."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1685 ) ) )
1685 ( sal_False == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getRemoteFlag function: get a volume device which is not remote."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1685 ) ) )
;
1686 }
1687
1688 #if ( defined UNX1 ) //remote Volume is different in Solaris and Windows
1689 void getRemoteFlag_002()
1690 {
1691 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1692 ::osl::VolumeInfo aVolumeInfo( mask );
1693 nError1 = ::osl::Directory::getVolumeInfo( aVolURL4, aVolumeInfo );
1694 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1694 ) ) )
;
1695 sal_Bool bOk = aVolumeInfo.getRemoteFlag();
1696
1697 CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Solaris version ).",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getRemoteFlag function: get a volume device which is remote( Solaris version )."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1698 ) ) )
1698 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getRemoteFlag function: get a volume device which is remote( Solaris version )."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1698 ) ) )
;
1699 }
1700#else //Windows version
1701 void getRemoteFlag_002()
1702 {
1703 CPPUNIT_ASSERT_MESSAGE( "test for getRemoteFlag function: get a volume device which is remote( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getRemoteFlag function: get a volume device which is remote( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1704 ) ) )
1704 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getRemoteFlag function: get a volume device which is remote( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1704 ) ) )
;
1705 }
1706#endif
1707
1708 CPPUNIT_TEST_SUITE( getRemoteFlag )public: typedef getRemoteFlag TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getRemoteFlag) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1709 CPPUNIT_TEST( getRemoteFlag_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getRemoteFlag_001"), &TestFixtureType
::getRemoteFlag_001, context.makeFixture() ) ) )
;
1710 CPPUNIT_TEST( getRemoteFlag_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getRemoteFlag_002"), &TestFixtureType
::getRemoteFlag_002, context.makeFixture() ) ) )
;
1711 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1712 };// class getRemoteFlag
1713
1714 //---------------------------------------------------------------------
1715 // testing the method
1716 // inline sal_Bool getRemoveableFlag() const
1717 //---------------------------------------------------------------------
1718 class getRemoveableFlag : public CppUnit::TestFixture
1719 {
1720 ::osl::FileBase::RC nError1;
1721
1722 public:
1723 // test code.
1724 void getRemoveableFlag_001()
1725 {
1726 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1727 ::osl::VolumeInfo aVolumeInfo( mask );
1728 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1729 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1729 ) ) )
;
1730 sal_Bool bOk = aVolumeInfo.getRemoveableFlag();
1731
1732 CPPUNIT_ASSERT_MESSAGE( "test for getRemoveableFlag function: get a volume device which is not removable.",( CppUnit::Asserter::failIf( !(((sal_Bool)0) == bOk), CppUnit
::Message( "assertion failed", "Expression: " "sal_False == bOk"
, "test for getRemoveableFlag function: get a volume device which is not removable."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1733 ) ) )
1733 sal_False == bOk )( CppUnit::Asserter::failIf( !(((sal_Bool)0) == bOk), CppUnit
::Message( "assertion failed", "Expression: " "sal_False == bOk"
, "test for getRemoveableFlag function: get a volume device which is not removable."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1733 ) ) )
;
1734 }
1735
1736 void getRemoveableFlag_002()
1737 {
1738 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1739 ::osl::VolumeInfo aVolumeInfo( mask );
1740 nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo );
1741 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1741 ) ) )
;
1742 sal_Bool bOk = aVolumeInfo.getRemoveableFlag();
1743
1744 CPPUNIT_ASSERT_MESSAGE( "test for getRemoveableFlag function: get a volume device which is removable, not sure, here we use floppy disk, but it did not pass.",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == bOk), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == bOk"
, "test for getRemoveableFlag function: get a volume device which is removable, not sure, here we use floppy disk, but it did not pass."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1745 ) ) )
1745 sal_True == bOk )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == bOk), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == bOk"
, "test for getRemoveableFlag function: get a volume device which is removable, not sure, here we use floppy disk, but it did not pass."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1745 ) ) )
;
1746 }
1747 CPPUNIT_TEST_SUITE( getRemoveableFlag )public: typedef getRemoveableFlag TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getRemoveableFlag) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1748 CPPUNIT_TEST( getRemoveableFlag_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getRemoveableFlag_001"), &
TestFixtureType::getRemoveableFlag_001, context.makeFixture()
) ) )
;
1749 CPPUNIT_TEST( getRemoveableFlag_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getRemoveableFlag_002"), &
TestFixtureType::getRemoveableFlag_002, context.makeFixture()
) ) )
;
1750 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1751 };// class getRemoveableFlag
1752
1753
1754 //---------------------------------------------------------------------
1755 // testing the method
1756 // inline sal_Bool getCompactDiscFlag() const
1757 //---------------------------------------------------------------------
1758 class getCompactDiscFlag : public CppUnit::TestFixture
1759 {
1760 ::osl::FileBase::RC nError1;
1761
1762 public:
1763 // test code.
1764 void getCompactDiscFlag_001()
1765 {
1766 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1767 ::osl::VolumeInfo aVolumeInfo( mask );
1768 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1769 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1769 ) ) )
;
1770 sal_Bool bOk = aVolumeInfo.getCompactDiscFlag();
1771
1772 CPPUNIT_ASSERT_MESSAGE( "test for getCompactDiscFlag function: get a volume device which is not a cdrom.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getCompactDiscFlag function: get a volume device which is not a cdrom."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1773 ) ) )
1773 ( sal_False == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getCompactDiscFlag function: get a volume device which is not a cdrom."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1773 ) ) )
;
1774 }
1775
1776 void getCompactDiscFlag_002()
1777 {
1778 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1779 ::osl::VolumeInfo aVolumeInfo( mask );
1780 nError1 = ::osl::Directory::getVolumeInfo( aVolURL6, aVolumeInfo );
1781 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1781 ) ) )
;
1782 sal_Bool bOk = aVolumeInfo.getCompactDiscFlag();
1783
1784 CPPUNIT_ASSERT_MESSAGE( "test for getCompactDiscFlag function: get a cdrom volume device flag, it did not pass.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getCompactDiscFlag function: get a cdrom volume device flag, it did not pass."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1785 ) ) )
1785 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getCompactDiscFlag function: get a cdrom volume device flag, it did not pass."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1785 ) ) )
;
1786 }
1787 CPPUNIT_TEST_SUITE( getCompactDiscFlag )public: typedef getCompactDiscFlag TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getCompactDiscFlag) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1788 CPPUNIT_TEST( getCompactDiscFlag_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getCompactDiscFlag_001"), &
TestFixtureType::getCompactDiscFlag_001, context.makeFixture(
) ) ) )
;
1789 CPPUNIT_TEST( getCompactDiscFlag_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getCompactDiscFlag_002"), &
TestFixtureType::getCompactDiscFlag_002, context.makeFixture(
) ) ) )
;
1790 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1791 };// class getCompactDiscFlag
1792
1793
1794 //---------------------------------------------------------------------
1795 // testing the method
1796 // inline sal_Bool getFloppyDiskFlag() const
1797 //---------------------------------------------------------------------
1798 class getFloppyDiskFlag : public CppUnit::TestFixture
1799 {
1800 ::osl::FileBase::RC nError1;
1801
1802 public:
1803 // test code.
1804 void getFloppyDiskFlag_001()
1805 {
1806 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1807 ::osl::VolumeInfo aVolumeInfo( mask );
1808 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1809 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1809 ) ) )
;
1810 sal_Bool bOk = aVolumeInfo.getFloppyDiskFlag();
1811
1812 CPPUNIT_ASSERT_MESSAGE( "test for getFloppyDiskFlag function: get a volume device which is not a floppy disk.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getFloppyDiskFlag function: get a volume device which is not a floppy disk."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1813 ) ) )
1813 ( sal_False == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getFloppyDiskFlag function: get a volume device which is not a floppy disk."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1813 ) ) )
;
1814 }
1815
1816 void getFloppyDiskFlag_002()
1817 {
1818 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1819 ::osl::VolumeInfo aVolumeInfo( mask );
1820 nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo );
1821 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1821 ) ) )
;
1822 sal_Bool bOk = aVolumeInfo.getFloppyDiskFlag();
1823
1824 CPPUNIT_ASSERT_MESSAGE( "test for getFloppyDiskFlag function: get a floppy volume device flag, it did not pass.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getFloppyDiskFlag function: get a floppy volume device flag, it did not pass."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1825 ) ) )
1825 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getFloppyDiskFlag function: get a floppy volume device flag, it did not pass."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1825 ) ) )
;
1826 }
1827 CPPUNIT_TEST_SUITE( getFloppyDiskFlag )public: typedef getFloppyDiskFlag TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getFloppyDiskFlag) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1828 CPPUNIT_TEST( getFloppyDiskFlag_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFloppyDiskFlag_001"), &
TestFixtureType::getFloppyDiskFlag_001, context.makeFixture()
) ) )
;
1829 CPPUNIT_TEST( getFloppyDiskFlag_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFloppyDiskFlag_002"), &
TestFixtureType::getFloppyDiskFlag_002, context.makeFixture()
) ) )
;
1830 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1831 };// class getFloppyDiskFlag
1832
1833
1834 //---------------------------------------------------------------------
1835 // testing the method
1836 // inline sal_Bool getFixedDiskFlag() const
1837 //---------------------------------------------------------------------
1838 class getFixedDiskFlag : public CppUnit::TestFixture
1839 {
1840 ::osl::FileBase::RC nError1;
1841
1842 public:
1843 // test code.
1844 void getFixedDiskFlag_001()
1845 {
1846 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1847 ::osl::VolumeInfo aVolumeInfo( mask );
1848 nError1 = ::osl::Directory::getVolumeInfo( aVolURL2, aVolumeInfo );
1849 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1849 ) ) )
;
1850 sal_Bool bOk = aVolumeInfo.getFixedDiskFlag();
1851
1852 CPPUNIT_ASSERT_MESSAGE( "test for getFixedDiskFlag function: get a volume device which is not a fixed disk.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getFixedDiskFlag function: get a volume device which is not a fixed disk."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1853 ) ) )
1853 ( sal_False == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getFixedDiskFlag function: get a volume device which is not a fixed disk."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1853 ) ) )
;
1854 }
1855
1856 void getFixedDiskFlag_002()
1857 {
1858 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1859 ::osl::VolumeInfo aVolumeInfo( mask );
1860 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1861 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1861 ) ) )
;
1862 sal_Bool bOk = aVolumeInfo.getFixedDiskFlag();
1863
1864 CPPUNIT_ASSERT_MESSAGE( "test for getFixedDiskFlag function: get a fixed disk volume device flag, it did not pass.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getFixedDiskFlag function: get a fixed disk volume device flag, it did not pass."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1865 ) ) )
1865 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getFixedDiskFlag function: get a fixed disk volume device flag, it did not pass."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1865 ) ) )
;
1866 }
1867 CPPUNIT_TEST_SUITE( getFixedDiskFlag )public: typedef getFixedDiskFlag TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getFixedDiskFlag) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1868 CPPUNIT_TEST( getFixedDiskFlag_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFixedDiskFlag_001"), &TestFixtureType
::getFixedDiskFlag_001, context.makeFixture() ) ) )
;
1869 CPPUNIT_TEST( getFixedDiskFlag_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFixedDiskFlag_002"), &TestFixtureType
::getFixedDiskFlag_002, context.makeFixture() ) ) )
;
1870 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1871 };// class getFixedDiskFlag
1872
1873 //---------------------------------------------------------------------
1874 // testing the method
1875 // inline sal_Bool getRAMDiskFlag() const
1876 //---------------------------------------------------------------------
1877 class getRAMDiskFlag : public CppUnit::TestFixture
1878 {
1879 ::osl::FileBase::RC nError1;
1880
1881 public:
1882 // test code.
1883 void getRAMDiskFlag_001()
1884 {
1885 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1886 ::osl::VolumeInfo aVolumeInfo( mask );
1887 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1888 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1888 ) ) )
;
1889 sal_Bool bOk = aVolumeInfo.getRAMDiskFlag();
1890
1891 CPPUNIT_ASSERT_MESSAGE( "test for getRAMDiskFlag function: get a volume device which is not a RAM disk.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getRAMDiskFlag function: get a volume device which is not a RAM disk."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1892 ) ) )
1892 ( sal_False == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getRAMDiskFlag function: get a volume device which is not a RAM disk."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1892 ) ) )
;
1893 }
1894
1895 void getRAMDiskFlag_002()
1896 {
1897 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
1898 ::osl::VolumeInfo aVolumeInfo( mask );
1899 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1900 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1900 ) ) )
;
1901 sal_Bool bOk = aVolumeInfo.getRAMDiskFlag();
1902
1903 CPPUNIT_ASSERT_MESSAGE( "test for getRAMDiskFlag function: FIX ME, don't know how to get a RAM disk flag, perhaps Windows 98 boot disk can create a RAM disk, it did not pass in (UNX)(W32).",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getRAMDiskFlag function: FIX ME, don't know how to get a RAM disk flag, perhaps Windows 98 boot disk can create a RAM disk, it did not pass in (UNX)(W32)."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1904 ) ) )
1904 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for getRAMDiskFlag function: FIX ME, don't know how to get a RAM disk flag, perhaps Windows 98 boot disk can create a RAM disk, it did not pass in (UNX)(W32)."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1904 ) ) )
;
1905 }
1906 CPPUNIT_TEST_SUITE( getRAMDiskFlag )public: typedef getRAMDiskFlag TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getRAMDiskFlag) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1907 CPPUNIT_TEST( getRAMDiskFlag_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getRAMDiskFlag_001"), &TestFixtureType
::getRAMDiskFlag_001, context.makeFixture() ) ) )
;
1908 CPPUNIT_TEST( getRAMDiskFlag_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getRAMDiskFlag_002"), &TestFixtureType
::getRAMDiskFlag_002, context.makeFixture() ) ) )
;
1909 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1910 };// class getRAMDiskFlag
1911
1912
1913 //---------------------------------------------------------------------
1914 // testing the method
1915 // inline sal_uInt64 getTotalSpace() const
1916 //---------------------------------------------------------------------
1917 class getTotalSpace : public CppUnit::TestFixture
1918 {
1919 ::osl::FileBase::RC nError1;
1920
1921 public:
1922 // test code.
1923 void getTotalSpace_001()
1924 {
1925 sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace0x00000002L;
1926 ::osl::VolumeInfo aVolumeInfo( mask );
1927 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1928 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1928 ) ) )
;
1929 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1929
) ) )
;
1930 sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace();
1931
1932 CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space of Fixed disk volume mounted on /, it should not be 0",( CppUnit::Asserter::failIf( !(0 != uiTotalSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 != uiTotalSpace", "test for getTotalSpace function: get total space of Fixed disk volume mounted on /, it should not be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1933 ) ) )
1933 0 != uiTotalSpace )( CppUnit::Asserter::failIf( !(0 != uiTotalSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 != uiTotalSpace", "test for getTotalSpace function: get total space of Fixed disk volume mounted on /, it should not be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1933 ) ) )
;
1934 }
1935
1936 #if defined( UNX1 )
1937 void getTotalSpace_002()
1938 {
1939 sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace0x00000002L;
1940 ::osl::VolumeInfo aVolumeInfo( mask );
1941 nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo );
1942 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1942 ) ) )
;
1943 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1943
) ) )
;
1944 sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace();
1945
1946 CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space of /proc, it should be 0",( CppUnit::Asserter::failIf( !(0 == uiTotalSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 == uiTotalSpace", "test for getTotalSpace function: get total space of /proc, it should be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1947 ) ) )
1947 0 == uiTotalSpace )( CppUnit::Asserter::failIf( !(0 == uiTotalSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 == uiTotalSpace", "test for getTotalSpace function: get total space of /proc, it should be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1947 ) ) )
;
1948 }
1949#else /// Windows version, in Windows, there is no /proc directory
1950 void getTotalSpace_002()
1951 {
1952 CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function:not applicable for /proc( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getTotalSpace function:not applicable for /proc( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1953 ) ) )
1953 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getTotalSpace function:not applicable for /proc( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1953 ) ) )
;
1954 }
1955#endif
1956
1957
1958
1959#if defined(SOLARIS)
1960 void getTotalSpace_003()
1961 {
1962 struct statvfs aStatFS;
1963 static const sal_Char name[] = "/";
1964
1965 memset (&aStatFS, 0, sizeof(aStatFS));
1966 statvfs( name, &aStatFS);
1967 sal_uInt64 TotalSpace = aStatFS.f_frsize * aStatFS.f_blocks ;
1968
1969 sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace0x00000002L;
1970 ::osl::VolumeInfo aVolumeInfo( mask );
1971 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
1972 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1972 ) ) )
;
1973 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 1973
) ) )
;
1974 sal_uInt64 uiTotalSpace = aVolumeInfo.getTotalSpace();
1975
1976 CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function: get total space by hand, then compare with getTotalSpace, it did not pass",( CppUnit::Asserter::failIf( !(uiTotalSpace == TotalSpace), CppUnit
::Message( "assertion failed", "Expression: " "uiTotalSpace == TotalSpace"
, "test for getTotalSpace function: get total space by hand, then compare with getTotalSpace, it did not pass"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1977 ) ) )
1977 uiTotalSpace == TotalSpace )( CppUnit::Asserter::failIf( !(uiTotalSpace == TotalSpace), CppUnit
::Message( "assertion failed", "Expression: " "uiTotalSpace == TotalSpace"
, "test for getTotalSpace function: get total space by hand, then compare with getTotalSpace, it did not pass"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1977 ) ) )
;
1978 }
1979#else /// Windows version
1980 void getTotalSpace_003()
1981 {
1982 CPPUNIT_ASSERT_MESSAGE( "test for getTotalSpace function:not implemented yet( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getTotalSpace function:not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1983 ) ) )
1983 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getTotalSpace function:not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 1983 ) ) )
;
1984 }
1985#endif
1986
1987 CPPUNIT_TEST_SUITE( getTotalSpace )public: typedef getTotalSpace TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getTotalSpace) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
1988 CPPUNIT_TEST( getTotalSpace_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getTotalSpace_001"), &TestFixtureType
::getTotalSpace_001, context.makeFixture() ) ) )
;
1989 CPPUNIT_TEST( getTotalSpace_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getTotalSpace_002"), &TestFixtureType
::getTotalSpace_002, context.makeFixture() ) ) )
;
1990 CPPUNIT_TEST( getTotalSpace_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getTotalSpace_003"), &TestFixtureType
::getTotalSpace_003, context.makeFixture() ) ) )
;
1991 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
1992 };// class getTotalSpace
1993
1994 //---------------------------------------------------------------------
1995 // testing the method
1996 // inline sal_uInt64 getFreeSpace() const
1997 //---------------------------------------------------------------------
1998 class getFreeSpace : public CppUnit::TestFixture
1999 {
2000 ::osl::FileBase::RC nError1;
2001
2002 public:
2003 // test code.
2004 void getFreeSpace_001()
2005 {
2006 sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace0x00000008L;
2007 ::osl::VolumeInfo aVolumeInfo( mask );
2008 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2009 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2009 ) ) )
;
2010 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2010
) ) )
;
2011 sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace();
2012
2013 CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the free space may be 0",( CppUnit::Asserter::failIf( !(0 != uiFreeSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 != uiFreeSpace", "test for getFreeSpace function: get free space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the free space may be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2014 ) ) )
2014 0 != uiFreeSpace )( CppUnit::Asserter::failIf( !(0 != uiFreeSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 != uiFreeSpace", "test for getFreeSpace function: get free space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the free space may be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2014 ) ) )
;
2015 }
2016
2017#if defined( UNX1 )
2018 void getFreeSpace_002()
2019 {
2020 sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace0x00000008L;
2021 ::osl::VolumeInfo aVolumeInfo( mask );
2022 nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo );
2023 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2023 ) ) )
;
2024 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2024
) ) )
;
2025 sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace();
2026
2027 CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space of /proc, it should be 0",( CppUnit::Asserter::failIf( !(0 == uiFreeSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 == uiFreeSpace", "test for getFreeSpace function: get free space of /proc, it should be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2028 ) ) )
2028 0 == uiFreeSpace )( CppUnit::Asserter::failIf( !(0 == uiFreeSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 == uiFreeSpace", "test for getFreeSpace function: get free space of /proc, it should be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2028 ) ) )
;
2029 }
2030#else /// Windows version, in Windows, there is no /proc directory
2031 void getFreeSpace_002()
2032 {
2033 CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: not applicable for /proc( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getFreeSpace function: not applicable for /proc( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2034 ) ) )
2034 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getFreeSpace function: not applicable for /proc( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2034 ) ) )
;
2035 }
2036#endif
2037
2038
2039#if defined(SOLARIS)
2040 void getFreeSpace_003()
2041 {
2042 struct statvfs aStatFS;
2043 static const sal_Char name[] = "/";
2044
2045 memset (&aStatFS, 0, sizeof(aStatFS));
2046 statvfs( name, &aStatFS);
2047 sal_uInt64 FreeSpace = aStatFS.f_bfree * aStatFS.f_frsize ;
2048
2049 sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace0x00000008L;
2050 ::osl::VolumeInfo aVolumeInfo( mask );
2051 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2052 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2052 ) ) )
;
2053 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2053
) ) )
;
2054 sal_uInt64 uiFreeSpace = aVolumeInfo.getFreeSpace();
2055
2056 CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: get free space by hand, then compare with getFreeSpace, it did not pass",( CppUnit::Asserter::failIf( !(uiFreeSpace == FreeSpace), CppUnit
::Message( "assertion failed", "Expression: " "uiFreeSpace == FreeSpace"
, "test for getFreeSpace function: get free space by hand, then compare with getFreeSpace, it did not pass"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2057 ) ) )
2057 uiFreeSpace == FreeSpace )( CppUnit::Asserter::failIf( !(uiFreeSpace == FreeSpace), CppUnit
::Message( "assertion failed", "Expression: " "uiFreeSpace == FreeSpace"
, "test for getFreeSpace function: get free space by hand, then compare with getFreeSpace, it did not pass"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2057 ) ) )
;
2058 }
2059#else //Windows version
2060 void getFreeSpace_003()
2061 {
2062 CPPUNIT_ASSERT_MESSAGE( "test for getFreeSpace function: not implemented yet( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getFreeSpace function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2063 ) ) )
2063 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getFreeSpace function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2063 ) ) )
;
2064 }
2065#endif
2066
2067
2068 CPPUNIT_TEST_SUITE( getFreeSpace )public: typedef getFreeSpace TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getFreeSpace) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
2069 CPPUNIT_TEST( getFreeSpace_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFreeSpace_001"), &TestFixtureType
::getFreeSpace_001, context.makeFixture() ) ) )
;
2070 CPPUNIT_TEST( getFreeSpace_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFreeSpace_002"), &TestFixtureType
::getFreeSpace_002, context.makeFixture() ) ) )
;
2071 CPPUNIT_TEST( getFreeSpace_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFreeSpace_003"), &TestFixtureType
::getFreeSpace_003, context.makeFixture() ) ) )
;
2072 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2073 };// class getFreeSpace
2074
2075 //---------------------------------------------------------------------
2076 // testing the method
2077 // inline sal_uInt64 getUsedSpace() const
2078 //---------------------------------------------------------------------
2079 class getUsedSpace : public CppUnit::TestFixture
2080 {
2081 ::osl::FileBase::RC nError1;
2082
2083 public:
2084 // test code.
2085 void getUsedSpace_001()
2086 {
2087 sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace0x00000004L;
2088 ::osl::VolumeInfo aVolumeInfo( mask );
2089 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2090 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2090 ) ) )
;
2091 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2091
) ) )
;
2092 sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace();
2093
2094 CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the used space may be 0",( CppUnit::Asserter::failIf( !(0 != uiUsedSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 != uiUsedSpace", "test for getUsedSpace function: get used space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the used space may be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2095 ) ) )
2095 0 != uiUsedSpace )( CppUnit::Asserter::failIf( !(0 != uiUsedSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 != uiUsedSpace", "test for getUsedSpace function: get used space of Fixed disk volume mounted on /, it should not be 0, suggestion: returned value, -1 is better, since some times the used space may be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2095 ) ) )
;
2096 }
2097
2098#if defined( UNX1 )
2099 void getUsedSpace_002()
2100 {
2101 sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace0x00000004L;
2102 ::osl::VolumeInfo aVolumeInfo( mask );
2103 nError1 = ::osl::Directory::getVolumeInfo( aVolURL3, aVolumeInfo );
2104 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2104 ) ) )
;
2105 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2105
) ) )
;
2106 sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace();
2107
2108 CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space of /proc, it should be 0",( CppUnit::Asserter::failIf( !(0 == uiUsedSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 == uiUsedSpace", "test for getUsedSpace function: get used space of /proc, it should be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2109 ) ) )
2109 0 == uiUsedSpace )( CppUnit::Asserter::failIf( !(0 == uiUsedSpace), CppUnit::Message
( "assertion failed", "Expression: " "0 == uiUsedSpace", "test for getUsedSpace function: get used space of /proc, it should be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2109 ) ) )
;
2110 }
2111#else /// Windows version, in Windows, there is no /proc directory
2112 void getUsedSpace_002()
2113 {
2114 CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: not applicable for /proc( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getUsedSpace function: not applicable for /proc( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2115 ) ) )
2115 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getUsedSpace function: not applicable for /proc( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2115 ) ) )
;
2116 }
2117#endif
2118
2119
2120#if defined(SOLARIS)
2121 void getUsedSpace_003()
2122 {
2123 struct statvfs aStatFS;
2124 static const sal_Char name[] = "/";
2125
2126 memset (&aStatFS, 0, sizeof(aStatFS));
2127 statvfs( name, &aStatFS);
2128 sal_uInt64 UsedSpace = ( aStatFS.f_blocks - aStatFS.f_bavail ) * aStatFS.f_frsize;
2129
2130
2131 sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace0x00000004L;
2132 ::osl::VolumeInfo aVolumeInfo( mask );
2133 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2134 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2134 ) ) )
;
2135 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2135
) ) )
;
2136 sal_uInt64 uiUsedSpace = aVolumeInfo.getUsedSpace();
2137
2138 CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: get used space by hand, then compare with getUsedSpace, it did not pass",( CppUnit::Asserter::failIf( !(uiUsedSpace == UsedSpace), CppUnit
::Message( "assertion failed", "Expression: " "uiUsedSpace == UsedSpace"
, "test for getUsedSpace function: get used space by hand, then compare with getUsedSpace, it did not pass"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2139 ) ) )
2139 uiUsedSpace == UsedSpace )( CppUnit::Asserter::failIf( !(uiUsedSpace == UsedSpace), CppUnit
::Message( "assertion failed", "Expression: " "uiUsedSpace == UsedSpace"
, "test for getUsedSpace function: get used space by hand, then compare with getUsedSpace, it did not pass"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2139 ) ) )
;
2140 }
2141#else //Windows version
2142 void getUsedSpace_003()
2143 {
2144 CPPUNIT_ASSERT_MESSAGE( "test for getUsedSpace function: not implemented yet( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getUsedSpace function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2145 ) ) )
2145 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getUsedSpace function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2145 ) ) )
;
2146 }
2147#endif
2148
2149
2150 CPPUNIT_TEST_SUITE( getUsedSpace )public: typedef getUsedSpace TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getUsedSpace) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
2151 CPPUNIT_TEST( getUsedSpace_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getUsedSpace_001"), &TestFixtureType
::getUsedSpace_001, context.makeFixture() ) ) )
;
2152 CPPUNIT_TEST( getUsedSpace_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getUsedSpace_002"), &TestFixtureType
::getUsedSpace_002, context.makeFixture() ) ) )
;
2153 CPPUNIT_TEST( getUsedSpace_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getUsedSpace_003"), &TestFixtureType
::getUsedSpace_003, context.makeFixture() ) ) )
;
2154 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2155 };// class getUsedSpace
2156
2157
2158 //---------------------------------------------------------------------
2159 // testing the method
2160 // inline sal_uInt32 getMaxNameLength() const
2161 //---------------------------------------------------------------------
2162 class getMaxNameLength : public CppUnit::TestFixture
2163 {
2164 ::osl::FileBase::RC nError1;
2165
2166 public:
2167 // test code.
2168 void getMaxNameLength_001()
2169 {
2170 sal_Int32 mask = osl_VolumeInfo_Mask_MaxNameLength0x00000010L;
2171 ::osl::VolumeInfo aVolumeInfo( mask );
2172 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2173 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2173 ) ) )
;
2174 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2174
) ) )
;
2175 sal_uInt32 uiMaxNameLength = aVolumeInfo.getMaxNameLength();
2176
2177 CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: get max name length of Fixed disk volume mounted on /, it should not be 0",( CppUnit::Asserter::failIf( !(0 != uiMaxNameLength), CppUnit
::Message( "assertion failed", "Expression: " "0 != uiMaxNameLength"
, "test for getMaxNameLength function: get max name length of Fixed disk volume mounted on /, it should not be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2178 ) ) )
2178 0 != uiMaxNameLength )( CppUnit::Asserter::failIf( !(0 != uiMaxNameLength), CppUnit
::Message( "assertion failed", "Expression: " "0 != uiMaxNameLength"
, "test for getMaxNameLength function: get max name length of Fixed disk volume mounted on /, it should not be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2178 ) ) )
;
2179 }
2180
2181
2182#if defined(UNX1) && !defined(ANDROID)
2183 void getMaxNameLength_002()
2184 {
2185 struct statvfs aStatFS;
2186 static const sal_Char name[] = "/";
2187
2188 memset (&aStatFS, 0, sizeof(aStatFS));
2189 statvfs( name, &aStatFS);
2190 sal_uInt64 MaxNameLength = aStatFS.f_namemax;
2191
2192 sal_Int32 mask = osl_VolumeInfo_Mask_MaxNameLength0x00000010L;
2193 ::osl::VolumeInfo aVolumeInfo( mask );
2194 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2195 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2195 ) ) )
;
2196 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2196
) ) )
;
2197 sal_uInt64 uiMaxNameLength = aVolumeInfo.getMaxNameLength();
2198
2199 CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: get max name length by hand, then compare with getMaxNameLength",( CppUnit::Asserter::failIf( !(uiMaxNameLength == MaxNameLength
), CppUnit::Message( "assertion failed", "Expression: " "uiMaxNameLength == MaxNameLength"
, "test for getMaxNameLength function: get max name length by hand, then compare with getMaxNameLength"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2200 ) ) )
2200 uiMaxNameLength == MaxNameLength )( CppUnit::Asserter::failIf( !(uiMaxNameLength == MaxNameLength
), CppUnit::Message( "assertion failed", "Expression: " "uiMaxNameLength == MaxNameLength"
, "test for getMaxNameLength function: get max name length by hand, then compare with getMaxNameLength"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2200 ) ) )
;
2201 }
2202#else //Windows version
2203 void getMaxNameLength_002()
2204 {
2205 CPPUNIT_ASSERT_MESSAGE( "test for getMaxNameLength function: not implemented yet( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getMaxNameLength function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2206 ) ) )
2206 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getMaxNameLength function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2206 ) ) )
;
2207 }
2208#endif
2209
2210 CPPUNIT_TEST_SUITE( getMaxNameLength )public: typedef getMaxNameLength TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getMaxNameLength) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
2211 CPPUNIT_TEST( getMaxNameLength_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getMaxNameLength_001"), &TestFixtureType
::getMaxNameLength_001, context.makeFixture() ) ) )
;
2212 CPPUNIT_TEST( getMaxNameLength_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getMaxNameLength_002"), &TestFixtureType
::getMaxNameLength_002, context.makeFixture() ) ) )
;
2213 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2214 };// class getMaxNameLength
2215
2216
2217 //---------------------------------------------------------------------
2218 // testing the method
2219 // inline sal_uInt32 getMaxPathLength() const
2220 //---------------------------------------------------------------------
2221 class getMaxPathLength : public CppUnit::TestFixture
2222 {
2223 ::osl::FileBase::RC nError1;
2224
2225 public:
2226 // test code.
2227 void getMaxPathLength_001()
2228 {
2229 sal_Int32 mask = osl_VolumeInfo_Mask_MaxPathLength0x00000020L;
2230 ::osl::VolumeInfo aVolumeInfo( mask );
2231 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2232 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2232 ) ) )
;
2233 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2233
) ) )
;
2234 sal_uInt32 uiMaxPathLength = aVolumeInfo.getMaxPathLength();
2235
2236 CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: get max path length of Fixed disk volume mounted on /, it should not be 0",( CppUnit::Asserter::failIf( !(0 != uiMaxPathLength), CppUnit
::Message( "assertion failed", "Expression: " "0 != uiMaxPathLength"
, "test for getMaxPathLength function: get max path length of Fixed disk volume mounted on /, it should not be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2237 ) ) )
2237 0 != uiMaxPathLength )( CppUnit::Asserter::failIf( !(0 != uiMaxPathLength), CppUnit
::Message( "assertion failed", "Expression: " "0 != uiMaxPathLength"
, "test for getMaxPathLength function: get max path length of Fixed disk volume mounted on /, it should not be 0"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2237 ) ) )
;
2238 }
2239
2240
2241#if ( defined UNX1 )
2242 void getMaxPathLength_002()
2243 {
2244 sal_Int32 mask = osl_VolumeInfo_Mask_MaxPathLength0x00000020L;
2245 ::osl::VolumeInfo aVolumeInfo( mask );
2246 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2247 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2247 ) ) )
;
2248 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2248
) ) )
;
2249 sal_uInt64 uiMaxPathLength = aVolumeInfo.getMaxPathLength();
2250
2251 CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: get max path length by hand, then compare with getMaxPathLength",( CppUnit::Asserter::failIf( !(uiMaxPathLength == 4096), CppUnit
::Message( "assertion failed", "Expression: " "uiMaxPathLength == PATH_MAX"
, "test for getMaxPathLength function: get max path length by hand, then compare with getMaxPathLength"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2252 ) ) )
2252 uiMaxPathLength == PATH_MAX )( CppUnit::Asserter::failIf( !(uiMaxPathLength == 4096), CppUnit
::Message( "assertion failed", "Expression: " "uiMaxPathLength == PATH_MAX"
, "test for getMaxPathLength function: get max path length by hand, then compare with getMaxPathLength"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2252 ) ) )
;
2253 }
2254#else //Windows version
2255 void getMaxPathLength_002()
2256 {
2257 CPPUNIT_ASSERT_MESSAGE( "test for getMaxPathLength function: not implemented yet( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getMaxPathLength function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2258 ) ) )
2258 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getMaxPathLength function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2258 ) ) )
;
2259 }
2260#endif
2261
2262
2263 CPPUNIT_TEST_SUITE( getMaxPathLength )public: typedef getMaxPathLength TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getMaxPathLength) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
2264 CPPUNIT_TEST( getMaxPathLength_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getMaxPathLength_001"), &TestFixtureType
::getMaxPathLength_001, context.makeFixture() ) ) )
;
2265 CPPUNIT_TEST( getMaxPathLength_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getMaxPathLength_002"), &TestFixtureType
::getMaxPathLength_002, context.makeFixture() ) ) )
;
2266 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2267 };// class getMaxPathLength
2268
2269
2270 //---------------------------------------------------------------------
2271 // testing the method
2272 // inline ::rtl::OUString getFileSystemName() const
2273 //---------------------------------------------------------------------
2274 class getFileSystemName : public CppUnit::TestFixture
2275 {
2276 ::rtl::OUString aUStr;
2277 ::osl::FileBase::RC nError1;
2278
2279 public:
2280 // test code.
2281 void getFileSystemName_001()
2282 {
2283 sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemName0x00000040L;
2284 ::osl::VolumeInfo aVolumeInfo( mask );
2285 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2286 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2286 ) ) )
;
2287 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2287
) ) )
;
2288 aUStr = aVolumeInfo.getFileSystemName();
2289
2290 CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: get file system name of Fixed disk volume mounted on /, it should not be empty string",( CppUnit::Asserter::failIf( !(((sal_Bool)0) == compareFileName
( aNullURL, aUStr )), CppUnit::Message( "assertion failed", "Expression: "
"sal_False == compareFileName( aNullURL, aUStr )", "test for getFileSystemName function: get file system name of Fixed disk volume mounted on /, it should not be empty string"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2291 ) ) )
2291 sal_False == compareFileName( aNullURL, aUStr ) )( CppUnit::Asserter::failIf( !(((sal_Bool)0) == compareFileName
( aNullURL, aUStr )), CppUnit::Message( "assertion failed", "Expression: "
"sal_False == compareFileName( aNullURL, aUStr )", "test for getFileSystemName function: get file system name of Fixed disk volume mounted on /, it should not be empty string"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2291 ) ) )
;
2292 }
2293
2294
2295#if defined(SOLARIS)
2296 void getFileSystemName_002()
2297 {
2298 struct statvfs aStatFS;
2299 static const sal_Char name[] = "/";
2300
2301 memset (&aStatFS, 0, sizeof(aStatFS));
2302 statvfs( name, &aStatFS);
2303 sal_Char * astrFileSystemName = aStatFS.f_basetype;
2304
2305 sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemName0x00000040L;
2306 ::osl::VolumeInfo aVolumeInfo( mask );
2307 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2308 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2308 ) ) )
;
2309 CPPUNIT_ASSERT( sal_True == aVolumeInfo.isValid( mask ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == aVolumeInfo.isValid
( mask )), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == aVolumeInfo.isValid( mask )"), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 2309
) ) )
;
2310 aUStr = aVolumeInfo.getFileSystemName();
2311
2312 CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: get file system name by hand, then compare with getFileSystemName",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aUStr, astrFileSystemName )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == compareFileName( aUStr, astrFileSystemName )"
, "test for getFileSystemName function: get file system name by hand, then compare with getFileSystemName"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2313 ) ) )
2313 sal_True == compareFileName( aUStr, astrFileSystemName ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aUStr, astrFileSystemName )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == compareFileName( aUStr, astrFileSystemName )"
, "test for getFileSystemName function: get file system name by hand, then compare with getFileSystemName"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2313 ) ) )
;
2314 }
2315#else //Windows version
2316 void getFileSystemName_002()
2317 {
2318 CPPUNIT_ASSERT_MESSAGE( "test for getFileSystemName function: not implemented yet( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getFileSystemName function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2319 ) ) )
2319 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getFileSystemName function: not implemented yet( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2319 ) ) )
;
2320 }
2321#endif
2322
2323
2324 CPPUNIT_TEST_SUITE( getFileSystemName )public: typedef getFileSystemName TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getFileSystemName) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
2325 CPPUNIT_TEST( getFileSystemName_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileSystemName_001"), &
TestFixtureType::getFileSystemName_001, context.makeFixture()
) ) )
;
2326 CPPUNIT_TEST( getFileSystemName_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileSystemName_002"), &
TestFixtureType::getFileSystemName_002, context.makeFixture()
) ) )
;
2327 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2328 };// class getFileSystemName
2329
2330 //---------------------------------------------------------------------
2331 // testing the method
2332 // inline VolumeDevice getDeviceHandle() const
2333 //---------------------------------------------------------------------
2334 class getDeviceHandle : public CppUnit::TestFixture
2335 {
2336 ::rtl::OUString aUStr;
2337 ::osl::FileBase::RC nError1;
2338
2339 public:
2340 // test code.
2341 void getDeviceHandle_001()
2342 {
2343 ::osl::VolumeInfo aVolumeInfo( osl_VolumeInfo_Mask_Attributes0x00000001L );
2344 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
2345 CPPUNIT_ASSERT( osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2345 ) ) )
;
2346
2347 ::osl::VolumeDevice aVolumeDevice1( aVolumeInfo.getDeviceHandle() );
2348 sal_Bool bOk = compareFileName( aNullURL, aVolumeDevice1.getMountPath() );
2349
2350 CPPUNIT_ASSERT_MESSAGE( "test for getDeviceHandle function: get device handle of Fixed disk volume mounted on /, it should not be NULL, it did not pass in (W32) (UNX).",( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getDeviceHandle function: get device handle of Fixed disk volume mounted on /, it should not be NULL, it did not pass in (W32) (UNX)."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2351 ) ) )
2351 ( sal_False == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)0) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_False == bOk )"
, "test for getDeviceHandle function: get device handle of Fixed disk volume mounted on /, it should not be NULL, it did not pass in (W32) (UNX)."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2351 ) ) )
;
2352 }
2353
2354 CPPUNIT_TEST_SUITE( getDeviceHandle )public: typedef getDeviceHandle TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getDeviceHandle) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
2355 CPPUNIT_TEST( getDeviceHandle_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getDeviceHandle_001"), &TestFixtureType
::getDeviceHandle_001, context.makeFixture() ) ) )
;
2356 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2357 };// class getDeviceHandle
2358
2359
2360 // -----------------------------------------------------------------------------
2361 /*CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::ctors, "osl_VolumeInfo" );
2362 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::isValid, "osl_VolumeInfo" );
2363 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRemoteFlag, "osl_VolumeInfo" );
2364 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRemoveableFlag, "osl_VolumeInfo" );
2365 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getCompactDiscFlag, "osl_VolumeInfo" );
2366 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFloppyDiskFlag, "osl_VolumeInfo" );
2367 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFixedDiskFlag, "osl_VolumeInfo" );
2368 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getRAMDiskFlag, "osl_VolumeInfo" );
2369 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getTotalSpace, "osl_VolumeInfo" );
2370 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFreeSpace, "osl_VolumeInfo" );
2371 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getUsedSpace, "osl_VolumeInfo" );
2372 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getMaxNameLength, "osl_VolumeInfo" );
2373 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getMaxPathLength, "osl_VolumeInfo" );
2374 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getFileSystemName, "osl_VolumeInfo" );
2375 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_VolumeInfo::getDeviceHandle, "osl_VolumeInfo" );*/
2376}// namespace osl_VolumeInfo
2377
2378
2379
2380//------------------------------------------------------------------------
2381// Beginning of the test cases for VolumeDevice class
2382//------------------------------------------------------------------------
2383namespace osl_FileStatus
2384{
2385
2386 //---------------------------------------------------------------------
2387 // testing the method
2388 // FileStatus( sal_uInt32 nMask ): _nMask( nMask )
2389 //---------------------------------------------------------------------
2390 class ctors : public CppUnit::TestFixture
2391 {
2392 ::rtl::OUString aUStr;
2393 ::osl::FileBase::RC nError1;
2394 ::osl::DirectoryItem rItem;
2395
2396 public:
2397 // initialization
2398 void setUp()
2399 {
2400 // create a tempfile in $TEMP/tmpdir/tmpname.
2401 createTestDirectory( aTmpName3 );
2402 createTestFile( aTmpName4 );
2403
2404 ::std::auto_ptr<Directory> pDir( new Directory( aTmpName3 ) );
2405 nError1 = pDir->open();
2406 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2406 ) ) )
;
2407 nError1 = pDir->getNextItem( rItem, 0 );
2408 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2408 ) ) )
;
2409 pDir->close();
2410 /*
2411 Directory aDir( aTmpName3 );
2412 nError1 = aDir.open();
2413 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2414 nError1 = aDir.getNextItem( rItem, 0 );
2415 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
2416 aDir.close();
2417 */
2418 }
2419
2420 void tearDown()
2421 {
2422 // remove the tempfile in $TEMP/tmpdir/tmpname.
2423 deleteTestFile( aTmpName4 );
2424 deleteTestDirectory( aTmpName3 );
2425 }
2426
2427 // test code.
2428 void ctors_001()
2429 {
2430 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_All0x7FFFFFFF );
2431 nError1 = rItem.getFileStatus( rFileStatus );
2432 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2432 ) ) )
;
2433 aUStr = rFileStatus.getFileName();
2434
2435 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask all and see the file name",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aUStr, aTmpName2)), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == compareFileName( aUStr, aTmpName2)", "test for ctors function: mask all and see the file name"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2436 ) ) )
2436 sal_True == compareFileName( aUStr, aTmpName2) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aUStr, aTmpName2)), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == compareFileName( aUStr, aTmpName2)", "test for ctors function: mask all and see the file name"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2436 ) ) )
;
2437 }
2438
2439 void ctors_002()
2440 {
2441 ::osl::FileStatus rFileStatus( 0 );
2442 nError1 = rItem.getFileStatus( rFileStatus );
2443 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2443 ) ) )
;
2444 aUStr = rFileStatus.getFileName();
2445
2446 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: mask is empty",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aUStr, aNullURL)), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == compareFileName( aUStr, aNullURL)", "test for ctors function: mask is empty"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2447 ) ) )
2447 sal_True == compareFileName( aUStr, aNullURL) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aUStr, aNullURL)), CppUnit::Message( "assertion failed", "Expression: "
"sal_True == compareFileName( aUStr, aNullURL)", "test for ctors function: mask is empty"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2447 ) ) )
;
2448 }
2449
2450 CPPUNIT_TEST_SUITE( ctors )public: typedef ctors TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(ctors) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
2451 CPPUNIT_TEST( ctors_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_001"), &TestFixtureType
::ctors_001, context.makeFixture() ) ) )
;
2452 CPPUNIT_TEST( ctors_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_002"), &TestFixtureType
::ctors_002, context.makeFixture() ) ) )
;
2453 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2454 };// class ctors
2455
2456
2457 //---------------------------------------------------------------------
2458 // testing the method
2459 // inline sal_Bool isValid( sal_uInt32 nMask ) const
2460 //---------------------------------------------------------------------
2461 class isValid : public CppUnit::TestFixture
2462 {
2463 ::rtl::OUString aUStr;
2464 ::osl::Directory *pDir;
2465 ::osl::DirectoryItem rItem_file, rItem_link;
2466
2467 public:
2468 // initialization
2469 void setUp()
2470 {
2471 // create a tempfile in $TEMP/tmpdir/tmpname.
2472 createTestDirectory( aTmpName3 );
2473 createTestFile( aTmpName4 );
2474
2475 pDir = new Directory( aTmpName3 );
2476 //::std::auto_ptr<Directory> pDir( new Directory( aTmpName3 ) );
2477 ::osl::FileBase::RC nError1 = pDir->open();
2478 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2478 ) ) )
;
2479 nError1 = pDir->getNextItem( rItem_file, 1 );
2480 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2480 ) ) )
;
2481 }
2482
2483 void tearDown()
2484 {
2485 ::osl::FileBase::RC nError1 = pDir->close();
2486 delete pDir;
2487 CPPUNIT_ASSERT_MESSAGE( errorToStr(nError1).getStr(), ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, errorToStr(nError1).getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2487 ) ) )
;
2488
2489 // remove the tempfile in $TEMP/tmpdir/tmpname.
2490 deleteTestFile( aTmpName4 );
2491 deleteTestDirectory( aTmpName3 );
2492 }
2493
2494 // test code.
2495 void isValid_001()
2496 {
2497 sal_uInt32 mask = 0;
2498 ::osl::FileStatus rFileStatus( mask );
2499 ::osl::FileBase::RC nError1 = rItem_file.getFileStatus( rFileStatus );
2500 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2500 ) ) )
;
2501 sal_Bool bOk = rFileStatus.isValid( mask );
2502
2503 CPPUNIT_ASSERT_MESSAGE( "test for isValid function: no fields specified",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for isValid function: no fields specified" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2504 ) ) )
2504 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for isValid function: no fields specified" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2504 ) ) )
;
2505 }
2506
2507 void check_FileStatus(::osl::FileStatus const& _aStatus)
2508 {
2509 rtl::OString sStat;
2510 if (_aStatus.isValid(osl_FileStatus_Mask_Type0x00000001))
2511 {
2512 sStat += "type ";
2513 }
2514 if (_aStatus.isValid(osl_FileStatus_Mask_Attributes0x00000002))
2515 {
2516 sStat += "attributes ";
2517 }
2518 if (_aStatus.isValid(osl_FileStatus_Mask_CreationTime0x00000010))
2519 {
2520 sStat += "ctime ";
2521 }
2522 if (_aStatus.isValid(osl_FileStatus_Mask_AccessTime0x00000020))
2523 {
2524 sStat += "atime ";
2525 }
2526 if (_aStatus.isValid(osl_FileStatus_Mask_ModifyTime0x00000040))
2527 {
2528 sStat += "mtime ";
2529 }
2530 if (_aStatus.isValid(osl_FileStatus_Mask_FileSize0x00000080))
2531 {
2532 sStat += "filesize ";
2533 }
2534 if (_aStatus.isValid(osl_FileStatus_Mask_FileName0x00000100))
2535 {
2536 sStat += "filename ";
2537 }
2538 if (_aStatus.isValid(osl_FileStatus_Mask_FileURL0x00000200))
2539 {
2540 sStat += "fileurl ";
2541 }
2542 printf("mask: %s\n", sStat.getStr());
2543 }
2544
2545 void isValid_002()
2546 {
2547 createTestFile( aTmpName6 );
2548 sal_uInt32 mask_file = ( osl_FileStatus_Mask_Type0x00000001 | osl_FileStatus_Mask_Attributes0x00000002 |
2549 osl_FileStatus_Mask_CreationTime0x00000010 | osl_FileStatus_Mask_AccessTime0x00000020 |
2550 osl_FileStatus_Mask_ModifyTime0x00000040 | osl_FileStatus_Mask_FileSize0x00000080 |
2551 osl_FileStatus_Mask_FileName0x00000100 | osl_FileStatus_Mask_FileURL0x00000200) ;
2552 ::osl::FileStatus rFileStatus( mask_file );
2553 ::osl::FileBase::RC nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem_file );
2554 nError1 = rItem_file.getFileStatus( rFileStatus );
2555
2556 CPPUNIT_ASSERT_MESSAGE( errorToStr(nError1).getStr(), ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, errorToStr(nError1).getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2556 ) ) )
;
2557
2558// LLA: this is wrong, we never should try to check on all masks
2559// only on one.
2560// Second, it's not a bug, if a value is not valid, it's an unhandled feature.
2561
2562// sal_Bool bOk = rFileStatus.isValid( mask_file );
2563
2564 check_FileStatus(rFileStatus);
2565 deleteTestFile( aTmpName6 );
2566
2567 // CPPUNIT_ASSERT_MESSAGE( "test for isValid function: regular file mask fields test, #osl_FileStatus_Mask_CreationTime# should be valid field for regular file, but feedback is invalid",
2568 // ( sal_True == bOk ) );
2569 }
2570
2571 //Link is not defined in Windows, and on Linux, we can not get the directory item of the link file
2572 // LLA: we have to differ to filesystems, normal filesystems support links (EXT2, ...)
2573 // castrated filesystems don't (FAT, FAT32)
2574 // Windows NT NTFS support links, but the windows api don't :-(
2575
2576 void isValid_003()
2577 {
2578#if defined ( UNX1 )
2579 // ::osl::FileBase::RC nError;
2580 sal_Int32 fd;
2581
2582 ::rtl::OUString aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys );
2583 ( ( aUStr_LnkFileSys += aSlashURL ) += getCurrentPID() ) += ::rtl::OUString("/tmpdir/link.file");
2584 ( ( aUStr_SrcFileSys += aSlashURL ) += getCurrentPID() ) += ::rtl::OUString("/tmpdir/tmpname");
2585
2586 rtl::OString strLinkFileName;
2587 rtl::OString strSrcFileName;
2588 strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
2589 strSrcFileName = OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
2590
2591 //create a link file and link it to file "/tmp/PID/tmpdir/tmpname"
2592 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() );
2593 CPPUNIT_ASSERT( fd == 0 )( CppUnit::Asserter::failIf( !(fd == 0), CppUnit::Message( "assertion failed"
, "Expression: " "fd == 0"), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2593 ) ) )
;
2594
2595 // testDirectory is "/tmp/PID/tmpdir/"
2596 ::osl::Directory testDirectory( aTmpName3 );
2597 ::osl::FileBase::RC nError1 = testDirectory.open();
2598 ::rtl::OUString aFileName ("link.file");
2599 sal_Bool bOk = sal_False((sal_Bool)0);
2600 while (1) {
2601 nError1 = testDirectory.getNextItem( rItem_link, 4 );
2602 if (::osl::FileBase::E_None == nError1) {
2603 sal_uInt32 mask_link = osl_FileStatus_Mask_FileName0x00000100 | osl_FileStatus_Mask_LinkTargetURL0x00000400;
2604 ::osl::FileStatus rFileStatus( mask_link );
2605 rItem_link.getFileStatus( rFileStatus );
2606 if ( compareFileName( rFileStatus.getFileName(), aFileName) == sal_True((sal_Bool)1) )
2607 {
2608 //printf("find the link file");
2609 if ( sal_True((sal_Bool)1) == rFileStatus.isValid( osl_FileStatus_Mask_LinkTargetURL0x00000400 ) )
2610 {
2611 bOk = sal_True((sal_Bool)1);
2612 break;
2613 }
2614 }
2615 }
2616 else
2617 break;
2618 };
2619
2620 fd = remove( strLinkFileName.getStr() );
2621 CPPUNIT_ASSERT( fd == 0 )( CppUnit::Asserter::failIf( !(fd == 0), CppUnit::Message( "assertion failed"
, "Expression: " "fd == 0"), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2621 ) ) )
;
2622
2623 CPPUNIT_ASSERT_MESSAGE("test for isValid function: link file, check for LinkTargetURL",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for isValid function: link file, check for LinkTargetURL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2624 ) ) )
2624 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for isValid function: link file, check for LinkTargetURL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2624 ) ) )
;
2625#endif
2626 }
2627
2628 void isValid_004()
2629 {
2630 sal_uInt32 mask_file_all = osl_FileStatus_Mask_All0x7FFFFFFF;
2631 ::osl::FileStatus rFileStatus_all( mask_file_all );
2632 ::osl::FileBase::RC nError1 = rItem_file.getFileStatus( rFileStatus_all );
2633 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2633 ) ) )
;
2634
2635 check_FileStatus(rFileStatus_all);
2636// LLA: this is wrong
2637// sal_Bool bOk1 = rFileStatus_all.isValid( mask_file_all );
2638
2639 sal_uInt32 mask_file_val = osl_FileStatus_Mask_Validate0x80000000;
2640 ::osl::FileStatus rFileStatus_val( mask_file_val );
2641 nError1 = rItem_file.getFileStatus( rFileStatus_val );
2642 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2642 ) ) )
;
2643 // sal_Bool bOk2 = rFileStatus_val.isValid( mask_file_val );
2644
2645 check_FileStatus(rFileStatus_val);
2646 // CPPUNIT_ASSERT_MESSAGE( "test for isValid function: check for Mask_All and Validate, really not sure what validate used for and how to use it, help me. did not pass (W32)(UNX).",
2647 // ( sal_False == bOk1 ) && ( sal_True == bOk2 ) );
2648 }
2649
2650
2651 CPPUNIT_TEST_SUITE( isValid )public: typedef isValid TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(isValid) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
2652 CPPUNIT_TEST( isValid_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isValid_001"), &TestFixtureType
::isValid_001, context.makeFixture() ) ) )
;
2653 CPPUNIT_TEST( isValid_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isValid_002"), &TestFixtureType
::isValid_002, context.makeFixture() ) ) )
;
2654 CPPUNIT_TEST( isValid_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isValid_003"), &TestFixtureType
::isValid_003, context.makeFixture() ) ) )
;
2655 CPPUNIT_TEST( isValid_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isValid_004"), &TestFixtureType
::isValid_004, context.makeFixture() ) ) )
;
2656 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2657 };// class ctors
2658
2659
2660 //---------------------------------------------------------------------
2661 // testing the method
2662 // inline Type getFileType() const
2663 //---------------------------------------------------------------------
2664 class getFileType : public CppUnit::TestFixture
2665 {
2666 ::rtl::OUString aUStr;
2667 ::osl::FileBase::RC nError1;
2668
2669 ::osl::DirectoryItem m_aItem_1, m_aItem_2, m_aVolumeItem, m_aFifoItem;
2670 ::osl::DirectoryItem m_aLinkItem, m_aSocketItem, m_aSpecialItem;
2671
2672 public:
2673 // initialization
2674 void setUp()
2675 {
2676 // create a tempfile: $TEMP/tmpdir/tmpname.
2677 // a tempdirectory: $TEMP/tmpdir/tmpdir.
2678 // use $ROOT/staroffice as volume ---> use dev/fd as volume.
2679 // and get their directory item.
2680 createTestDirectory( aTmpName3 );
2681 createTestFile( aTmpName3, aTmpName2 );
2682 createTestDirectory( aTmpName3, aTmpName1 );
2683
2684 boost::scoped_ptr<Directory> pDir( new Directory( aTmpName3 ) );
2685 nError1 = pDir->open();
2686 CPPUNIT_ASSERT_MESSAGE("open aTmpName3 failed!", ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "open aTmpName3 failed!" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2686 ) ) )
;
2687 //getNextItem can not assure which item retrieved
2688 nError1 = pDir->getNextItem( m_aItem_1, 1 );
2689 CPPUNIT_ASSERT_MESSAGE("get first item failed!", ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "get first item failed!" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2689 ) ) )
;
2690
2691 nError1 = pDir->getNextItem( m_aItem_2 );
2692 CPPUNIT_ASSERT_MESSAGE("get second item failed!", ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "get second item failed!" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2692 ) ) )
;
2693 pDir->close();
2694 //mindy: failed on my RH9,so removed temporaly
2695 //nError1 = ::osl::DirectoryItem::get( aVolURL2, m_aVolumeItem );
2696 //CPPUNIT_ASSERT_MESSAGE("get volume item failed!", ::osl::FileBase::E_None == nError1 );
2697
2698 }
2699
2700 void tearDown()
2701 {
2702 // remove all in $TEMP/tmpdir.
2703 deleteTestDirectory( aTmpName3, aTmpName1 );
2704 deleteTestFile( aTmpName3, aTmpName2 );
2705 deleteTestDirectory( aTmpName3 );
2706 }
2707
2708 // test code.
2709 void getFileType_001()
2710 {
2711 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Type0x00000001 | osl_FileStatus_Mask_FileName0x00000100 );
2712 nError1 = m_aItem_1.getFileStatus( rFileStatus );
2713 CPPUNIT_ASSERT_MESSAGE("getFileStatus failed", ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "getFileStatus failed" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2713 ) ) )
;
2714
2715 check_FileType(rFileStatus);
2716 }
2717
2718 void check_FileType(osl::FileStatus const& _rFileStatus )
2719 {
2720 sal_Bool bOK = sal_False((sal_Bool)0);
2721 if ( _rFileStatus.isValid(osl_FileStatus_Mask_FileName0x00000100))
2722 {
2723 rtl::OUString suFilename = _rFileStatus.getFileName();
2724
2725 if ( _rFileStatus.isValid(osl_FileStatus_Mask_Type0x00000001))
2726 {
2727 osl::FileStatus::Type eType = _rFileStatus.getFileType();
2728
2729 if ( compareFileName( suFilename, aTmpName2) == sal_True((sal_Bool)1) )
2730 {
2731 // regular
2732 bOK = ( eType == osl::FileStatus::Regular );
2733 }
2734 if ( compareFileName( suFilename, aTmpName1) == sal_True((sal_Bool)1) )
2735 {
2736 // directory
2737 bOK = ( eType == ::osl::FileStatus::Directory );
2738 }
2739
2740 CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: ",( CppUnit::Asserter::failIf( !(( bOK == ((sal_Bool)1) )), CppUnit
::Message( "assertion failed", "Expression: " "( bOK == sal_True )"
, "test for getFileType function: " ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2741 ) ) )
2741 ( bOK == sal_True ) )( CppUnit::Asserter::failIf( !(( bOK == ((sal_Bool)1) )), CppUnit
::Message( "assertion failed", "Expression: " "( bOK == sal_True )"
, "test for getFileType function: " ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2741 ) ) )
;
2742 }
2743 }
2744 // LLA: it's not a bug, if a FileStatus not exist, so no else
2745 }
2746
2747 void getFileType_002()
2748 {
2749 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Type0x00000001 | osl_FileStatus_Mask_FileName0x00000100 );
2750 nError1 = m_aItem_2.getFileStatus( rFileStatus );
2751
2752 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2752 ) ) )
;
2753 check_FileType(rFileStatus);
2754 }
2755
2756 void getFileType_003()
2757 {
2758 }
2759
2760 void getFileType_007()
2761 {
2762#if defined ( SOLARIS ) //Special file is differ in Windows
2763 nError1 = ::osl::DirectoryItem::get( aTypeURL2, m_aSpecialItem );
2764 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2764 ) ) )
;
2765
2766 //check for File type
2767 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Type0x00000001 );
2768 nError1 = m_aSpecialItem.getFileStatus( rFileStatus );
2769 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2769 ) ) )
;
2770
2771 if (rFileStatus.isValid(osl_FileStatus_Mask_Type0x00000001))
2772 {
2773 osl::FileStatus::Type eType = rFileStatus.getFileType();
2774
2775
2776 CPPUNIT_ASSERT_MESSAGE( "test for getFileType function: Special, Solaris version ",( CppUnit::Asserter::failIf( !(( eType == ::osl::FileStatus::
Special )), CppUnit::Message( "assertion failed", "Expression: "
"( eType == ::osl::FileStatus::Special )", "test for getFileType function: Special, Solaris version "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2777 ) ) )
2777 ( eType == ::osl::FileStatus::Special ) )( CppUnit::Asserter::failIf( !(( eType == ::osl::FileStatus::
Special )), CppUnit::Message( "assertion failed", "Expression: "
"( eType == ::osl::FileStatus::Special )", "test for getFileType function: Special, Solaris version "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2777 ) ) )
;
2778 }
2779#endif
2780 }
2781
2782 CPPUNIT_TEST_SUITE( getFileType )public: typedef getFileType TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(getFileType) ); return testNamer; } public
: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
2783 CPPUNIT_TEST( getFileType_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileType_001"), &TestFixtureType
::getFileType_001, context.makeFixture() ) ) )
;
2784 CPPUNIT_TEST( getFileType_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileType_002"), &TestFixtureType
::getFileType_002, context.makeFixture() ) ) )
;
2785 CPPUNIT_TEST( getFileType_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileType_003"), &TestFixtureType
::getFileType_003, context.makeFixture() ) ) )
;
2786 CPPUNIT_TEST( getFileType_007 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileType_007"), &TestFixtureType
::getFileType_007, context.makeFixture() ) ) )
;
2787 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2788 };// class getFileType
2789
2790 //---------------------------------------------------------------------
2791 // testing the method
2792 // inline sal_uInt64 getAttributes() const
2793 //---------------------------------------------------------------------
2794 class getAttributes : public CppUnit::TestFixture
2795 {
2796 ::rtl::OUString aTypeURL, aTypeURL_Hid;
2797 ::osl::FileBase::RC nError;
2798 ::osl::DirectoryItem rItem, rItem_hidden;
2799
2800 public:
2801 // initialization
2802 void setUp()
2803 {
2804 aTypeURL = aUserDirectoryURL.copy( 0 );
2805 concatURL( aTypeURL, aTmpName2 );
2806 createTestFile( aTypeURL );
2807 nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
2808 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2808 ) ) )
;
2809
2810 aTypeURL_Hid = aUserDirectoryURL.copy( 0 );
2811 concatURL( aTypeURL_Hid, aHidURL1 );
2812 createTestFile( aTypeURL_Hid );
2813 nError = ::osl::DirectoryItem::get( aTypeURL_Hid, rItem_hidden );
2814 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2814 ) ) )
;
2815 }
2816
2817 void tearDown()
2818 {
2819 deleteTestFile( aTypeURL );
2820 deleteTestFile( aTypeURL_Hid );
2821 }
2822
2823 // test code.
2824#if ( defined UNX1 )
2825//windows only 3 file attributes: normal, readonly, hidden
2826 void getAttributes_001()
2827 {
2828 changeFileMode( aTypeURL, S_IRUSR0400 | S_IRGRP(0400 >> 3) | S_IROTH((0400 >> 3) >> 3) );
2829
2830 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Attributes0x00000002 );
2831 nError = rItem.getFileStatus( rFileStatus );
2832 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2832 ) ) )
;
2833
2834 CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead( UNX version ) ",( CppUnit::Asserter::failIf( !(( 0x00000001 | 0x00000040 | 0x00000200
| 0x00001000 ) == rFileStatus.getAttributes()), CppUnit::Message
( "assertion failed", "Expression: " "( osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead ) == rFileStatus.getAttributes()"
, "test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead( UNX version ) "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2836 ) ) )
2835 ( osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead ) ==( CppUnit::Asserter::failIf( !(( 0x00000001 | 0x00000040 | 0x00000200
| 0x00001000 ) == rFileStatus.getAttributes()), CppUnit::Message
( "assertion failed", "Expression: " "( osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead ) == rFileStatus.getAttributes()"
, "test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead( UNX version ) "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2836 ) ) )
2836 rFileStatus.getAttributes() )( CppUnit::Asserter::failIf( !(( 0x00000001 | 0x00000040 | 0x00000200
| 0x00001000 ) == rFileStatus.getAttributes()), CppUnit::Message
( "assertion failed", "Expression: " "( osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead ) == rFileStatus.getAttributes()"
, "test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead( UNX version ) "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2836 ) ) )
;
2837 }
2838#else //Windows version
2839 void getAttributes_001()
2840 {
2841 CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2842 ) ) )
2842 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getAttributes function: ReadOnly, GrpRead, OwnRead, OthRead( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2842 ) ) )
;
2843 }
2844#endif
2845
2846
2847 void getAttributes_002()
2848 {
2849#if ( defined UNX1 )
2850 changeFileMode( aTypeURL, S_IXUSR0100 | S_IXGRP(0100 >> 3) | S_IXOTH((0100 >> 3) >> 3) );
2851
2852 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Attributes0x00000002 );
2853 nError = rItem.getFileStatus( rFileStatus );
2854 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2854 ) ) )
;
2855
2856 CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: Executable, GrpExe, OwnExe, OthExe, the result is Readonly, Executable, GrpExe, OwnExe, OthExe, it partly not pass( Solaris version )",( CppUnit::Asserter::failIf( !(( 0x00000001 | 0x00000010 | 0x00000080
| 0x00000400 | 0x00002000 ) == rFileStatus.getAttributes()),
CppUnit::Message( "assertion failed", "Expression: " "( osl_File_Attribute_ReadOnly | osl_File_Attribute_Executable | osl_File_Attribute_GrpExe | osl_File_Attribute_OwnExe | osl_File_Attribute_OthExe ) == rFileStatus.getAttributes()"
, "test for getAttributes function: Executable, GrpExe, OwnExe, OthExe, the result is Readonly, Executable, GrpExe, OwnExe, OthExe, it partly not pass( Solaris version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2858 ) ) )
2857 ( osl_File_Attribute_ReadOnly | osl_File_Attribute_Executable | osl_File_Attribute_GrpExe | osl_File_Attribute_OwnExe | osl_File_Attribute_OthExe ) ==( CppUnit::Asserter::failIf( !(( 0x00000001 | 0x00000010 | 0x00000080
| 0x00000400 | 0x00002000 ) == rFileStatus.getAttributes()),
CppUnit::Message( "assertion failed", "Expression: " "( osl_File_Attribute_ReadOnly | osl_File_Attribute_Executable | osl_File_Attribute_GrpExe | osl_File_Attribute_OwnExe | osl_File_Attribute_OthExe ) == rFileStatus.getAttributes()"
, "test for getAttributes function: Executable, GrpExe, OwnExe, OthExe, the result is Readonly, Executable, GrpExe, OwnExe, OthExe, it partly not pass( Solaris version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2858 ) ) )
2858 rFileStatus.getAttributes() )( CppUnit::Asserter::failIf( !(( 0x00000001 | 0x00000010 | 0x00000080
| 0x00000400 | 0x00002000 ) == rFileStatus.getAttributes()),
CppUnit::Message( "assertion failed", "Expression: " "( osl_File_Attribute_ReadOnly | osl_File_Attribute_Executable | osl_File_Attribute_GrpExe | osl_File_Attribute_OwnExe | osl_File_Attribute_OthExe ) == rFileStatus.getAttributes()"
, "test for getAttributes function: Executable, GrpExe, OwnExe, OthExe, the result is Readonly, Executable, GrpExe, OwnExe, OthExe, it partly not pass( Solaris version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2858 ) ) )
;
2859#endif
2860 }
2861
2862
2863#if ( defined UNX1 )
2864 void getAttributes_003()
2865 {
2866 changeFileMode( aTypeURL, S_IWUSR0200 | S_IWGRP(0200 >> 3) | S_IWOTH((0200 >> 3) >> 3) );
2867
2868 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Attributes0x00000002 );
2869 nError = rItem.getFileStatus( rFileStatus );
2870 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2870 ) ) )
;
2871
2872 CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: GrpWrite, OwnWrite, OthWrite( Solaris version )",( CppUnit::Asserter::failIf( !(( 0x00000020 | 0x00000100 | 0x00000800
) == rFileStatus.getAttributes()), CppUnit::Message( "assertion failed"
, "Expression: " "( osl_File_Attribute_GrpWrite | osl_File_Attribute_OwnWrite | osl_File_Attribute_OthWrite ) == rFileStatus.getAttributes()"
, "test for getAttributes function: GrpWrite, OwnWrite, OthWrite( Solaris version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2874 ) ) )
2873 ( osl_File_Attribute_GrpWrite | osl_File_Attribute_OwnWrite | osl_File_Attribute_OthWrite ) ==( CppUnit::Asserter::failIf( !(( 0x00000020 | 0x00000100 | 0x00000800
) == rFileStatus.getAttributes()), CppUnit::Message( "assertion failed"
, "Expression: " "( osl_File_Attribute_GrpWrite | osl_File_Attribute_OwnWrite | osl_File_Attribute_OthWrite ) == rFileStatus.getAttributes()"
, "test for getAttributes function: GrpWrite, OwnWrite, OthWrite( Solaris version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2874 ) ) )
2874 rFileStatus.getAttributes() )( CppUnit::Asserter::failIf( !(( 0x00000020 | 0x00000100 | 0x00000800
) == rFileStatus.getAttributes()), CppUnit::Message( "assertion failed"
, "Expression: " "( osl_File_Attribute_GrpWrite | osl_File_Attribute_OwnWrite | osl_File_Attribute_OthWrite ) == rFileStatus.getAttributes()"
, "test for getAttributes function: GrpWrite, OwnWrite, OthWrite( Solaris version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2874 ) ) )
;
2875 }
2876#else //Windows version
2877 void getAttributes_003()
2878 {
2879 CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: GrpWrite, OwnWrite, OthWrite( Windows version )",( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getAttributes function: GrpWrite, OwnWrite, OthWrite( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2880 ) ) )
2880 1 == 1 )( CppUnit::Asserter::failIf( !(1 == 1), CppUnit::Message( "assertion failed"
, "Expression: " "1 == 1", "test for getAttributes function: GrpWrite, OwnWrite, OthWrite( Windows version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2880 ) ) )
;
2881 }
2882#endif
2883
2884#if ( defined UNX1 ) //hidden file definition may different in Windows
2885 void getAttributes_004()
2886 {
2887 sal_Int32 test_Attributes = osl_File_Attribute_Hidden0x00000002;
2888 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Attributes0x00000002 );
2889 nError = rItem_hidden.getFileStatus( rFileStatus );
2890 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2890 ) ) )
;
2891 test_Attributes &= rFileStatus.getAttributes();
2892
2893 CPPUNIT_ASSERT_MESSAGE( "test for getAttributes function: Hidden files( Solaris version )",( CppUnit::Asserter::failIf( !(test_Attributes == 0x00000002)
, CppUnit::Message( "assertion failed", "Expression: " "test_Attributes == osl_File_Attribute_Hidden"
, "test for getAttributes function: Hidden files( Solaris version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2894 ) ) )
2894 test_Attributes == osl_File_Attribute_Hidden )( CppUnit::Asserter::failIf( !(test_Attributes == 0x00000002)
, CppUnit::Message( "assertion failed", "Expression: " "test_Attributes == osl_File_Attribute_Hidden"
, "test for getAttributes function: Hidden files( Solaris version )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2894 ) ) )
;
2895 }
2896#else //Windows version
2897 void getAttributes_004()
2898 {
2899 ::rtl::OUString aUserHiddenFileURL ("file:///c:/AUTOEXEC.BAT");
2900 nError = ::osl::DirectoryItem::get( aUserHiddenFileURL, rItem_hidden );
2901 CPPUNIT_ASSERT_MESSAGE("get item fail", nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
, "get item fail" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2901 ) ) )
;
2902 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Attributes0x00000002 );
2903 nError = rItem_hidden.getFileStatus( rFileStatus );
2904 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2904 ) ) )
;
2905
2906 CPPUNIT_ASSERT_MESSAGE( "Hidden files(Windows version), please check if hidden file c:/AUTOEXEC.BAT exists ",( CppUnit::Asserter::failIf( !((rFileStatus.getAttributes() &
0x00000002)!= 0), CppUnit::Message( "assertion failed", "Expression: "
"(rFileStatus.getAttributes() & osl_File_Attribute_Hidden)!= 0"
, "Hidden files(Windows version), please check if hidden file c:/AUTOEXEC.BAT exists "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2907 ) ) )
2907 (rFileStatus.getAttributes() & osl_File_Attribute_Hidden)!= 0 )( CppUnit::Asserter::failIf( !((rFileStatus.getAttributes() &
0x00000002)!= 0), CppUnit::Message( "assertion failed", "Expression: "
"(rFileStatus.getAttributes() & osl_File_Attribute_Hidden)!= 0"
, "Hidden files(Windows version), please check if hidden file c:/AUTOEXEC.BAT exists "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2907 ) ) )
;
2908 }
2909#endif
2910
2911 CPPUNIT_TEST_SUITE( getAttributes )public: typedef getAttributes TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getAttributes) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
2912 CPPUNIT_TEST( getAttributes_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAttributes_001"), &TestFixtureType
::getAttributes_001, context.makeFixture() ) ) )
;
2913 CPPUNIT_TEST( getAttributes_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAttributes_002"), &TestFixtureType
::getAttributes_002, context.makeFixture() ) ) )
;
2914 CPPUNIT_TEST( getAttributes_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAttributes_003"), &TestFixtureType
::getAttributes_003, context.makeFixture() ) ) )
;
2915 CPPUNIT_TEST( getAttributes_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAttributes_004"), &TestFixtureType
::getAttributes_004, context.makeFixture() ) ) )
;
2916 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2917 };// class getAttributes
2918
2919 //---------------------------------------------------------------------
2920 // testing the method
2921 // inline TimeValue getAccessTime() const
2922 //---------------------------------------------------------------------
2923 class getAccessTime : public CppUnit::TestFixture
2924 {
2925 ::rtl::OUString aTypeURL;
2926 ::osl::FileBase::RC nError;
2927 ::osl::DirectoryItem rItem;
2928
2929 public:
2930 // initialization
2931 void setUp()
2932 {
2933 aTypeURL = aUserDirectoryURL.copy( 0 );
2934 concatURL( aTypeURL, aTmpName2 );
2935 createTestFile( aTypeURL );
2936 nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
2937 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2937 ) ) )
;
2938
2939 }
2940
2941 void tearDown()
2942 {
2943 deleteTestFile( aTypeURL );
2944 }
2945
2946 // test code.
2947 void getAccessTime_001()
2948 {
2949 TimeValue *pTV_current = NULL__null;
2950 CPPUNIT_ASSERT( ( pTV_current = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL )( CppUnit::Asserter::failIf( !(( pTV_current = ( TimeValue* )
malloc( sizeof( TimeValue ) ) ) != __null), CppUnit::Message(
"assertion failed", "Expression: " "( pTV_current = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2950 ) ) )
;
2951 TimeValue *pTV_access = NULL__null;
2952 CPPUNIT_ASSERT( ( pTV_access = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL )( CppUnit::Asserter::failIf( !(( pTV_access = ( TimeValue* )malloc
( sizeof( TimeValue ) ) ) != __null), CppUnit::Message( "assertion failed"
, "Expression: " "( pTV_access = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2952 ) ) )
;
2953
2954 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_AccessTime0x00000020 );
2955 nError = rItem.getFileStatus( rFileStatus );
2956 sal_Bool bOk = osl_getSystemTime( pTV_current );
2957 CPPUNIT_ASSERT( sal_True == bOk && nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == bOk &&
nError == FileBase::E_None), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == bOk && nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2957 ) ) )
;
2958
2959 *pTV_access = rFileStatus.getAccessTime();
Called C++ object pointer is null
2960
2961 sal_Bool bOK = t_compareTime( pTV_access, pTV_current, delta2000 );
2962 free( pTV_current );
2963 free( pTV_access );
2964
2965 CPPUNIT_ASSERT_MESSAGE( "test for getAccessTime function: This test turns out that UNX pricision is no more than 1 sec, don't know how to test this function, in Windows test, it lost hour min sec, only have date time. ",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == bOK), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == bOK"
, "test for getAccessTime function: This test turns out that UNX pricision is no more than 1 sec, don't know how to test this function, in Windows test, it lost hour min sec, only have date time. "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2966 ) ) )
2966 sal_True == bOK )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == bOK), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == bOK"
, "test for getAccessTime function: This test turns out that UNX pricision is no more than 1 sec, don't know how to test this function, in Windows test, it lost hour min sec, only have date time. "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2966 ) ) )
;
2967 }
2968
2969 CPPUNIT_TEST_SUITE( getAccessTime )public: typedef getAccessTime TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getAccessTime) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
2970 CPPUNIT_TEST( getAccessTime_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getAccessTime_001"), &TestFixtureType
::getAccessTime_001, context.makeFixture() ) ) )
;
2971 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
2972 };// class getAccessTime
2973
2974 //---------------------------------------------------------------------
2975 // testing the method
2976 // inline TimeValue getModifyTime() const
2977 //---------------------------------------------------------------------
2978 class getModifyTime : public CppUnit::TestFixture
2979 {
2980 ::rtl::OUString aTypeURL;
2981 ::osl::FileBase::RC nError;
2982 ::osl::DirectoryItem rItem;
2983
2984 public:
2985
2986 // test code.
2987 void getModifyTime_001()
2988 {
2989 TimeValue *pTV_current = NULL__null;
2990 CPPUNIT_ASSERT( ( pTV_current = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL )( CppUnit::Asserter::failIf( !(( pTV_current = ( TimeValue* )
malloc( sizeof( TimeValue ) ) ) != __null), CppUnit::Message(
"assertion failed", "Expression: " "( pTV_current = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2990 ) ) )
;
2991
2992 //create file
2993 aTypeURL = aUserDirectoryURL.copy( 0 );
2994 concatURL( aTypeURL, aTmpName2 );
2995 createTestFile( aTypeURL );
2996
2997 //get current time
2998 sal_Bool bOk = osl_getSystemTime( pTV_current );
2999 CPPUNIT_ASSERT( sal_True == bOk )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == bOk), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == bOk"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 2999 ) ) )
;
3000
3001 //get instance item and filestatus
3002 nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3003 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3003 ) ) )
;
3004 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_ModifyTime0x00000040 );
3005 nError = rItem.getFileStatus( rFileStatus );
3006 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3006 ) ) )
;
3007
3008 //get modify time
3009 TimeValue *pTV_modify = NULL__null;
3010 CPPUNIT_ASSERT( ( pTV_modify = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL )( CppUnit::Asserter::failIf( !(( pTV_modify = ( TimeValue* )malloc
( sizeof( TimeValue ) ) ) != __null), CppUnit::Message( "assertion failed"
, "Expression: " "( pTV_modify = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3010 ) ) )
;
3011 *pTV_modify = rFileStatus.getModifyTime();
3012
3013 sal_Bool bOK = t_compareTime( pTV_modify, pTV_current, delta2000 );
3014 //delete file
3015 deleteTestFile( aTypeURL );
3016 free( pTV_current );
3017
3018 CPPUNIT_ASSERT_MESSAGE( "test for getModifyTime function: This test turns out that UNX pricision is no more than 1 sec, don't know how to improve this function. ",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == bOK), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == bOK"
, "test for getModifyTime function: This test turns out that UNX pricision is no more than 1 sec, don't know how to improve this function. "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3019 ) ) )
3019 sal_True == bOK )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == bOK), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == bOK"
, "test for getModifyTime function: This test turns out that UNX pricision is no more than 1 sec, don't know how to improve this function. "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3019 ) ) )
;
3020 }
3021
3022 CPPUNIT_TEST_SUITE( getModifyTime )public: typedef getModifyTime TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getModifyTime) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
3023 CPPUNIT_TEST( getModifyTime_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getModifyTime_001"), &TestFixtureType
::getModifyTime_001, context.makeFixture() ) ) )
;
3024 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3025 };// class getModifyTime
3026
3027
3028 //---------------------------------------------------------------------
3029 // testing the method
3030 // inline sal_uInt64 getFileSize() const
3031 //---------------------------------------------------------------------
3032 class getFileSize : public CppUnit::TestFixture
3033 {
3034 ::rtl::OUString aTypeURL;
3035 ::osl::FileBase::RC nError;
3036 ::osl::DirectoryItem rItem;
3037
3038 public:
3039 // initialization
3040 void setUp()
3041 {
3042 aTypeURL = aUserDirectoryURL.copy( 0 );
3043 concatURL( aTypeURL, aTmpName2 );
3044 createTestFile( aTypeURL );
3045 nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3046 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3046 ) ) )
;
3047 }
3048
3049 void tearDown()
3050 {
3051 deleteTestFile( aTypeURL );
3052 }
3053
3054 // test code.
3055 void getFileSize_001()
3056 {
3057 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileSize0x00000080 );
3058 nError = rItem.getFileStatus( rFileStatus );
3059 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3059 ) ) )
;
3060
3061 sal_uInt64 uFileSize = rFileStatus.getFileSize();
3062
3063 CPPUNIT_ASSERT_MESSAGE( "test for getFileSize function: empty file ",( CppUnit::Asserter::failIf( !(0 == uFileSize), CppUnit::Message
( "assertion failed", "Expression: " "0 == uFileSize", "test for getFileSize function: empty file "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3064 ) ) )
3064 0 == uFileSize )( CppUnit::Asserter::failIf( !(0 == uFileSize), CppUnit::Message
( "assertion failed", "Expression: " "0 == uFileSize", "test for getFileSize function: empty file "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3064 ) ) )
;
3065 }
3066
3067 void getFileSize_002()
3068 {
3069 ::osl::File testfile( aTypeURL );
3070 nError = testfile.open( osl_File_OpenFlag_Write0x00000002L | osl_File_OpenFlag_Read0x00000001L );
3071 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3071 ) ) )
;
3072 nError = testfile.setSize( TEST_FILE_SIZE1024 );
3073 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3073 ) ) )
;
3074
3075 nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3076 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3076 ) ) )
;
3077 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileSize0x00000080 );
3078 nError = rItem.getFileStatus( rFileStatus );
3079 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3079 ) ) )
;
3080 sal_uInt64 uFileSize = rFileStatus.getFileSize();
3081
3082 CPPUNIT_ASSERT_MESSAGE( "test for getFileSize function: file with size of TEST_FILE_SIZE, did not pass in (W32). ",( CppUnit::Asserter::failIf( !(1024 == uFileSize), CppUnit::Message
( "assertion failed", "Expression: " "TEST_FILE_SIZE == uFileSize"
, "test for getFileSize function: file with size of TEST_FILE_SIZE, did not pass in (W32). "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3083 ) ) )
3083 TEST_FILE_SIZE == uFileSize )( CppUnit::Asserter::failIf( !(1024 == uFileSize), CppUnit::Message
( "assertion failed", "Expression: " "TEST_FILE_SIZE == uFileSize"
, "test for getFileSize function: file with size of TEST_FILE_SIZE, did not pass in (W32). "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3083 ) ) )
;
3084 }
3085 CPPUNIT_TEST_SUITE( getFileSize )public: typedef getFileSize TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(getFileSize) ); return testNamer; } public
: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
3086 CPPUNIT_TEST( getFileSize_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileSize_001"), &TestFixtureType
::getFileSize_001, context.makeFixture() ) ) )
;
3087 CPPUNIT_TEST( getFileSize_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileSize_002"), &TestFixtureType
::getFileSize_002, context.makeFixture() ) ) )
;
3088 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3089 };// class getFileSize
3090
3091 //---------------------------------------------------------------------
3092 // testing the method
3093 // inline ::rtl::OUString getFileName() const
3094 //---------------------------------------------------------------------
3095 class getFileName : public CppUnit::TestFixture
3096 {
3097 ::rtl::OUString aTypeURL;
3098 ::osl::FileBase::RC nError;
3099 ::osl::DirectoryItem rItem;
3100
3101 public:
3102 // initialization
3103 void setUp()
3104 {
3105 aTypeURL = aUserDirectoryURL.copy( 0 );
3106 concatURL( aTypeURL, aTmpName2 );
3107 createTestFile( aTypeURL );
3108 nError = ::osl::DirectoryItem::get( aTypeURL, rItem );
3109 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3109 ) ) )
;
3110 }
3111
3112 void tearDown()
3113 {
3114 deleteTestFile( aTypeURL );
3115 }
3116
3117 // test code.
3118 void getFileName_001()
3119 {
3120 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 );
3121 nError = rItem.getFileStatus( rFileStatus );
3122 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3122 ) ) )
;
3123
3124 ::rtl::OUString aFileName = rFileStatus.getFileName();
3125
3126 CPPUNIT_ASSERT_MESSAGE( "test for getFileName function: name compare with specify",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aFileName, aTmpName2 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == compareFileName( aFileName, aTmpName2 )"
, "test for getFileName function: name compare with specify" )
, CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3127 ) ) )
3127 sal_True == compareFileName( aFileName, aTmpName2 ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aFileName, aTmpName2 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == compareFileName( aFileName, aTmpName2 )"
, "test for getFileName function: name compare with specify" )
, CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3127 ) ) )
;
3128 }
3129
3130 CPPUNIT_TEST_SUITE( getFileName )public: typedef getFileName TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(getFileName) ); return testNamer; } public
: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
3131 CPPUNIT_TEST( getFileName_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileName_001"), &TestFixtureType
::getFileName_001, context.makeFixture() ) ) )
;
3132 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3133 };// class getFileName
3134
3135 //---------------------------------------------------------------------
3136 // testing the method
3137 // inline ::rtl::OUString getFileURL() const
3138 //---------------------------------------------------------------------
3139 class getFileURL : public CppUnit::TestFixture
3140 {
3141 ::rtl::OUString aTypeURL;
3142 ::osl::FileBase::RC nError;
3143 ::osl::DirectoryItem rItem;
3144
3145 public:
3146 // initialization
3147 void setUp()
3148 {
3149 createTestFile( aTmpName6 );
3150 nError = ::osl::DirectoryItem::get( aTmpName6, rItem );
3151 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3151 ) ) )
;
3152 }
3153
3154 void tearDown()
3155 {
3156 deleteTestFile( aTmpName6 );
3157 }
3158
3159 // test code.
3160 void getFileURL_001()
3161 {
3162 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileURL0x00000200 );
3163 nError = rItem.getFileStatus( rFileStatus );
3164 CPPUNIT_ASSERT( nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3164 ) ) )
;
3165
3166 ::rtl::OUString aFileURL = rFileStatus.getFileURL();
3167
3168 CPPUNIT_ASSERT_MESSAGE( "test for getFileURL function: ",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aFileURL, aTmpName6 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == compareFileName( aFileURL, aTmpName6 )"
, "test for getFileURL function: " ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3169 ) ) )
3169 sal_True == compareFileName( aFileURL, aTmpName6 ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aFileURL, aTmpName6 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == compareFileName( aFileURL, aTmpName6 )"
, "test for getFileURL function: " ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3169 ) ) )
;
3170 }
3171
3172 CPPUNIT_TEST_SUITE( getFileURL )public: typedef getFileURL TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(getFileURL) ); return testNamer; } public:
typedef CppUnit::TestSuiteBuilderContext<TestFixtureType>
TestSuiteBuilderContextType; static void addTestsToSuite( CppUnit
::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
3173 CPPUNIT_TEST( getFileURL_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileURL_001"), &TestFixtureType
::getFileURL_001, context.makeFixture() ) ) )
;
3174 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3175 };// class getFileURL
3176
3177 //---------------------------------------------------------------------
3178 // testing the method
3179 // inline ::rtl::OUString getLinkTargetURL() const
3180 //---------------------------------------------------------------------
3181 class getLinkTargetURL : public CppUnit::TestFixture
3182 {
3183 ::rtl::OUString aTypeURL;
3184 ::osl::FileBase::RC nError;
3185 ::osl::DirectoryItem rItem;
3186
3187 public:
3188 // test code.
3189 // initialization
3190 void setUp()
3191 {
3192 aTypeURL = aUserDirectoryURL.copy( 0 );
3193 concatURL( aTypeURL, aTmpName2 );
3194 createTestFile( aTypeURL );
3195 }
3196
3197 void tearDown()
3198 {
3199 deleteTestFile( aTypeURL );
3200 }
3201
3202#if ( defined UNX1 ) //Link file is not define in Windows
3203 void getLinkTargetURL_001()
3204 {
3205 //create a link file;
3206 ::rtl::OUString aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys );
3207 ( ( aUStr_LnkFileSys += aSlashURL ) += getCurrentPID() ) += ::rtl::OUString("/link.file");
3208 ( ( aUStr_SrcFileSys += aSlashURL ) += getCurrentPID() ) += ::rtl::OUString("/tmpname");
3209
3210 rtl::OString strLinkFileName, strSrcFileName;
3211 strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
3212 strSrcFileName = OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
3213
3214 sal_Int32 fd;
3215 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() );
3216 CPPUNIT_ASSERT_MESSAGE( "in creating link file", fd == 0 )( CppUnit::Asserter::failIf( !(fd == 0), CppUnit::Message( "assertion failed"
, "Expression: " "fd == 0", "in creating link file" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3216 ) ) )
;
3217
3218 //get linkTarget URL
3219 nError = ::osl::DirectoryItem::get( aLnkURL1, rItem );
3220 CPPUNIT_ASSERT_MESSAGE( "in getting link file item", nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
, "in getting link file item" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3220 ) ) )
;
3221
3222 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_LinkTargetURL0x00000400 );
3223 nError = rItem.getFileStatus( rFileStatus );
3224 CPPUNIT_ASSERT_MESSAGE( "in getting link file status", nError == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError == FileBase::E_None"
, "in getting link file status" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3224 ) ) )
;
3225 ::rtl::OUString aFileURL = rFileStatus.getLinkTargetURL();
3226
3227 //remove link file
3228 fd = remove( strLinkFileName.getStr() );
3229 CPPUNIT_ASSERT_MESSAGE( "in deleting link file", fd == 0 )( CppUnit::Asserter::failIf( !(fd == 0), CppUnit::Message( "assertion failed"
, "Expression: " "fd == 0", "in deleting link file" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3229 ) ) )
;
3230
3231 CPPUNIT_ASSERT_MESSAGE( "test for getLinkTargetURL function: Solaris version, creat a file, and a link file link to it, get its LinkTargetURL and compare",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aFileURL, aTypeURL )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == compareFileName( aFileURL, aTypeURL )"
, "test for getLinkTargetURL function: Solaris version, creat a file, and a link file link to it, get its LinkTargetURL and compare"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3232 ) ) )
3232 sal_True == compareFileName( aFileURL, aTypeURL ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == compareFileName
( aFileURL, aTypeURL )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == compareFileName( aFileURL, aTypeURL )"
, "test for getLinkTargetURL function: Solaris version, creat a file, and a link file link to it, get its LinkTargetURL and compare"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3232 ) ) )
;
3233 }
3234#else
3235 void getLinkTargetURL_001()
3236 {
3237 CPPUNIT_ASSERT_MESSAGE( "test for getLinkTargetURL function: Windows version, not tested",( CppUnit::Asserter::failIf( !(1), CppUnit::Message( "assertion failed"
, "Expression: " "1", "test for getLinkTargetURL function: Windows version, not tested"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3238 ) ) )
3238 1 )( CppUnit::Asserter::failIf( !(1), CppUnit::Message( "assertion failed"
, "Expression: " "1", "test for getLinkTargetURL function: Windows version, not tested"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3238 ) ) )
;
3239 }
3240#endif
3241
3242 CPPUNIT_TEST_SUITE( getLinkTargetURL )public: typedef getLinkTargetURL TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getLinkTargetURL) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
3243 CPPUNIT_TEST( getLinkTargetURL_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getLinkTargetURL_001"), &TestFixtureType
::getLinkTargetURL_001, context.makeFixture() ) ) )
;
3244 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3245 };// class getLinkTargetURL
3246
3247 // -----------------------------------------------------------------------------
3248 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::ctors, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::ctors >
autoRegisterRegistry__3248("osl_FileStatus")
;
3249 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::isValid, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::isValid
> autoRegisterRegistry__3249("osl_FileStatus")
;
3250 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getFileType, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::getFileType
> autoRegisterRegistry__3250("osl_FileStatus")
;
3251 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getAttributes, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::getAttributes
> autoRegisterRegistry__3251("osl_FileStatus")
;
3252 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getAccessTime, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::getAccessTime
> autoRegisterRegistry__3252("osl_FileStatus")
;
3253 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getModifyTime, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::getModifyTime
> autoRegisterRegistry__3253("osl_FileStatus")
;
3254 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getFileSize, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::getFileSize
> autoRegisterRegistry__3254("osl_FileStatus")
;
3255 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getFileName, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::getFileName
> autoRegisterRegistry__3255("osl_FileStatus")
;
3256 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getFileURL, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::getFileURL
> autoRegisterRegistry__3256("osl_FileStatus")
;
3257 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_FileStatus::getLinkTargetURL, "osl_FileStatus" )static CppUnit::AutoRegisterSuite< osl_FileStatus::getLinkTargetURL
> autoRegisterRegistry__3257("osl_FileStatus")
;
3258}// namespace osl_FileStatus
3259
3260
3261
3262//------------------------------------------------------------------------
3263// Beginning of the test cases for File class
3264//------------------------------------------------------------------------
3265namespace osl_File
3266{
3267 //---------------------------------------------------------------------
3268 // testing the method
3269 // File( const ::rtl::OUString& ustrFileURL )
3270 //---------------------------------------------------------------------
3271 class ctors : public CppUnit::TestFixture
3272 {
3273 // ::osl::FileBase::RC nError1;
3274
3275 public:
3276 // initialization
3277 void setUp()
3278 {
3279 // create a tempfile in $TEMP/tmpdir/tmpname.
3280 createTestDirectory( aTmpName3 );
3281 createTestFile( aTmpName4 );
3282 }
3283
3284 void tearDown()
3285 {
3286 // remove the tempfile in $TEMP/tmpdir/tmpname.
3287 deleteTestFile( aTmpName4 );
3288 deleteTestDirectory( aTmpName3 );
3289 }
3290
3291 // test code.
3292 void ctors_001()
3293 {
3294 ::osl::File testFile( aTmpName4 );
3295
3296 ::osl::FileBase::RC nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3297 ::osl::FileBase::RC nError2 = testFile.close();
3298 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: initialize a File and test its open and close",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: initialize a File and test its open and close"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3299 ) ) )
3299 ( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: initialize a File and test its open and close"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3299 ) ) )
;
3300 }
3301
3302 void ctors_002()
3303 {
3304 ::osl::File testFile( aTmpName5 );
3305 sal_Char buffer[30] = "Test for File constructor";
3306 sal_uInt64 nCount;
3307
3308 ::osl::FileBase::RC nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3309 ::osl::FileBase::RC nError2 = testFile.write( buffer, 30, nCount );
3310 testFile.close();
3311
3312 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: test relative file URL, this test show that relative file URL is also acceptable",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: test relative file URL, this test show that relative file URL is also acceptable"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3313 ) ) )
3313 ( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: test relative file URL, this test show that relative file URL is also acceptable"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3313 ) ) )
;
3314 }
3315
3316 CPPUNIT_TEST_SUITE( ctors )public: typedef ctors TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(ctors) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
3317 CPPUNIT_TEST( ctors_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_001"), &TestFixtureType
::ctors_001, context.makeFixture() ) ) )
;
3318 CPPUNIT_TEST( ctors_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_002"), &TestFixtureType
::ctors_002, context.makeFixture() ) ) )
;
3319 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3320 };// class ctors
3321
3322 //---------------------------------------------------------------------
3323 // testing the method
3324 // inline RC open( sal_uInt32 uFlags )
3325 //---------------------------------------------------------------------
3326 class open : public CppUnit::TestFixture
3327 {
3328 ::osl::FileBase::RC nError1, nError2, nError3;
3329
3330 public:
3331 // initialization
3332 void setUp()
3333 {
3334 // create a tempfile in $TEMP/tmpdir/tmpname.
3335 createTestDirectory( aTmpName3 );
3336 createTestFile( aTmpName4 );
3337 }
3338
3339 void tearDown()
3340 {
3341 // remove the tempfile in $TEMP/tmpdir/tmpname.
3342 deleteTestFile( aTmpName4 );
3343 deleteTestDirectory( aTmpName3 );
3344 }
3345
3346 // test code.
3347 void open_001()
3348 {
3349 ::osl::File testFile( aTmpName4 );
3350
3351 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3352 nError2 = testFile.close();
3353 CPPUNIT_ASSERT_MESSAGE("close error", ::osl::FileBase::E_None == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError2"
, "close error" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3353 ) ) )
;
3354
3355 CPPUNIT_ASSERT_MESSAGE( "test for open function: open a regular file",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "test for open function: open a regular file" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 3356
) ) )
3356 ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "test for open function: open a regular file" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 3356
) ) )
;
3357 }
3358
3359 void open_002()
3360 {
3361 ::osl::File testFile( aTmpName3 );
3362
3363 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L );
3364
3365 CPPUNIT_ASSERT_MESSAGE( "test for open function: open a directory",( CppUnit::Asserter::failIf( !(( File::E_INVAL == nError1 ) ||
( File::E_ACCES == nError1 )), CppUnit::Message( "assertion failed"
, "Expression: " "( File::E_INVAL == nError1 ) || ( File::E_ACCES == nError1 )"
, "test for open function: open a directory" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 3366
) ) )
3366 ( File::E_INVAL == nError1 ) || ( File::E_ACCES == nError1 ) )( CppUnit::Asserter::failIf( !(( File::E_INVAL == nError1 ) ||
( File::E_ACCES == nError1 )), CppUnit::Message( "assertion failed"
, "Expression: " "( File::E_INVAL == nError1 ) || ( File::E_ACCES == nError1 )"
, "test for open function: open a directory" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 3366
) ) )
;
3367 }
3368
3369 void open_003()
3370 {
3371 ::osl::File testFile( aCanURL1 );
3372
3373 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3374
3375 CPPUNIT_ASSERT_MESSAGE( "test for open function: open a non-exist file",( CppUnit::Asserter::failIf( !(File::E_NOENT == nError1), CppUnit
::Message( "assertion failed", "Expression: " "File::E_NOENT == nError1"
, "test for open function: open a non-exist file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3376 ) ) )
3376 File::E_NOENT == nError1 )( CppUnit::Asserter::failIf( !(File::E_NOENT == nError1), CppUnit
::Message( "assertion failed", "Expression: " "File::E_NOENT == nError1"
, "test for open function: open a non-exist file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3376 ) ) )
;
3377 }
3378
3379 void open_004()
3380 {
3381 ::rtl::OUString aTestFile( aRootURL );
3382 concatURL( aTestFile, aTmpName2 );
3383 ::osl::File testFile( aTestFile );
3384
3385 nError1 = testFile.open( osl_File_OpenFlag_Create0x00000004L );
3386 sal_Bool bOK = ( File::E_ACCES == nError1 );
3387#if defined (WNT )
3388 bOK = sal_True((sal_Bool)1); /// in Windows, you can create file in c:/ any way.
3389 testFile.close();
3390 deleteTestFile( aTestFile);
3391#endif
3392
3393 CPPUNIT_ASSERT_MESSAGE( "test for open function: create an illegal file",( CppUnit::Asserter::failIf( !(bOK == ((sal_Bool)1)), CppUnit
::Message( "assertion failed", "Expression: " "bOK == sal_True"
, "test for open function: create an illegal file" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3394 ) ) )
3394 bOK == sal_True )( CppUnit::Asserter::failIf( !(bOK == ((sal_Bool)1)), CppUnit
::Message( "assertion failed", "Expression: " "bOK == sal_True"
, "test for open function: create an illegal file" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3394 ) ) )
;
3395 }
3396
3397 void open_005()
3398 {
3399 ::osl::File testFile( aTmpName4 );
3400
3401 nError1 = testFile.open( osl_File_OpenFlag_Create0x00000004L );
3402
3403 CPPUNIT_ASSERT_MESSAGE( "test for open function: create an exist file",( CppUnit::Asserter::failIf( !(File::E_EXIST == nError1), CppUnit
::Message( "assertion failed", "Expression: " "File::E_EXIST == nError1"
, "test for open function: create an exist file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3404 ) ) )
3404 File::E_EXIST == nError1 )( CppUnit::Asserter::failIf( !(File::E_EXIST == nError1), CppUnit
::Message( "assertion failed", "Expression: " "File::E_EXIST == nError1"
, "test for open function: create an exist file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3404 ) ) )
;
3405 }
3406
3407 void open_006()
3408 {
3409 ::osl::File testFile( aCanURL1 );
3410 sal_Char buffer_write[30] = "Test for File open";
3411 sal_Char buffer_read[30];
3412 sal_uInt64 nCount_write, nCount_read;
3413
3414 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L | osl_File_OpenFlag_Create0x00000004L );
3415 nError2 = testFile.write( buffer_write, 30, nCount_write );
3416 ::osl::FileBase::RC nError4 = testFile.setPos( osl_Pos_Absolut1, 0 );
3417 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError4 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError4
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError4"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3417 ) ) )
;
3418 nError3 = testFile.read( buffer_read, 10, nCount_read );
3419
3420 ::osl::FileBase::RC nError5 = testFile.close();
3421 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError5 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError5
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError5"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3421 ) ) )
;
3422 ::osl::FileBase::RC nError6 = testFile.remove( aCanURL1 );
3423 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError6 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError6
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError6"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3423 ) ) )
;
3424
3425 CPPUNIT_ASSERT_MESSAGE( "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 ) &&
( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write
) && ( 10 == nCount_read )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) && ( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write ) && ( 10 == nCount_read )"
, "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3430 ) ) )
3426 ( ::osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 ) &&
( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write
) && ( 10 == nCount_read )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) && ( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write ) && ( 10 == nCount_read )"
, "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3430 ) ) )
3427 ( ::osl::FileBase::E_None == nError2 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 ) &&
( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write
) && ( 10 == nCount_read )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) && ( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write ) && ( 10 == nCount_read )"
, "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3430 ) ) )
3428 ( ::osl::FileBase::E_None == nError3 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 ) &&
( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write
) && ( 10 == nCount_read )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) && ( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write ) && ( 10 == nCount_read )"
, "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3430 ) ) )
3429 ( 30 == nCount_write ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 ) &&
( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write
) && ( 10 == nCount_read )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) && ( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write ) && ( 10 == nCount_read )"
, "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3430 ) ) )
3430 ( 10 == nCount_read ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 ) &&
( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write
) && ( 10 == nCount_read )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 ) && ( ::osl::FileBase::E_None == nError3 ) && ( 30 == nCount_write ) && ( 10 == nCount_read )"
, "test for open function: test for osl_File_OpenFlag_Read, osl_File_OpenFlag_Write and osl_File_OpenFlag_Create"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3430 ) ) )
;
3431 }
3432
3433 CPPUNIT_TEST_SUITE( open )public: typedef open TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(open) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
3434 CPPUNIT_TEST( open_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_001"), &TestFixtureType
::open_001, context.makeFixture() ) ) )
;
3435 CPPUNIT_TEST( open_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_002"), &TestFixtureType
::open_002, context.makeFixture() ) ) )
;
3436 CPPUNIT_TEST( open_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_003"), &TestFixtureType
::open_003, context.makeFixture() ) ) )
;
3437 CPPUNIT_TEST( open_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_004"), &TestFixtureType
::open_004, context.makeFixture() ) ) )
;
3438 CPPUNIT_TEST( open_005 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_005"), &TestFixtureType
::open_005, context.makeFixture() ) ) )
;
3439 CPPUNIT_TEST( open_006 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_006"), &TestFixtureType
::open_006, context.makeFixture() ) ) )
;
3440 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3441 };// class open
3442
3443 //---------------------------------------------------------------------
3444 // testing the method
3445 // inline RC close()
3446 //---------------------------------------------------------------------
3447 class close : public CppUnit::TestFixture
3448 {
3449 ::osl::FileBase::RC nError1, nError2, nError3;
3450
3451 public:
3452 // initialization
3453 void setUp()
3454 {
3455 // create a tempfile in $TEMP/tmpdir/tmpname.
3456 createTestDirectory( aTmpName3 );
3457 createTestFile( aTmpName4 );
3458 }
3459
3460 void tearDown()
3461 {
3462 // remove the tempfile in $TEMP/tmpdir/tmpname.
3463 deleteTestFile( aTmpName4 );
3464 deleteTestDirectory( aTmpName3 );
3465 }
3466
3467 // test code.
3468 void close_001()
3469 {
3470 ::osl::File testFile( aTmpName4 );
3471
3472 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3473 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3473 ) ) )
;
3474
3475 nError2 = testFile.close();
3476
3477 CPPUNIT_ASSERT_MESSAGE( "test for close function: close a regular file",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError2"
, "test for close function: close a regular file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3478 ) ) )
3478 ::osl::FileBase::E_None == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError2"
, "test for close function: close a regular file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3478 ) ) )
;
3479 }
3480
3481 void close_002()
3482 {
3483 ::osl::File testFile( aTmpName4 );
3484
3485 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3486 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3486 ) ) )
;
3487
3488 nError2 = testFile.close();
3489
3490 nError3 = testFile.setPos( osl_Pos_Absolut1, 0 );
3491
3492 CPPUNIT_ASSERT_MESSAGE( "test for close function: manipulate a file after it has been closed",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ::osl::FileBase::E_None != nError3 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( ::osl::FileBase::E_None != nError3 )"
, "test for close function: manipulate a file after it has been closed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3494 ) ) )
3493 ( ::osl::FileBase::E_None == nError2 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ::osl::FileBase::E_None != nError3 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( ::osl::FileBase::E_None != nError3 )"
, "test for close function: manipulate a file after it has been closed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3494 ) ) )
3494 ( ::osl::FileBase::E_None != nError3 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ::osl::FileBase::E_None != nError3 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( ::osl::FileBase::E_None != nError3 )"
, "test for close function: manipulate a file after it has been closed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3494 ) ) )
;
3495 }
3496
3497 CPPUNIT_TEST_SUITE( close )public: typedef close TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(close) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
3498 CPPUNIT_TEST( close_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "close_001"), &TestFixtureType
::close_001, context.makeFixture() ) ) )
;
3499 CPPUNIT_TEST( close_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "close_002"), &TestFixtureType
::close_002, context.makeFixture() ) ) )
;
3500 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3501 };// class close
3502
3503
3504 //---------------------------------------------------------------------
3505 // testing the method
3506 // inline RC setPos( sal_uInt32 uHow, sal_Int64 uPos )
3507 //---------------------------------------------------------------------
3508 class setPos : public CppUnit::TestFixture
3509 {
3510 ::osl::FileBase::RC nError1;
3511 sal_uInt64 nCount_write, nCount_read;
3512
3513 public:
3514 // initialization
3515 void setUp()
3516 {
3517 // create a tempfile in $TEMP/tmpdir/tmpname.
3518 createTestDirectory( aTmpName3 );
3519 createTestFile( aTmpName4 );
3520
3521 //write chars into the file.
3522 ::osl::File testFile( aTmpName4 );
3523
3524 nError1 = testFile.open( osl_File_OpenFlag_Write0x00000002L );
3525 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3525 ) ) )
;
3526 nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
3527 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3527 ) ) )
;
3528 nError1 = testFile.close();
3529 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3529 ) ) )
;
3530 }
3531
3532 void tearDown()
3533 {
3534 // remove the tempfile in $TEMP/tmpdir/tmpname.
3535 deleteTestFile( aTmpName4 );
3536 deleteTestDirectory( aTmpName3 );
3537 }
3538
3539 // test code.
3540 void setPos_001()
3541 {
3542 ::osl::File testFile( aTmpName4 );
3543 sal_Char buffer_read[2];
3544
3545 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3546 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3546 ) ) )
;
3547 nError1 = testFile.setPos( osl_Pos_Absolut1, 26 );
3548 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3548 ) ) )
;
3549 nError1 = testFile.read( buffer_read, 1, nCount_read );
3550 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3550 ) ) )
;
3551 nError1 = testFile.close();
3552 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3552 ) ) )
;
3553
3554 CPPUNIT_ASSERT_MESSAGE( "test for setPos function: test for osl_Pos_Absolut, set the position to 26, test if the 26th char in file is correct",( CppUnit::Asserter::failIf( !(buffer_read[0] == pBuffer_Char
[26]), CppUnit::Message( "assertion failed", "Expression: " "buffer_read[0] == pBuffer_Char[26]"
, "test for setPos function: test for osl_Pos_Absolut, set the position to 26, test if the 26th char in file is correct"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3555 ) ) )
3555 buffer_read[0] == pBuffer_Char[26] )( CppUnit::Asserter::failIf( !(buffer_read[0] == pBuffer_Char
[26]), CppUnit::Message( "assertion failed", "Expression: " "buffer_read[0] == pBuffer_Char[26]"
, "test for setPos function: test for osl_Pos_Absolut, set the position to 26, test if the 26th char in file is correct"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3555 ) ) )
;
3556 }
3557
3558 void setPos_002()
3559 {
3560 ::osl::File testFile( aTmpName4 );
3561 sal_Char buffer_read[2];
3562
3563 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3564 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3564 ) ) )
;
3565 nError1 = testFile.setPos( osl_Pos_Absolut1, sizeof( pBuffer_Char ) - 2 );
3566 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3566 ) ) )
;
3567 nError1 = testFile.setPos( osl_Pos_Current2, 0);
3568 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3568 ) ) )
;
3569 nError1 = testFile.read( buffer_read, 1, nCount_read );
3570 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3570 ) ) )
;
3571 nError1 = testFile.close();
3572 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3572 ) ) )
;
3573
3574 CPPUNIT_ASSERT_MESSAGE( "test for setPos function: test for osl_Pos_Current, set the position to end, test if the ( end -1 ) char in file is correct",( CppUnit::Asserter::failIf( !(buffer_read[0] == pBuffer_Char
[sizeof( pBuffer_Char ) - 2]), CppUnit::Message( "assertion failed"
, "Expression: " "buffer_read[0] == pBuffer_Char[sizeof( pBuffer_Char ) - 2]"
, "test for setPos function: test for osl_Pos_Current, set the position to end, test if the ( end -1 ) char in file is correct"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3575 ) ) )
3575 buffer_read[0] == pBuffer_Char[sizeof( pBuffer_Char ) - 2] )( CppUnit::Asserter::failIf( !(buffer_read[0] == pBuffer_Char
[sizeof( pBuffer_Char ) - 2]), CppUnit::Message( "assertion failed"
, "Expression: " "buffer_read[0] == pBuffer_Char[sizeof( pBuffer_Char ) - 2]"
, "test for setPos function: test for osl_Pos_Current, set the position to end, test if the ( end -1 ) char in file is correct"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3575 ) ) )
;
3576 }
3577
3578 void setPos_003()
3579 {
3580 ::osl::File testFile( aTmpName4 );
3581 sal_Char buffer_read[2];
3582
3583 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3584 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3584 ) ) )
;
3585 //the file size is smaller than 100
3586 nError1 = testFile.setPos( osl_Pos_End3, -100 );
3587 CPPUNIT_ASSERT_MESSAGE( "should return error", ::osl::FileBase::E_INVAL == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_INVAL == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_INVAL == nError1"
, "should return error" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3587 ) ) )
;
3588
3589 nError1 = testFile.setPos( osl_Pos_End3, -53 );
3590 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3590 ) ) )
;
3591 nError1 = testFile.read( buffer_read, 1, nCount_read );
3592 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3592 ) ) )
;
3593 nError1 = testFile.close();
3594 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3594 ) ) )
;
3595
3596 CPPUNIT_ASSERT_MESSAGE( "test for setPos function: test for osl_Pos_End, set the position to end, test if the first char in file is correct",( CppUnit::Asserter::failIf( !(buffer_read[0] == pBuffer_Char
[0]), CppUnit::Message( "assertion failed", "Expression: " "buffer_read[0] == pBuffer_Char[0]"
, "test for setPos function: test for osl_Pos_End, set the position to end, test if the first char in file is correct"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3597 ) ) )
3597 buffer_read[0] == pBuffer_Char[0] )( CppUnit::Asserter::failIf( !(buffer_read[0] == pBuffer_Char
[0]), CppUnit::Message( "assertion failed", "Expression: " "buffer_read[0] == pBuffer_Char[0]"
, "test for setPos function: test for osl_Pos_End, set the position to end, test if the first char in file is correct"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3597 ) ) )
;
3598 }
3599
3600 CPPUNIT_TEST_SUITE( setPos )public: typedef setPos TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(setPos) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
3601 CPPUNIT_TEST( setPos_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "setPos_001"), &TestFixtureType
::setPos_001, context.makeFixture() ) ) )
;
3602 CPPUNIT_TEST( setPos_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "setPos_002"), &TestFixtureType
::setPos_002, context.makeFixture() ) ) )
;
3603 CPPUNIT_TEST( setPos_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "setPos_003"), &TestFixtureType
::setPos_003, context.makeFixture() ) ) )
;
3604 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3605 };// class setPos
3606
3607 //---------------------------------------------------------------------
3608 // testing the method
3609 // inline RC getPos( sal_uInt64& uPos )
3610 //---------------------------------------------------------------------
3611 class getPos : public CppUnit::TestFixture
3612 {
3613 ::osl::FileBase::RC nError1;
3614 sal_uInt64 nCount_write;
3615
3616 public:
3617 // initialization
3618 void setUp()
3619 {
3620 // create a tempfile in $TEMP/tmpdir/tmpname.
3621 createTestDirectory( aTmpName3 );
3622 createTestFile( aTmpName4 );
3623
3624 //write chars into the file.
3625 ::osl::File testFile( aTmpName4 );
3626
3627 nError1 = testFile.open( osl_File_OpenFlag_Write0x00000002L );
3628 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3628 ) ) )
;
3629 nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
3630 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3630 ) ) )
;
3631 nError1 = testFile.close();
3632 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3632 ) ) )
;
3633 }
3634
3635 void tearDown()
3636 {
3637 // remove the tempfile in $TEMP/tmpdir/tmpname.
3638 deleteTestFile( aTmpName4 );
3639 deleteTestDirectory( aTmpName3 );
3640 }
3641
3642 // test code.
3643 void getPos_001()
3644 {
3645 ::osl::File testFile( aTmpName4 );
3646 sal_uInt64 nFilePointer;
3647
3648 nError1 = testFile.getPos( nFilePointer );
3649 CPPUNIT_ASSERT( ::osl::FileBase::E_INVAL == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_INVAL == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_INVAL == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3649 ) ) )
;
3650
3651 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3652 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3652 ) ) )
;
3653
3654 nError1 = testFile.setPos( osl_Pos_Absolut1, 26 );
3655 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3655 ) ) )
;
3656 nError1 = testFile.getPos( nFilePointer );
3657 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3657 ) ) )
;
3658
3659 nError1 = testFile.close();
3660 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3660 ) ) )
;
3661
3662 CPPUNIT_ASSERT_MESSAGE( "test for getPos function: set the position to 26, get position and check if it is right",( CppUnit::Asserter::failIf( !(26 == nFilePointer), CppUnit::
Message( "assertion failed", "Expression: " "26 == nFilePointer"
, "test for getPos function: set the position to 26, get position and check if it is right"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3663 ) ) )
3663 26 == nFilePointer )( CppUnit::Asserter::failIf( !(26 == nFilePointer), CppUnit::
Message( "assertion failed", "Expression: " "26 == nFilePointer"
, "test for getPos function: set the position to 26, get position and check if it is right"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3663 ) ) )
;
3664 }
3665
3666 CPPUNIT_TEST_SUITE( getPos )public: typedef getPos TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(getPos) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
3667 CPPUNIT_TEST( getPos_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getPos_001"), &TestFixtureType
::getPos_001, context.makeFixture() ) ) )
;
3668 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3669 };// class getPos
3670
3671
3672 //---------------------------------------------------------------------
3673 // testing the method
3674 // inline RC isEndOfFile( sal_Bool *pIsEOF )
3675 //---------------------------------------------------------------------
3676 class isEndOfFile : public CppUnit::TestFixture
3677 {
3678 ::osl::FileBase::RC nError1;
3679 sal_uInt64 nCount_write;
3680
3681 public:
3682 // initialization
3683 void setUp()
3684 {
3685 // create a tempfile in $TEMP/tmpdir/tmpname.
3686 createTestDirectory( aTmpName3 );
3687 createTestFile( aTmpName4 );
3688
3689 //write chars into the file.
3690 ::osl::File testFile( aTmpName4 );
3691
3692 nError1 = testFile.open( osl_File_OpenFlag_Write0x00000002L );
3693 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3693 ) ) )
;
3694 nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
3695 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3695 ) ) )
;
3696 nError1 = testFile.close();
3697 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3697 ) ) )
;
3698 }
3699
3700 void tearDown()
3701 {
3702 // remove the tempfile in $TEMP/tmpdir/tmpname.
3703 deleteTestFile( aTmpName4 );
3704 deleteTestDirectory( aTmpName3 );
3705 }
3706
3707 // test code.
3708 void isEndOfFile_001()
3709 {
3710 ::osl::File testFile( aTmpName4 );
3711 sal_Bool bEOF = sal_False((sal_Bool)0);
3712 sal_Bool *pEOF = &bEOF;
3713
3714
3715 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3716 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3716 ) ) )
;
3717
3718 nError1 = testFile.setPos( osl_Pos_End3, 0 );
3719 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3719 ) ) )
;
3720 nError1 = testFile.isEndOfFile( pEOF );
3721 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3721 ) ) )
;
3722
3723 nError1 = testFile.close();
3724 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3724 ) ) )
;
3725
3726 CPPUNIT_ASSERT_MESSAGE( "test for isEndOfFile function: set the position to end, check if reach end",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == *pEOF), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == *pEOF"
, "test for isEndOfFile function: set the position to end, check if reach end"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3727 ) ) )
3727 sal_True == *pEOF )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == *pEOF), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == *pEOF"
, "test for isEndOfFile function: set the position to end, check if reach end"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3727 ) ) )
;
3728 }
3729
3730 void isEndOfFile_002()
3731 {
3732 ::osl::File testFile( aTmpName4 );
3733 sal_Bool bEOF = sal_False((sal_Bool)0);
3734 sal_Bool *pEOF = &bEOF;
3735 sal_uInt64 nFilePointer = 0;
3736
3737 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3738 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3738 ) ) )
;
3739
3740 nError1 = testFile.setPos( osl_Pos_Absolut1, 0 );
3741 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3741 ) ) )
;
3742 *pEOF = sal_False((sal_Bool)0);
3743 while ( !( *pEOF ) )
3744 {
3745 nError1 = testFile.isEndOfFile( pEOF );
3746 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3746 ) ) )
;
3747 nError1 = testFile.setPos( osl_Pos_Current2, 1 );
3748 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3748 ) ) )
;
3749 }
3750 nError1 = testFile.getPos( nFilePointer );
3751 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3751 ) ) )
;
3752
3753 nError1 = testFile.close();
3754 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3754 ) ) )
;
3755
3756 CPPUNIT_ASSERT_MESSAGE( "test for isEndOfFile function: use isEndOfFile to move pointer step by step",( CppUnit::Asserter::failIf( !(sizeof( pBuffer_Char ) + 1 == nFilePointer
), CppUnit::Message( "assertion failed", "Expression: " "sizeof( pBuffer_Char ) + 1 == nFilePointer"
, "test for isEndOfFile function: use isEndOfFile to move pointer step by step"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3757 ) ) )
3757 sizeof( pBuffer_Char ) + 1 == nFilePointer )( CppUnit::Asserter::failIf( !(sizeof( pBuffer_Char ) + 1 == nFilePointer
), CppUnit::Message( "assertion failed", "Expression: " "sizeof( pBuffer_Char ) + 1 == nFilePointer"
, "test for isEndOfFile function: use isEndOfFile to move pointer step by step"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3757 ) ) )
;
3758 }
3759 CPPUNIT_TEST_SUITE( isEndOfFile )public: typedef isEndOfFile TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(isEndOfFile) ); return testNamer; } public
: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
3760 CPPUNIT_TEST( isEndOfFile_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isEndOfFile_001"), &TestFixtureType
::isEndOfFile_001, context.makeFixture() ) ) )
;
3761 CPPUNIT_TEST( isEndOfFile_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isEndOfFile_002"), &TestFixtureType
::isEndOfFile_002, context.makeFixture() ) ) )
;
3762 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3763 };// class isEndOfFile
3764
3765
3766 //---------------------------------------------------------------------
3767 // testing the method
3768 // inline RC setSize( sal_uInt64 uSize )
3769 //---------------------------------------------------------------------
3770 class setSize : public CppUnit::TestFixture
3771 {
3772 ::osl::FileBase::RC nError1;
3773 sal_uInt64 nCount_write;
3774
3775 public:
3776 // initialization
3777 void setUp()
3778 {
3779 // create a tempfile in $TEMP/tmpdir/tmpname.
3780 createTestDirectory( aTmpName3 );
3781 createTestFile( aTmpName4 );
3782
3783 //write chars into the file.
3784 ::osl::File testFile( aTmpName4 );
3785
3786 nError1 = testFile.open( osl_File_OpenFlag_Write0x00000002L );
3787 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3787 ) ) )
;
3788 nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
3789 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3789 ) ) )
;
3790 nError1 = testFile.close();
3791 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3791 ) ) )
;
3792 }
3793
3794 void tearDown()
3795 {
3796 // remove the tempfile in $TEMP/tmpdir/tmpname.
3797 deleteTestFile( aTmpName4 );
3798 deleteTestDirectory( aTmpName3 );
3799 }
3800
3801 // test code.
3802 void setSize_001()
3803 {
3804 ::osl::File testFile( aTmpName4 );
3805 // sal_Bool bEOF = sal_False;
3806 // sal_Bool *pEOF = &bEOF;
3807 sal_uInt64 nFilePointer;
3808
3809
3810 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3811 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3811 ) ) )
;
3812
3813 //enlarge the file to size of 100;
3814 nError1 = testFile.setSize( 100 );
3815 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3815 ) ) )
;
3816
3817 //get the file size;
3818 nError1 = testFile.setPos( osl_Pos_End3, 0 );
3819 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3819 ) ) )
;
3820 nError1 = testFile.getPos( nFilePointer );
3821 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3821 ) ) )
;
3822
3823 nError1 = testFile.close();
3824 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3824 ) ) )
;
3825
3826 CPPUNIT_ASSERT_MESSAGE( "test for setSize function: enlarge the file ",( CppUnit::Asserter::failIf( !(100 == nFilePointer), CppUnit::
Message( "assertion failed", "Expression: " "100 == nFilePointer"
, "test for setSize function: enlarge the file " ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3827 ) ) )
3827 100 == nFilePointer )( CppUnit::Asserter::failIf( !(100 == nFilePointer), CppUnit::
Message( "assertion failed", "Expression: " "100 == nFilePointer"
, "test for setSize function: enlarge the file " ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3827 ) ) )
;
3828 }
3829
3830 void setSize_002()
3831 {
3832 ::osl::File testFile( aTmpName4 );
3833 // sal_Bool bEOF = sal_False;
3834 // sal_Bool *pEOF = &bEOF;
3835 sal_uInt64 nFilePointer;
3836
3837
3838 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3839 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3839 ) ) )
;
3840
3841 //enlarge the file to size of 100;
3842 nError1 = testFile.setSize( 10 );
3843 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3843 ) ) )
;
3844
3845 //get the file size;
3846 nError1 = testFile.setPos( osl_Pos_End3, 0 );
3847 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3847 ) ) )
;
3848 nError1 = testFile.getPos( nFilePointer );
3849 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3849 ) ) )
;
3850
3851 nError1 = testFile.close();
3852 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3852 ) ) )
;
3853
3854 CPPUNIT_ASSERT_MESSAGE( "test for setSize function: truncate the file ",( CppUnit::Asserter::failIf( !(10 == nFilePointer), CppUnit::
Message( "assertion failed", "Expression: " "10 == nFilePointer"
, "test for setSize function: truncate the file " ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3855 ) ) )
3855 10 == nFilePointer )( CppUnit::Asserter::failIf( !(10 == nFilePointer), CppUnit::
Message( "assertion failed", "Expression: " "10 == nFilePointer"
, "test for setSize function: truncate the file " ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3855 ) ) )
;
3856 }
3857
3858 CPPUNIT_TEST_SUITE( setSize )public: typedef setSize TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(setSize) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
3859 CPPUNIT_TEST( setSize_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "setSize_001"), &TestFixtureType
::setSize_001, context.makeFixture() ) ) )
;
3860 CPPUNIT_TEST( setSize_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "setSize_002"), &TestFixtureType
::setSize_002, context.makeFixture() ) ) )
;
3861 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3862 };// class setSize
3863
3864
3865 //---------------------------------------------------------------------
3866 // testing the method
3867 // inline RC read( void *pBuffer, sal_uInt64 uBytesRequested, sal_uInt64& rBytesRead )
3868 //---------------------------------------------------------------------
3869 class read : public CppUnit::TestFixture
3870 {
3871 ::osl::FileBase::RC nError1;
3872 sal_uInt64 nCount_write, nCount_read;
3873
3874 public:
3875 // initialization
3876 void setUp()
3877 {
3878 // create a tempfile in $TEMP/tmpdir/tmpname.
3879 createTestDirectory( aTmpName3 );
3880 createTestFile( aTmpName4 );
3881
3882 //write chars into the file.
3883 ::osl::File testFile( aTmpName4 );
3884
3885 nError1 = testFile.open( osl_File_OpenFlag_Write0x00000002L );
3886 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3886 ) ) )
;
3887 nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
3888 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3888 ) ) )
;
3889 nError1 = testFile.close();
3890 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3890 ) ) )
;
3891 }
3892
3893 void tearDown()
3894 {
3895 // remove the tempfile in $TEMP/tmpdir/tmpname.
3896 deleteTestFile( aTmpName4 );
3897 deleteTestDirectory( aTmpName3 );
3898 }
3899
3900 // test code.
3901 void read_001()
3902 {
3903 ::osl::File testFile( aTmpName4 );
3904 sal_uInt64 nFilePointer;
3905 sal_Char buffer_read[10];
3906
3907
3908 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3909 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3909 ) ) )
;
3910
3911 nError1 = testFile.read( buffer_read, 10, nCount_read );
3912 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3912 ) ) )
;
3913 nError1 = testFile.getPos( nFilePointer );
3914 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3914 ) ) )
;
3915
3916 nError1 = testFile.close();
3917 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3917 ) ) )
;
3918
3919 CPPUNIT_ASSERT_MESSAGE( "test for read function: read whole content in the file to a buffer",( CppUnit::Asserter::failIf( !(( 10 == nFilePointer ) &&
( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) )), CppUnit::
Message( "assertion failed", "Expression: " "( 10 == nFilePointer ) && ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) )"
, "test for read function: read whole content in the file to a buffer"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3920 ) ) )
3920 ( 10 == nFilePointer ) && ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) )( CppUnit::Asserter::failIf( !(( 10 == nFilePointer ) &&
( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) )), CppUnit::
Message( "assertion failed", "Expression: " "( 10 == nFilePointer ) && ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) )"
, "test for read function: read whole content in the file to a buffer"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3920 ) ) )
;
3921 }
3922
3923 void read_002()
3924 {
3925 ::osl::File testFile( aTmpName4 );
3926 sal_uInt64 nFilePointer;
3927 sal_Char buffer_read[26];
3928
3929
3930 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3931 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3931 ) ) )
;
3932
3933 nError1 = testFile.setPos( osl_Pos_Absolut1, 26 );
3934 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3934 ) ) )
;
3935 nError1 = testFile.read( buffer_read, 26, nCount_read );
3936 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3936 ) ) )
;
3937 nError1 = testFile.getPos( nFilePointer );
3938 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3938 ) ) )
;
3939
3940 nError1 = testFile.close();
3941 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3941 ) ) )
;
3942
3943 CPPUNIT_ASSERT_MESSAGE( "test for read function: read from a special positon in the file",( CppUnit::Asserter::failIf( !(( 52 == nFilePointer ) &&
( 26 == nCount_read ) && ( 0 == strncmp( buffer_read
, &pBuffer_Char[26], 26 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( 52 == nFilePointer ) && ( 26 == nCount_read ) && ( 0 == strncmp( buffer_read, &pBuffer_Char[26], 26 ) )"
, "test for read function: read from a special positon in the file"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3944 ) ) )
3944 ( 52 == nFilePointer ) && ( 26 == nCount_read ) && ( 0 == strncmp( buffer_read, &pBuffer_Char[26], 26 ) ) )( CppUnit::Asserter::failIf( !(( 52 == nFilePointer ) &&
( 26 == nCount_read ) && ( 0 == strncmp( buffer_read
, &pBuffer_Char[26], 26 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( 52 == nFilePointer ) && ( 26 == nCount_read ) && ( 0 == strncmp( buffer_read, &pBuffer_Char[26], 26 ) )"
, "test for read function: read from a special positon in the file"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3944 ) ) )
;
3945 }
3946
3947 CPPUNIT_TEST_SUITE( read )public: typedef read TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(read) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
3948 CPPUNIT_TEST( read_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "read_001"), &TestFixtureType
::read_001, context.makeFixture() ) ) )
;
3949 CPPUNIT_TEST( read_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "read_002"), &TestFixtureType
::read_002, context.makeFixture() ) ) )
;
3950 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
3951 };// class read
3952
3953 //---------------------------------------------------------------------
3954 // testing the method
3955 // inline RC write(const void *pBuffer, sal_uInt64 uBytesToWrite, sal_uInt64& rBytesWritten)
3956 //---------------------------------------------------------------------
3957 class write : public CppUnit::TestFixture
3958 {
3959 ::osl::FileBase::RC nError1;
3960 sal_uInt64 nCount_write, nCount_read;
3961
3962 public:
3963 // initialization
3964 void setUp()
3965 {
3966 // create a tempfile in $TEMP/tmpname.
3967 createTestFile( aTmpName6 );
3968 }
3969
3970 void tearDown()
3971 {
3972 // remove the tempfile in $TEMP/tmpname.
3973 deleteTestFile( aTmpName6 );
3974 }
3975
3976 // test code.
3977 void write_001()
3978 {
3979 ::osl::File testFile( aTmpName6 );
3980 sal_uInt64 nFilePointer;
3981 sal_Char buffer_read[10];
3982
3983 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
3984 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3984 ) ) )
;
3985
3986 //write chars into the file.
3987 nError1 = testFile.write( pBuffer_Char, 10, nCount_write );
3988 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3988 ) ) )
;
3989 //get the current pointer;
3990 nError1 = testFile.getPos( nFilePointer );
3991 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3991 ) ) )
;
3992 //reset pointer to the begining;
3993 nError1 = testFile.setPos( osl_Pos_Absolut1, 0 );
3994 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3994 ) ) )
;
3995 nError1 = testFile.read( buffer_read, 10, nCount_read );
3996 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3996 ) ) )
;
3997
3998 nError1 = testFile.close();
3999 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 3999 ) ) )
;
4000
4001 CPPUNIT_ASSERT_MESSAGE( "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size",( CppUnit::Asserter::failIf( !(( 10 == nFilePointer ) &&
( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) &&
( 10 == nCount_write )), CppUnit::Message( "assertion failed"
, "Expression: " "( 10 == nFilePointer ) && ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) && ( 10 == nCount_write )"
, "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4004 ) ) )
4002 ( 10 == nFilePointer ) &&( CppUnit::Asserter::failIf( !(( 10 == nFilePointer ) &&
( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) &&
( 10 == nCount_write )), CppUnit::Message( "assertion failed"
, "Expression: " "( 10 == nFilePointer ) && ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) && ( 10 == nCount_write )"
, "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4004 ) ) )
4003 ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) &&( CppUnit::Asserter::failIf( !(( 10 == nFilePointer ) &&
( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) &&
( 10 == nCount_write )), CppUnit::Message( "assertion failed"
, "Expression: " "( 10 == nFilePointer ) && ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) && ( 10 == nCount_write )"
, "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4004 ) ) )
4004 ( 10 == nCount_write ) )( CppUnit::Asserter::failIf( !(( 10 == nFilePointer ) &&
( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) &&
( 10 == nCount_write )), CppUnit::Message( "assertion failed"
, "Expression: " "( 10 == nFilePointer ) && ( 0 == strncmp( buffer_read, pBuffer_Char, 10 ) ) && ( 10 == nCount_write )"
, "test for write function: read whole content in the file to a buffer. Note, buffer size can not smaller than the read size"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4004 ) ) )
;
4005 }
4006
4007 CPPUNIT_TEST_SUITE( write )public: typedef write TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(write) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4008 CPPUNIT_TEST( write_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "write_001"), &TestFixtureType
::write_001, context.makeFixture() ) ) )
;
4009 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4010 };// class write
4011
4012 //---------------------------------------------------------------------
4013 // testing the method
4014 // inline RC readLine( ::rtl::ByteSequence& aSeq )
4015 //---------------------------------------------------------------------
4016 class readLine : public CppUnit::TestFixture
4017 {
4018 ::osl::FileBase::RC nError1;
4019 sal_uInt64 nCount_write;
4020 ::rtl::ByteSequence aSequence;
4021
4022 public:
4023 // initialization
4024 void setUp()
4025 {
4026 // create a tempfile in $TEMP/tmpname.
4027 createTestFile( aTmpName6 );
4028
4029 //write some strings into the file.
4030 ::osl::File testFile( aTmpName6 );
4031 sal_Char ppStrSeq[3][27] = { "abcde\n",
4032 "1234567890\n",
4033 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
4034 };
4035
4036 nError1 = testFile.open( osl_File_OpenFlag_Write0x00000002L );
4037 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4037 ) ) )
;
4038
4039 for ( int nCount = 0; nCount < 3; nCount++ )
4040 {
4041 nError1 = testFile.write( ppStrSeq[nCount], strlen( ppStrSeq[nCount] ), nCount_write );
4042 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4042 ) ) )
;
4043 }
4044
4045 nError1 = testFile.close();
4046 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4046 ) ) )
;
4047 }
4048
4049 void tearDown()
4050 {
4051 // remove the tempfile in $TEMP/tmpname.
4052 deleteTestFile( aTmpName6 );
4053 }
4054
4055 // test code.
4056 void readLine_001()
4057 {
4058 ::osl::File testFile( aTmpName6 );
4059
4060 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
4061 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4061 ) ) )
;
4062 nError1 = testFile.readLine( aSequence );
4063 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4063 ) ) )
;
4064 CPPUNIT_ASSERT_MESSAGE( "test for readLine function: read the first line of the file.",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( 0 == strncmp( ( const char * )aSequence.getArray
(), pBuffer_Char, 5 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( 0 == strncmp( ( const char * )aSequence.getArray(), pBuffer_Char, 5 ) )"
, "test for readLine function: read the first line of the file."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4066 ) ) )
4065 ( ::osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( 0 == strncmp( ( const char * )aSequence.getArray
(), pBuffer_Char, 5 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( 0 == strncmp( ( const char * )aSequence.getArray(), pBuffer_Char, 5 ) )"
, "test for readLine function: read the first line of the file."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4066 ) ) )
4066 ( 0 == strncmp( ( const char * )aSequence.getArray(), pBuffer_Char, 5 ) ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( 0 == strncmp( ( const char * )aSequence.getArray
(), pBuffer_Char, 5 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( 0 == strncmp( ( const char * )aSequence.getArray(), pBuffer_Char, 5 ) )"
, "test for readLine function: read the first line of the file."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4066 ) ) )
;
4067 }
4068
4069 void readLine_002()
4070 {
4071 ::osl::File testFile( aTmpName6 );
4072 sal_Bool bEOF = sal_False((sal_Bool)0);
4073 sal_Bool *pEOF = &bEOF;
4074
4075 nError1 = testFile.open( osl_File_OpenFlag_Read0x00000001L | osl_File_OpenFlag_Write0x00000002L );
4076 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4076 ) ) )
;
4077 for ( int nCount = 0; nCount < 3; nCount++ )
4078 {
4079 nError1 = testFile.readLine( aSequence );
4080 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4080 ) ) )
;
4081 }
4082 nError1 = testFile.isEndOfFile( pEOF );
4083 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4083 ) ) )
;
4084
4085 CPPUNIT_ASSERT_MESSAGE( "test for readLine function: read three lines of the file and check the file pointer moving.",( CppUnit::Asserter::failIf( !(*pEOF && ( 0 == strncmp
( ( const char * )aSequence.getArray(), &pBuffer_Char[26]
, 26 ) )), CppUnit::Message( "assertion failed", "Expression: "
"*pEOF && ( 0 == strncmp( ( const char * )aSequence.getArray(), &pBuffer_Char[26], 26 ) )"
, "test for readLine function: read three lines of the file and check the file pointer moving."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4087 ) ) )
4086 *pEOF &&( CppUnit::Asserter::failIf( !(*pEOF && ( 0 == strncmp
( ( const char * )aSequence.getArray(), &pBuffer_Char[26]
, 26 ) )), CppUnit::Message( "assertion failed", "Expression: "
"*pEOF && ( 0 == strncmp( ( const char * )aSequence.getArray(), &pBuffer_Char[26], 26 ) )"
, "test for readLine function: read three lines of the file and check the file pointer moving."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4087 ) ) )
4087 ( 0 == strncmp( ( const char * )aSequence.getArray(), &pBuffer_Char[26], 26 ) ) )( CppUnit::Asserter::failIf( !(*pEOF && ( 0 == strncmp
( ( const char * )aSequence.getArray(), &pBuffer_Char[26]
, 26 ) )), CppUnit::Message( "assertion failed", "Expression: "
"*pEOF && ( 0 == strncmp( ( const char * )aSequence.getArray(), &pBuffer_Char[26], 26 ) )"
, "test for readLine function: read three lines of the file and check the file pointer moving."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4087 ) ) )
;
4088 }
4089#ifdef UNX1
4090 void readLine_android()
4091 {
4092 static const char buffer[] =
4093 "Hello\n\r\n\a\n"
4094 "Fun=Badness\n"
4095 "Some=Somethingelse\n\r";
4096 sal_Int32 aHash = rtl_str_hashCode( buffer );
4097 for (size_t i = 0; i < sizeof (buffer); i += 7)
4098 {
4099 oslFileHandle pFile( 0 );
4100 CPPUNIT_ASSERT( osl_openMemoryAsFile( (void *)buffer,( CppUnit::Asserter::failIf( !(osl_openMemoryAsFile( (void *)
buffer, sizeof( buffer ) - i, &pFile ) == osl_File_E_None
), CppUnit::Message( "assertion failed", "Expression: " "osl_openMemoryAsFile( (void *)buffer, sizeof( buffer ) - i, &pFile ) == osl_File_E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4102 ) ) )
4101 sizeof( buffer ) - i, &pFile )( CppUnit::Asserter::failIf( !(osl_openMemoryAsFile( (void *)
buffer, sizeof( buffer ) - i, &pFile ) == osl_File_E_None
), CppUnit::Message( "assertion failed", "Expression: " "osl_openMemoryAsFile( (void *)buffer, sizeof( buffer ) - i, &pFile ) == osl_File_E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4102 ) ) )
4102 == osl_File_E_None )( CppUnit::Asserter::failIf( !(osl_openMemoryAsFile( (void *)
buffer, sizeof( buffer ) - i, &pFile ) == osl_File_E_None
), CppUnit::Message( "assertion failed", "Expression: " "osl_openMemoryAsFile( (void *)buffer, sizeof( buffer ) - i, &pFile ) == osl_File_E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4102 ) ) )
;
4103 for (;;)
4104 {
4105 sal_Sequence *pSequence( 0 );
4106 if (osl_readLine( pFile, &pSequence ) != osl_File_E_None)
4107 break;
4108 rtl_byte_sequence_release (pSequence);
4109 }
4110 CPPUNIT_ASSERT( osl_closeFile( pFile ) == osl_File_E_None )( CppUnit::Asserter::failIf( !(osl_closeFile( pFile ) == osl_File_E_None
), CppUnit::Message( "assertion failed", "Expression: " "osl_closeFile( pFile ) == osl_File_E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4110 ) ) )
;
4111 }
4112 CPPUNIT_ASSERT( aHash == rtl_str_hashCode( buffer ) )( CppUnit::Asserter::failIf( !(aHash == rtl_str_hashCode( buffer
)), CppUnit::Message( "assertion failed", "Expression: " "aHash == rtl_str_hashCode( buffer )"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4112 ) ) )
;
4113 }
4114#endif
4115 CPPUNIT_TEST_SUITE( readLine )public: typedef readLine TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(readLine) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4116 CPPUNIT_TEST( readLine_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "readLine_001"), &TestFixtureType
::readLine_001, context.makeFixture() ) ) )
;
4117 CPPUNIT_TEST( readLine_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "readLine_002"), &TestFixtureType
::readLine_002, context.makeFixture() ) ) )
;
4118#ifdef UNX1
4119 CPPUNIT_TEST( readLine_android )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "readLine_android"), &TestFixtureType
::readLine_android, context.makeFixture() ) ) )
;
4120#endif
4121 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4122 };// class readLine
4123
4124 //---------------------------------------------------------------------
4125 // testing the method
4126 // inline static RC copy( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
4127 //---------------------------------------------------------------------
4128 class copy : public CppUnit::TestFixture
4129 {
4130 ::osl::FileBase::RC nError1;
4131 sal_uInt64 nCount_write;
4132
4133 public:
4134 // initialization
4135 void setUp()
4136 {
4137 // create a tempfile in $TEMP/tmpdir/tmpname.
4138 createTestDirectory( aTmpName3 );
4139 createTestFile( aTmpName4 );
4140
4141 //write chars into the file.
4142 ::osl::File testFile( aTmpName4 );
4143
4144 nError1 = testFile.open( osl_File_OpenFlag_Write0x00000002L );
4145 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4145 ) ) )
;
4146 nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4147 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4147 ) ) )
;
4148 nError1 = testFile.close();
4149 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4149 ) ) )
;
4150 }
4151
4152 void tearDown()
4153 {
4154 // remove the tempfile in $TEMP/tmpdir/tmpname.
4155 deleteTestFile( aTmpName4 );
4156 deleteTestDirectory( aTmpName3 );
4157 }
4158
4159 // test code.
4160 void copy_001()
4161 {
4162 ::osl::File testFile( aTmpName6 );
4163
4164 //copy $TEMP/tmpdir/tmpname to $TEMP/tmpname.
4165 nError1 = ::osl::File::copy( aTmpName4, aTmpName6 );
4166 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4166 ) ) )
;
4167 //check
4168 nError1 = testFile.open( osl_File_OpenFlag_Create0x00000004L );
4169 deleteTestFile( aTmpName6 );
4170
4171 CPPUNIT_ASSERT_MESSAGE( "test for copy function: copy file to upper directory",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_EXIST == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_EXIST == nError1"
, "test for copy function: copy file to upper directory" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4172 ) ) )
4172 ::osl::FileBase::E_EXIST == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_EXIST == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_EXIST == nError1"
, "test for copy function: copy file to upper directory" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4172 ) ) )
;
4173 }
4174
4175 void copy_002()
4176 {
4177 //copy $TEMP/tmpdir/tmpname to $TEMP/tmpdir.
4178 nError1 = ::osl::File::copy( aTmpName4, aTmpName3 );
4179
4180 CPPUNIT_ASSERT_MESSAGE( "test for copy function: use directory as destination",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_ISDIR == nError1
) ||( ::osl::FileBase::E_ACCES == nError1 )), CppUnit::Message
( "assertion failed", "Expression: " "( ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase::E_ACCES == nError1 )"
, "test for copy function: use directory as destination" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4181 ) ) )
4181 ( ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase::E_ACCES == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_ISDIR == nError1
) ||( ::osl::FileBase::E_ACCES == nError1 )), CppUnit::Message
( "assertion failed", "Expression: " "( ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase::E_ACCES == nError1 )"
, "test for copy function: use directory as destination" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4181 ) ) )
;
4182 }
4183
4184 void copy_003()
4185 {
4186 //copy $TEMP/tmpdir/tmpname to $ROOT/tmpname.
4187 nError1 = ::osl::File::copy( aTmpName4, aTmpName7 );
4188#if defined (WNT )
4189 nError1 = ::osl::FileBase::E_ACCES; /// for Windows, c:/ is writtenable any way.
4190 deleteTestFile( aTmpName7);
4191#endif
4192 CPPUNIT_ASSERT_MESSAGE( "test for copy function: copy to an illigal place",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_ACCES == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_ACCES == nError1"
, "test for copy function: copy to an illigal place" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4193 ) ) )
4193 ::osl::FileBase::E_ACCES == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_ACCES == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_ACCES == nError1"
, "test for copy function: copy to an illigal place" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4193 ) ) )
;
4194 }
4195
4196 void copy_004()
4197 {
4198 //copy $TEMP/tmpname to $TEMP/tmpdir/tmpname.
4199 nError1 = ::osl::File::copy( aTmpName6, aTmpName4 );
4200
4201 CPPUNIT_ASSERT_MESSAGE( "test for copy function: copy a not exist file",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_NOENT == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_NOENT == nError1"
, "test for copy function: copy a not exist file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4202 ) ) )
4202 ::osl::FileBase::E_NOENT == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_NOENT == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_NOENT == nError1"
, "test for copy function: copy a not exist file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4202 ) ) )
;
4203 }
4204
4205 void copy_005()
4206 {
4207 //copy $TEMP/tmpname to $TEMP/system.path using system path.
4208 nError1 = ::osl::File::copy( aTmpName6, aSysPath1 );
4209
4210 CPPUNIT_ASSERT_MESSAGE( "test for copy function: copy a file using system file path",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_INVAL == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_INVAL == nError1"
, "test for copy function: copy a file using system file path"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4211 ) ) )
4211 ::osl::FileBase::E_INVAL == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_INVAL == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_INVAL == nError1"
, "test for copy function: copy a file using system file path"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4211 ) ) )
;
4212 }
4213 void copy_006()
4214 {
4215 createTestFile( aTmpName6 );
4216 File tmpFile( aTmpName6 );
4217 FileBase::RC err = tmpFile.open( osl_File_OpenFlag_Write0x00000002L | osl_File_OpenFlag_Read0x00000001L );
4218 (void)err;
4219 tmpFile.setSize( 200 );
4220 tmpFile.close();
4221 //copy to new path
4222 nError1 = ::osl::File::copy( aTmpName6, aTmpName4 );
4223 CPPUNIT_ASSERT( nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4223 ) ) )
;
4224
4225 //check if is the new file
4226 File newFile( aTmpName4 );
4227 newFile.open( osl_File_OpenFlag_Write0x00000002L | osl_File_OpenFlag_Read0x00000001L );
4228 nError1 = newFile.setPos( osl_Pos_End3, 0 );
4229 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4229 ) ) )
;
4230 sal_uInt64 nFilePointer;
4231 nError1 = newFile.getPos( nFilePointer );
4232 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4232 ) ) )
;
4233 newFile.close();
4234 deleteTestFile( aTmpName6 );
4235 CPPUNIT_ASSERT_MESSAGE( "test for copy function: the dest file exist",( CppUnit::Asserter::failIf( !(nFilePointer == 200), CppUnit::
Message( "assertion failed", "Expression: " "nFilePointer == 200"
, "test for copy function: the dest file exist" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 4236
) ) )
4236 nFilePointer == 200 )( CppUnit::Asserter::failIf( !(nFilePointer == 200), CppUnit::
Message( "assertion failed", "Expression: " "nFilePointer == 200"
, "test for copy function: the dest file exist" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 4236
) ) )
;
4237 }
4238 //copyLink has not been impletmented yet
4239 void copy_007()
4240 {
4241#if ( defined UNX1 )
4242
4243 CPPUNIT_ASSERT_MESSAGE( "test for copy function: source file is link file",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_INVAL == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_INVAL == nError1"
, "test for copy function: source file is link file" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4244 ) ) )
4244 ::osl::FileBase::E_INVAL == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_INVAL == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_INVAL == nError1"
, "test for copy function: source file is link file" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4244 ) ) )
;
4245#endif
4246 }
4247
4248 CPPUNIT_TEST_SUITE( copy )public: typedef copy TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(copy) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4249 CPPUNIT_TEST( copy_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "copy_001"), &TestFixtureType
::copy_001, context.makeFixture() ) ) )
;
4250 CPPUNIT_TEST( copy_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "copy_002"), &TestFixtureType
::copy_002, context.makeFixture() ) ) )
;
4251 CPPUNIT_TEST( copy_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "copy_003"), &TestFixtureType
::copy_003, context.makeFixture() ) ) )
;
4252 CPPUNIT_TEST( copy_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "copy_004"), &TestFixtureType
::copy_004, context.makeFixture() ) ) )
;
4253 CPPUNIT_TEST( copy_005 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "copy_005"), &TestFixtureType
::copy_005, context.makeFixture() ) ) )
;
4254 CPPUNIT_TEST( copy_006 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "copy_006"), &TestFixtureType
::copy_006, context.makeFixture() ) ) )
;
4255 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4256 };// class copy
4257
4258 //---------------------------------------------------------------------
4259 // testing the method
4260 // inline static RC move( const ::rtl::OUString& ustrSourceFileURL, const ::rtl::OUString& ustrDestFileURL )
4261 //---------------------------------------------------------------------
4262 class move : public CppUnit::TestFixture
4263 {
4264 ::osl::FileBase::RC nError1, nError2;
4265 sal_uInt64 nCount_write;
4266
4267 public:
4268 // initialization
4269 void setUp()
4270 {
4271 // create a tempfile in $TEMP/tmpdir/tmpname.
4272 createTestDirectory( aTmpName3 );
4273 createTestFile( aTmpName4 );
4274
4275 //write chars into the file.
4276 ::osl::File testFile( aTmpName4 );
4277
4278 nError1 = testFile.open( osl_File_OpenFlag_Write0x00000002L );
4279 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4279 ) ) )
;
4280 nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4281 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4281 ) ) )
;
4282 nError1 = testFile.close();
4283 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4283 ) ) )
;
4284 }
4285
4286 void tearDown()
4287 {
4288 // remove the tempfile in $TEMP/tmpdir/tmpname.
4289 deleteTestFile( aTmpName4 );
4290 deleteTestDirectory( aTmpName3 );
4291 }
4292
4293 // test code.
4294 void move_001()
4295 {
4296 //rename $TEMP/tmpdir/tmpname to $TEMP/canonical.name.
4297 nError1 = ::osl::File::move( aTmpName4, aCanURL1 );
4298 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4298 ) ) )
;
4299 //check
4300 ::osl::File testFile( aCanURL1 );
4301 nError2 = testFile.open( osl_File_OpenFlag_Create0x00000004L );
4302 deleteTestFile( aCanURL1 );
4303
4304 CPPUNIT_ASSERT_MESSAGE( "test for move function: rename file to another directory",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_EXIST == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_EXIST == nError2"
, "test for move function: rename file to another directory" )
, CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4305 ) ) )
4305 ::osl::FileBase::E_EXIST == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_EXIST == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_EXIST == nError2"
, "test for move function: rename file to another directory" )
, CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4305 ) ) )
;
4306 }
4307
4308 void move_002()
4309 {
4310 //move $TEMP/tmpdir/tmpname to $TEMP/tmpdir.
4311 nError1 = ::osl::File::move( aTmpName4, aTmpName3 );
4312 //returned ::osl::FileBase::E_ACCES on WNT
4313 CPPUNIT_ASSERT_MESSAGE( "test for move function: use directory as destination",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_ACCES == nError1
|| ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase
::E_EXIST == nError1 )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_ACCES == nError1 || ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase::E_EXIST == nError1 )"
, "test for move function: use directory as destination" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4314 ) ) )
4314 ( ::osl::FileBase::E_ACCES == nError1 || ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase::E_EXIST == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_ACCES == nError1
|| ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase
::E_EXIST == nError1 )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_ACCES == nError1 || ::osl::FileBase::E_ISDIR == nError1 ) ||( ::osl::FileBase::E_EXIST == nError1 )"
, "test for move function: use directory as destination" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4314 ) ) )
;
4315 }
4316
4317 void move_003()
4318 {
4319 //move $TEMP/tmpdir/tmpname to $ROOT/tmpname.
4320 nError1 = ::osl::File::move( aTmpName4, aTmpName7 );
4321#if defined (WNT )
4322 nError1 = ::osl::FileBase::E_ACCES; /// for Windows, c:/ is writtenable any way.
4323 deleteTestFile( aTmpName7);
4324#endif
4325
4326 CPPUNIT_ASSERT_MESSAGE( "test for move function: move to an illigal place",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_ACCES == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_ACCES == nError1"
, "test for move function: move to an illigal place" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4327 ) ) )
4327 ::osl::FileBase::E_ACCES == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_ACCES == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_ACCES == nError1"
, "test for move function: move to an illigal place" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4327 ) ) )
;
4328 }
4329
4330 void move_004()
4331 {
4332 //move $TEMP/tmpname to $TEMP/tmpdir/tmpname.
4333 nError1 = ::osl::File::move( aTmpName6, aTmpName4 );
4334
4335 CPPUNIT_ASSERT_MESSAGE( "test for move function: move a not exist file",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_NOENT == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_NOENT == nError1"
, "test for move function: move a not exist file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4336 ) ) )
4336 ::osl::FileBase::E_NOENT == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_NOENT == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_NOENT == nError1"
, "test for move function: move a not exist file" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4336 ) ) )
;
4337 }
4338
4339 void move_005()
4340 {
4341 //move $TEMP/tmpname to $TEMP/system.path using system path.
4342 nError1 = ::osl::File::move( aTmpName6, aSysPath1 );
4343
4344 CPPUNIT_ASSERT_MESSAGE( "test for move function: move a file using system file",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_INVAL == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_INVAL == nError1"
, "test for move function: move a file using system file" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4345 ) ) )
4345 ::osl::FileBase::E_INVAL == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_INVAL == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_INVAL == nError1"
, "test for move function: move a file using system file" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4345 ) ) )
;
4346 }
4347
4348 void move_006()
4349 {
4350 //move directory $TEMP/tmpname to $TEMP/tmpdir/tmpname.
4351 createTestDirectory( aTmpName6 );
4352 nError1 = ::osl::File::move( aTmpName6, aTmpName4 );
4353 //move file $TEMP/tmpdir/tmpname to $TEMP/tmpname
4354 nError2 = ::osl::File::move( aTmpName4, aTmpName6 );
4355 deleteTestDirectory( aTmpName6 );
4356#if defined ( WNT )
4357 deleteTestDirectory( aTmpName4 );// in Windows, it can be moved!!!!! this is only for not influence the following test.
4358 deleteTestFile( aTmpName6 );
4359 nError1 = ::osl::FileBase::E_NOTDIR;
4360 nError2 = ::osl::FileBase::E_ISDIR;
4361#endif
4362 CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to an exist file with same name, did not pass in (W32)",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_NOTDIR == nError1
&& ::osl::FileBase::E_ISDIR == nError2), CppUnit::Message
( "assertion failed", "Expression: " "::osl::FileBase::E_NOTDIR == nError1 && ::osl::FileBase::E_ISDIR == nError2"
, "test for move function: move a directory to an exist file with same name, did not pass in (W32)"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4363 ) ) )
4363 ::osl::FileBase::E_NOTDIR == nError1 && ::osl::FileBase::E_ISDIR == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_NOTDIR == nError1
&& ::osl::FileBase::E_ISDIR == nError2), CppUnit::Message
( "assertion failed", "Expression: " "::osl::FileBase::E_NOTDIR == nError1 && ::osl::FileBase::E_ISDIR == nError2"
, "test for move function: move a directory to an exist file with same name, did not pass in (W32)"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4363 ) ) )
;
4364 }
4365
4366 void move_007()
4367 {
4368 //create directory $TEMP/tmpname.
4369 createTestDirectory( aTmpName6 );
4370 //move directory $TEMP/tmpdir to $TEMP/tmpname/tmpdir
4371 nError1 = ::osl::File::move( aTmpName3, aTmpName8 );
4372 //check
4373 nError2 = ::osl::Directory::create( aTmpName8 );
4374 ::osl::File::move( aTmpName8, aTmpName3 );
4375 deleteTestDirectory( aTmpName6 );
4376
4377 CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to an exist file with same name",( CppUnit::Asserter::failIf( !((::osl::FileBase::E_None == nError1
) && (::osl::FileBase::E_EXIST == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "(::osl::FileBase::E_None == nError1 ) && (::osl::FileBase::E_EXIST == nError2 )"
, "test for move function: move a directory to an exist file with same name"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4379 ) ) )
4378 (::osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !((::osl::FileBase::E_None == nError1
) && (::osl::FileBase::E_EXIST == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "(::osl::FileBase::E_None == nError1 ) && (::osl::FileBase::E_EXIST == nError2 )"
, "test for move function: move a directory to an exist file with same name"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4379 ) ) )
4379 (::osl::FileBase::E_EXIST == nError2 ) )( CppUnit::Asserter::failIf( !((::osl::FileBase::E_None == nError1
) && (::osl::FileBase::E_EXIST == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "(::osl::FileBase::E_None == nError1 ) && (::osl::FileBase::E_EXIST == nError2 )"
, "test for move function: move a directory to an exist file with same name"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4379 ) ) )
;
4380 }
4381 // oldpath and newpath are not on the same filesystem.EXDEV,no such error no on Solaris, only on linux
4382 void move_008()
4383 {
4384 CPPUNIT_ASSERT_MESSAGE( "oldpath and newpath are not on the same filesystem, should error returns",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "oldpath and newpath are not on the same filesystem, should error returns"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4385 ) ) )
4385 ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "oldpath and newpath are not on the same filesystem, should error returns"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4385 ) ) )
;
4386 }
4387 //bugid# 115420, after the bug fix, add the case
4388 void move_009()
4389 {
4390 //create directory $TEMP/tmpname.
4391 createTestDirectory( aTmpName6 );
4392 //create directory $TEMP/tmpname/tmpdir
4393 createTestDirectory( aTmpName8 );
4394 //move directory $TEMP/tmpname to $TEMP/tmpname/tmpdir/tmpname
4395 rtl::OUString newName = aTmpName8 + OUString("/tmpname");
4396 nError1 = ::osl::File::move( aTmpName3, newName );
4397 //deleteTestDirectory( newName + OUString("/tmpname") );
4398 //deleteTestDirectory( newName );
4399 deleteTestDirectory( aTmpName8 );
4400 deleteTestDirectory( aTmpName6 );
4401 CPPUNIT_ASSERT_MESSAGE( "test for move function: move a directory to it's subdirectory",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None != nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None != nError1"
, "test for move function: move a directory to it's subdirectory"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4402 ) ) )
4402 ::osl::FileBase::E_None != nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None != nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None != nError1"
, "test for move function: move a directory to it's subdirectory"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4402 ) ) )
;
4403 }
4404
4405 CPPUNIT_TEST_SUITE( move )public: typedef move TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(move) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4406 CPPUNIT_TEST( move_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "move_001"), &TestFixtureType
::move_001, context.makeFixture() ) ) )
;
4407 CPPUNIT_TEST( move_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "move_002"), &TestFixtureType
::move_002, context.makeFixture() ) ) )
;
4408 CPPUNIT_TEST( move_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "move_003"), &TestFixtureType
::move_003, context.makeFixture() ) ) )
;
4409 CPPUNIT_TEST( move_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "move_004"), &TestFixtureType
::move_004, context.makeFixture() ) ) )
;
4410 CPPUNIT_TEST( move_005 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "move_005"), &TestFixtureType
::move_005, context.makeFixture() ) ) )
;
4411 CPPUNIT_TEST( move_006 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "move_006"), &TestFixtureType
::move_006, context.makeFixture() ) ) )
;
4412 CPPUNIT_TEST( move_007 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "move_007"), &TestFixtureType
::move_007, context.makeFixture() ) ) )
;
4413 // CPPUNIT_TEST( move_008 );
4414 //CPPUNIT_TEST( move_009 );
4415 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4416 };// class move
4417
4418
4419 //---------------------------------------------------------------------
4420 // testing the method
4421 // inline static RC remove( const ::rtl::OUString& ustrFileURL )
4422 //---------------------------------------------------------------------
4423 class remove : public CppUnit::TestFixture
4424 {
4425 ::osl::FileBase::RC nError1, nError2;
4426 sal_uInt64 nCount_write;
4427
4428 public:
4429 // initialization
4430 void setUp()
4431 {
4432 // create a tempfile in $TEMP/tmpdir/tmpname.
4433 createTestDirectory( aTmpName3 );
4434 createTestFile( aTmpName4 );
4435
4436 //write chars into the file.
4437 ::osl::File testFile( aTmpName4 );
4438
4439 nError1 = testFile.open( osl_File_OpenFlag_Write0x00000002L );
4440 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4440 ) ) )
;
4441 nError1 = testFile.write( pBuffer_Char, sizeof( pBuffer_Char ), nCount_write );
4442 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4442 ) ) )
;
4443 nError1 = testFile.close();
4444 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4444 ) ) )
;
4445 }
4446
4447 void tearDown()
4448 {
4449 // remove the tempfile in $TEMP/tmpdir/tmpname.
4450 deleteTestFile( aTmpName4 );
4451 deleteTestDirectory( aTmpName3 );
4452 }
4453
4454 // test code.
4455 void remove_001()
4456 {
4457 //remove $TEMP/tmpdir/tmpname.
4458 nError1 = ::osl::File::remove( aTmpName4 );
4459 //check
4460 ::osl::File testFile( aTmpName4 );
4461 nError2 = testFile.open( osl_File_OpenFlag_Create0x00000004L );
4462
4463 CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a file",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_EXIST != nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_EXIST != nError2 )"
, "test for remove function: remove a file" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 4465
) ) )
4464 ( ::osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_EXIST != nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_EXIST != nError2 )"
, "test for remove function: remove a file" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 4465
) ) )
4465 ( ::osl::FileBase::E_EXIST != nError2 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_EXIST != nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_EXIST != nError2 )"
, "test for remove function: remove a file" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 4465
) ) )
;
4466 }
4467
4468 void remove_002()
4469 {
4470 //remove $TEMP/tmpname.
4471 nError1 = ::osl::File::remove( aTmpName6 );
4472
4473 CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a file not exist",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOENT == nError1 )"
, "test for remove function: remove a file not exist" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4474 ) ) )
4474 ( ::osl::FileBase::E_NOENT == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOENT == nError1 )"
, "test for remove function: remove a file not exist" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4474 ) ) )
;
4475 }
4476
4477 void remove_003()
4478 {
4479 //remove $TEMP/system/path.
4480 nError1 = ::osl::File::remove( aSysPath2 );
4481
4482 CPPUNIT_ASSERT_MESSAGE( "test for remove function: removing a file not using full qualified URL",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError1 )"
, "test for remove function: removing a file not using full qualified URL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4483 ) ) )
4483 ( ::osl::FileBase::E_INVAL == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError1 )"
, "test for remove function: removing a file not using full qualified URL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4483 ) ) )
;
4484 }
4485
4486 void remove_004()
4487 {
4488 //remove $TEMP/tmpdir.
4489 nError1 = ::osl::File::remove( aTmpName3 );
4490
4491 CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a directory",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_ISDIR == nError1
) || ( ::osl::FileBase::E_ACCES == nError1 )), CppUnit::Message
( "assertion failed", "Expression: " "( ::osl::FileBase::E_ISDIR == nError1 ) || ( ::osl::FileBase::E_ACCES == nError1 )"
, "test for remove function: remove a directory" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4492 ) ) )
4492 ( ::osl::FileBase::E_ISDIR == nError1 ) || ( ::osl::FileBase::E_ACCES == nError1 ))( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_ISDIR == nError1
) || ( ::osl::FileBase::E_ACCES == nError1 )), CppUnit::Message
( "assertion failed", "Expression: " "( ::osl::FileBase::E_ISDIR == nError1 ) || ( ::osl::FileBase::E_ACCES == nError1 )"
, "test for remove function: remove a directory" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4492 ) ) )
;
4493 }
4494
4495 CPPUNIT_TEST_SUITE( remove )public: typedef remove TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(remove) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4496 CPPUNIT_TEST( remove_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "remove_001"), &TestFixtureType
::remove_001, context.makeFixture() ) ) )
;
4497 CPPUNIT_TEST( remove_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "remove_002"), &TestFixtureType
::remove_002, context.makeFixture() ) ) )
;
4498 CPPUNIT_TEST( remove_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "remove_003"), &TestFixtureType
::remove_003, context.makeFixture() ) ) )
;
4499 CPPUNIT_TEST( remove_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "remove_004"), &TestFixtureType
::remove_004, context.makeFixture() ) ) )
;
4500 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4501 };// class remove
4502
4503
4504 //---------------------------------------------------------------------
4505 // testing the method
4506 // inline static RC setAttributes( const ::rtl::OUString& ustrFileURL, sal_uInt64 uAttributes )
4507 //---------------------------------------------------------------------
4508 class setAttributes : public CppUnit::TestFixture
4509 {
4510 ::osl::FileBase::RC nError1, nError2;
4511 ::osl::DirectoryItem rItem, rItem_hidden;
4512
4513 public:
4514 // initialization
4515 void setUp()
4516 {
4517 // create a tempfile in $TEMP/tmpdir/tmpname.
4518 createTestFile( aTmpName6 );
4519 }
4520
4521 void tearDown()
4522 {
4523 // remove the tempfile in $TEMP/tmpdir/tmpname.
4524 deleteTestFile( aTmpName6 );
4525 }
4526
4527 // test code.
4528 void setAttributes_001()
4529 {
4530 //on windows, only can set 2 attributes: osl_File_Attribute_ReadOnly, osl_File_Attribute_Hidden
4531#ifdef UNX1
4532 //set the file to readonly
4533 nError2 = ::osl::File::setAttributes( aTmpName6, osl_File_Attribute_ReadOnly0x00000001 | osl_File_Attribute_GrpRead0x00000040 | osl_File_Attribute_OwnRead0x00000200 | osl_File_Attribute_OthRead0x00001000 );
4534 CPPUNIT_ASSERT( nError2 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError2 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError2 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4534 ) ) )
;
4535 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4536 CPPUNIT_ASSERT( nError1 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4536 ) ) )
;
4537 //get the file attributes
4538 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Attributes0x00000002 );
4539 nError1 = rItem.getFileStatus( rFileStatus );
4540 CPPUNIT_ASSERT( nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4540 ) ) )
;
4541
4542 CPPUNIT_ASSERT_MESSAGE( "test for setAttributes function: set file attributes and get it to verify.",( CppUnit::Asserter::failIf( !(( 0x00000001 | 0x00000040 | 0x00000200
| 0x00001000 ) == rFileStatus.getAttributes()), CppUnit::Message
( "assertion failed", "Expression: " "( osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead ) == rFileStatus.getAttributes()"
, "test for setAttributes function: set file attributes and get it to verify."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4544 ) ) )
4543 ( osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead ) ==( CppUnit::Asserter::failIf( !(( 0x00000001 | 0x00000040 | 0x00000200
| 0x00001000 ) == rFileStatus.getAttributes()), CppUnit::Message
( "assertion failed", "Expression: " "( osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead ) == rFileStatus.getAttributes()"
, "test for setAttributes function: set file attributes and get it to verify."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4544 ) ) )
4544 rFileStatus.getAttributes() )( CppUnit::Asserter::failIf( !(( 0x00000001 | 0x00000040 | 0x00000200
| 0x00001000 ) == rFileStatus.getAttributes()), CppUnit::Message
( "assertion failed", "Expression: " "( osl_File_Attribute_ReadOnly | osl_File_Attribute_GrpRead | osl_File_Attribute_OwnRead | osl_File_Attribute_OthRead ) == rFileStatus.getAttributes()"
, "test for setAttributes function: set file attributes and get it to verify."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4544 ) ) )
;
4545#else
4546 //please see GetFileAttributes
4547 nError2 = ::osl::File::setAttributes( aTmpName6, osl_File_Attribute_ReadOnly0x00000001 );
4548 CPPUNIT_ASSERT( nError2 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError2 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError2 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4548 ) ) )
;
4549 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4550 CPPUNIT_ASSERT( nError1 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4550 ) ) )
;
4551 //get the file attributes
4552 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Attributes0x00000002 );
4553 nError1 = rItem.getFileStatus( rFileStatus );
4554 CPPUNIT_ASSERT( nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4554 ) ) )
;
4555 //here the file has 2 Attributes: FILE_ATTRIBUTE_READONLY and FILE_ATTRIBUTE_NORMAL,
4556 // but FILE_ATTRIBUTE_NORMAL is valid only if used alone, so this is maybe a bug
4557 /*::rtl::OString aString = ::rtl::OUStringToOString( aTmpName6, RTL_TEXTENCODING_ASCII_US );
4558 DWORD dwFileAttributes = GetFileAttributes( aString.getStr() );
4559 if (dwFileAttributes & FILE_ATTRIBUTE_NORMAL)
4560 printf("has normal attribute");
4561 if (dwFileAttributes & FILE_ATTRIBUTE_READONLY)
4562 printf("has readonly attribute");
4563 */
4564 CPPUNIT_ASSERT_MESSAGE( "test for setAttributes function: set file attributes READONLY and get it to verify.",( CppUnit::Asserter::failIf( !((0x00000001 & rFileStatus.
getAttributes()) != 0), CppUnit::Message( "assertion failed",
"Expression: " "(osl_File_Attribute_ReadOnly & rFileStatus.getAttributes()) != 0"
, "test for setAttributes function: set file attributes READONLY and get it to verify."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4565 ) ) )
4565 (osl_File_Attribute_ReadOnly & rFileStatus.getAttributes()) != 0 )( CppUnit::Asserter::failIf( !((0x00000001 & rFileStatus.
getAttributes()) != 0), CppUnit::Message( "assertion failed",
"Expression: " "(osl_File_Attribute_ReadOnly & rFileStatus.getAttributes()) != 0"
, "test for setAttributes function: set file attributes READONLY and get it to verify."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4565 ) ) )
;
4566#endif
4567 }
4568 void setAttributes_002()
4569 {
4570 //on UNX, can not set hidden attribute to file, rename file can set the attribute
4571#ifdef WNT
4572 //set the file to hidden
4573 nError2 = ::osl::File::setAttributes( aTmpName6, osl_File_Attribute_Hidden0x00000002);
4574
4575 CPPUNIT_ASSERT( nError2 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError2 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError2 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4575 ) ) )
;
4576 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4577 CPPUNIT_ASSERT( nError1 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4577 ) ) )
;
4578 //get the file attributes
4579 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_Attributes0x00000002 );
4580 nError1 = rItem.getFileStatus( rFileStatus );
4581 CPPUNIT_ASSERT( nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4581 ) ) )
;
4582
4583 CPPUNIT_ASSERT_MESSAGE( "test for setAttributes function: set file attributes and get it to verify.",( CppUnit::Asserter::failIf( !((0x00000002 & rFileStatus.
getAttributes()) != 0), CppUnit::Message( "assertion failed",
"Expression: " "(osl_File_Attribute_Hidden & rFileStatus.getAttributes()) != 0"
, "test for setAttributes function: set file attributes and get it to verify."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4584 ) ) )
4584 (osl_File_Attribute_Hidden & rFileStatus.getAttributes()) != 0 )( CppUnit::Asserter::failIf( !((0x00000002 & rFileStatus.
getAttributes()) != 0), CppUnit::Message( "assertion failed",
"Expression: " "(osl_File_Attribute_Hidden & rFileStatus.getAttributes()) != 0"
, "test for setAttributes function: set file attributes and get it to verify."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4584 ) ) )
;
4585#endif
4586 }
4587
4588 CPPUNIT_TEST_SUITE( setAttributes )public: typedef setAttributes TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(setAttributes) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
4589 CPPUNIT_TEST( setAttributes_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "setAttributes_001"), &TestFixtureType
::setAttributes_001, context.makeFixture() ) ) )
;
4590 CPPUNIT_TEST( setAttributes_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "setAttributes_002"), &TestFixtureType
::setAttributes_002, context.makeFixture() ) ) )
;
4591 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4592 };// class setAttributes
4593
4594
4595 //---------------------------------------------------------------------
4596 // testing the method
4597 // inline static RC setTime(
4598 // const ::rtl::OUString& ustrFileURL,
4599 // const TimeValue& rCreationTime,
4600 // const TimeValue& rLastAccessTime,
4601 // const TimeValue& rLastWriteTime )
4602 //---------------------------------------------------------------------
4603 class setTime : public CppUnit::TestFixture
4604 {
4605 ::osl::FileBase::RC nError1, nError2;
4606 ::osl::DirectoryItem rItem;
4607
4608 public:
4609 // initialization
4610 void setUp()
4611 {
4612 // create a tempfile in $TEMP/tmpdir/tmpname.
4613 createTestFile( aTmpName6 );
4614 }
4615
4616 void tearDown()
4617 {
4618 // remove the tempfile in $TEMP/tmpdir/tmpname.
4619 deleteTestFile( aTmpName6 );
4620 }
4621
4622 // test code.
4623 void setTime_001()
4624 {
4625 TimeValue *pTV_current = NULL__null;
4626 CPPUNIT_ASSERT( ( pTV_current = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL )( CppUnit::Asserter::failIf( !(( pTV_current = ( TimeValue* )
malloc( sizeof( TimeValue ) ) ) != __null), CppUnit::Message(
"assertion failed", "Expression: " "( pTV_current = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4626 ) ) )
;
4627 TimeValue *pTV_creation = NULL__null;
4628 CPPUNIT_ASSERT( ( pTV_creation = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL )( CppUnit::Asserter::failIf( !(( pTV_creation = ( TimeValue* )
malloc( sizeof( TimeValue ) ) ) != __null), CppUnit::Message(
"assertion failed", "Expression: " "( pTV_creation = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4628 ) ) )
;
4629 TimeValue *pTV_access = NULL__null;
4630 CPPUNIT_ASSERT( ( pTV_access = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL )( CppUnit::Asserter::failIf( !(( pTV_access = ( TimeValue* )malloc
( sizeof( TimeValue ) ) ) != __null), CppUnit::Message( "assertion failed"
, "Expression: " "( pTV_access = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4630 ) ) )
;
4631 TimeValue *pTV_modify = NULL__null;
4632 CPPUNIT_ASSERT( ( pTV_modify = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL )( CppUnit::Asserter::failIf( !(( pTV_modify = ( TimeValue* )malloc
( sizeof( TimeValue ) ) ) != __null), CppUnit::Message( "assertion failed"
, "Expression: " "( pTV_modify = ( TimeValue* )malloc( sizeof( TimeValue ) ) ) != NULL"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4632 ) ) )
;
4633
4634 //get current time
4635 sal_Bool bOk = osl_getSystemTime( pTV_current );
4636 CPPUNIT_ASSERT( sal_True == bOk )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == bOk), CppUnit
::Message( "assertion failed", "Expression: " "sal_True == bOk"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4636 ) ) )
;
4637
4638 //set the file time
4639 nError2 = ::osl::File::setTime( aTmpName6, *pTV_current, *pTV_current, *pTV_current );
4640 CPPUNIT_ASSERT_MESSAGE( errorToStr( nError2 ).getStr(), nError2 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError2 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError2 == FileBase::E_None"
, errorToStr( nError2 ).getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4640 ) ) )
;
4641
4642 //get the file access time, creation time, modify time
4643 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4644 CPPUNIT_ASSERT_MESSAGE( errorToStr( nError1 ).getStr(), nError1 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
, errorToStr( nError1 ).getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4644 ) ) )
;
4645
4646 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_AccessTime0x00000020 );
4647 nError1 = rItem.getFileStatus( rFileStatus );
4648 CPPUNIT_ASSERT_MESSAGE( errorToStr( nError1 ).getStr(),nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
, errorToStr( nError1 ).getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4648 ) ) )
;
4649 *pTV_access = rFileStatus.getAccessTime();
4650
4651 ::osl::FileStatus rFileStatus1( osl_FileStatus_Mask_CreationTime0x00000010 );
4652 nError1 = rItem.getFileStatus( rFileStatus1 );
4653 CPPUNIT_ASSERT_MESSAGE( errorToStr( nError1 ).getStr(), nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
, errorToStr( nError1 ).getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4653 ) ) )
;
4654 *pTV_creation = rFileStatus1.getCreationTime();
4655
4656 ::osl::FileStatus rFileStatus2( osl_FileStatus_Mask_ModifyTime0x00000040 );
4657 nError1 = rItem.getFileStatus( rFileStatus2 );
4658 CPPUNIT_ASSERT_MESSAGE( errorToStr( nError1 ).getStr(), nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
, errorToStr( nError1 ).getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4658 ) ) )
;
4659 *pTV_modify = rFileStatus2.getModifyTime();
4660
4661 CPPUNIT_ASSERT_MESSAGE( "test for setTime function: set access time then get it. time precision is still a problem for it cut off the nanosec.",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == t_compareTime
( pTV_access, pTV_current, 2000 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == t_compareTime( pTV_access, pTV_current, delta )"
, "test for setTime function: set access time then get it. time precision is still a problem for it cut off the nanosec."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4662 ) ) )
4662 sal_True == t_compareTime( pTV_access, pTV_current, delta ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == t_compareTime
( pTV_access, pTV_current, 2000 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == t_compareTime( pTV_access, pTV_current, delta )"
, "test for setTime function: set access time then get it. time precision is still a problem for it cut off the nanosec."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4662 ) ) )
;
4663#if defined ( WNT )
4664 //Unfortunately there is no way to get the creation time of a file under Unix (its a Windows only feature).
4665 //That means the flag osl_FileStatus_Mask_CreationTime should be deprecated under Unix.
4666 CPPUNIT_ASSERT_MESSAGE( "test for setTime function: set creation time then get it. ",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == t_compareTime
( pTV_creation, pTV_current, 2000 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == t_compareTime( pTV_creation, pTV_current, delta )"
, "test for setTime function: set creation time then get it. "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4667 ) ) )
4667 sal_True == t_compareTime( pTV_creation, pTV_current, delta ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == t_compareTime
( pTV_creation, pTV_current, 2000 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == t_compareTime( pTV_creation, pTV_current, delta )"
, "test for setTime function: set creation time then get it. "
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4667 ) ) )
;
4668#endif
4669 CPPUNIT_ASSERT_MESSAGE( "test for setTime function: set modify time then get it. ",( CppUnit::Asserter::failIf( !(((sal_Bool)1) == t_compareTime
( pTV_modify, pTV_current, 2000 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == t_compareTime( pTV_modify, pTV_current, delta )"
, "test for setTime function: set modify time then get it. " )
, CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4670 ) ) )
4670 sal_True == t_compareTime( pTV_modify, pTV_current, delta ) )( CppUnit::Asserter::failIf( !(((sal_Bool)1) == t_compareTime
( pTV_modify, pTV_current, 2000 )), CppUnit::Message( "assertion failed"
, "Expression: " "sal_True == t_compareTime( pTV_modify, pTV_current, delta )"
, "test for setTime function: set modify time then get it. " )
, CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4670 ) ) )
;
4671 free( pTV_current );
4672 free( pTV_creation );
4673 free( pTV_access );
4674 free( pTV_modify );
4675 }
4676
4677 CPPUNIT_TEST_SUITE( setTime )public: typedef setTime TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(setTime) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4678 CPPUNIT_TEST( setTime_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "setTime_001"), &TestFixtureType
::setTime_001, context.makeFixture() ) ) )
;
4679 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4680 };// class setTime
4681
4682 //---------------------------------------------------------------------
4683 // testing the method
4684 // inline static RC sync()
4685 //---------------------------------------------------------------------
4686 class sync : public CppUnit::TestFixture
4687 {
4688 ::osl::FileBase::RC nError1, nError2;
4689 ::osl::DirectoryItem rItem;
4690
4691 public:
4692 // initialization
4693 void setUp()
4694 {
4695 // create a tempfile in $TEMP/tmpdir/tmpname.
4696 createTestFile( aTmpName6 );
4697
4698 }
4699
4700 void tearDown()
4701 {
4702 // remove the tempfile in $TEMP/tmpdir/tmpname.
4703 deleteTestFile( aTmpName6 );
4704 }
4705
4706 // test case: if The file is located on a read only file system.
4707 void sync_001()
4708 {
4709#ifdef UNX1
4710 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4711 CPPUNIT_ASSERT( nError1 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4711 ) ) )
;
4712
4713 File tmp_file( aTmpName6 );
4714 FileBase::RC err = tmp_file.open(osl_File_OpenFlag_Write0x00000002L );
4715
4716 CPPUNIT_ASSERT_MESSAGE("File open failed", err == FileBase::E_None)( CppUnit::Asserter::failIf( !(err == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "err == FileBase::E_None"
, "File open failed" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4716 ) ) )
;
4717
4718 char buffer[50000];
4719 sal_uInt64 written = 0;
4720 nError1 = tmp_file.write((void*)buffer, sizeof(buffer), written);
4721 CPPUNIT_ASSERT_MESSAGE("write failed!", nError1 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
, "write failed!" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4721 ) ) )
;
4722
4723 //set the file to readonly
4724 nError2 = ::osl::File::setAttributes( aTmpName6, osl_File_Attribute_ReadOnly0x00000001 | osl_File_Attribute_GrpRead0x00000040 | osl_File_Attribute_OwnRead0x00000200 | osl_File_Attribute_OthRead0x00001000 );
4725 CPPUNIT_ASSERT( nError2 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError2 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError2 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4725 ) ) )
;
4726
4727 nError2 = tmp_file.sync();
4728
4729 CPPUNIT_ASSERT_MESSAGE("can not sync to readonly file!", nError2 == FileBase::E_None)( CppUnit::Asserter::failIf( !(nError2 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError2 == FileBase::E_None"
, "can not sync to readonly file!" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4729 ) ) )
;
4730
4731 tmp_file.close();
4732#endif
4733 }
4734 //test case:no enough space, how to create such case???see test_cpy_wrt_file.cxx::test_osl_writeFile
4735
4736
4737
4738 CPPUNIT_TEST_SUITE( sync )public: typedef sync TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(sync) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4739 CPPUNIT_TEST( sync_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "sync_001"), &TestFixtureType
::sync_001, context.makeFixture() ) ) )
;
4740 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4741 };// class setTime
4742
4743 // -----------------------------------------------------------------------------
4744 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::ctors, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::ctors > autoRegisterRegistry__4744
("osl_File")
;
4745 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::open, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::open > autoRegisterRegistry__4745
("osl_File")
;
4746 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::close, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::close > autoRegisterRegistry__4746
("osl_File")
;
4747 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::setPos, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::setPos > autoRegisterRegistry__4747
("osl_File")
;
4748 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::getPos, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::getPos > autoRegisterRegistry__4748
("osl_File")
;
4749 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::isEndOfFile, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::isEndOfFile >
autoRegisterRegistry__4749("osl_File")
;
4750 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::setSize, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::setSize > autoRegisterRegistry__4750
("osl_File")
;
4751 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::read, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::read > autoRegisterRegistry__4751
("osl_File")
;
4752 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::write, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::write > autoRegisterRegistry__4752
("osl_File")
;
4753 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::readLine, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::readLine >
autoRegisterRegistry__4753("osl_File")
;
4754 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::copy, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::copy > autoRegisterRegistry__4754
("osl_File")
;
4755 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::move, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::move > autoRegisterRegistry__4755
("osl_File")
;
4756 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::remove, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::remove > autoRegisterRegistry__4756
("osl_File")
;
4757 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::setAttributes, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::setAttributes
> autoRegisterRegistry__4757("osl_File")
;
4758 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::setTime, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::setTime > autoRegisterRegistry__4758
("osl_File")
;
4759 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_File::sync, "osl_File" )static CppUnit::AutoRegisterSuite< osl_File::sync > autoRegisterRegistry__4759
("osl_File")
;
4760// FIXME: to enable these tests (when they work cross-platform) we need to add the below:
4761// CPPUNIT_REGISTRY_ADD_TO_DEFAULT( "osl_File" );
4762
4763}// namespace osl_File
4764
4765
4766//------------------------------------------------------------------------
4767// Beginning of the test cases for DirectoryItem class
4768//------------------------------------------------------------------------
4769namespace osl_DirectoryItem
4770{
4771 //---------------------------------------------------------------------
4772 // testing the method
4773 // DirectoryItem(): _pData( NULL )
4774 //---------------------------------------------------------------------
4775 class ctors : public CppUnit::TestFixture
4776 {
4777 ::osl::FileBase::RC nError1;
4778
4779 public:
4780 // initialization
4781 void setUp()
4782 {
4783 // create a tempfile in $TEMP/tmpname.
4784 createTestFile( aTmpName6 );
4785 }
4786
4787 void tearDown()
4788 {
4789 // remove the tempfile in $TEMP/tmpname.
4790 deleteTestFile( aTmpName6 );
4791 }
4792
4793 // test code.
4794 void ctors_001()
4795 {
4796 ::osl::File testFile( aTmpName6 );
4797 ::osl::DirectoryItem rItem; //constructor
4798
4799 //get the DirectoryItem.
4800 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4801 CPPUNIT_ASSERT( FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(FileBase::E_None == nError1), CppUnit
::Message( "assertion failed", "Expression: " "FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4801 ) ) )
;
4802
4803 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: initialize a new instance of DirectoryItem and get an item to check.",( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "test for ctors function: initialize a new instance of DirectoryItem and get an item to check."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4804 ) ) )
4804 ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
, "test for ctors function: initialize a new instance of DirectoryItem and get an item to check."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4804 ) ) )
;
4805 }
4806
4807 CPPUNIT_TEST_SUITE( ctors )public: typedef ctors TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(ctors) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4808 CPPUNIT_TEST( ctors_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_001"), &TestFixtureType
::ctors_001, context.makeFixture() ) ) )
;
4809 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4810 };// class ctors
4811
4812 //---------------------------------------------------------------------
4813 // testing the method
4814 // DirectoryItem( const DirectoryItem& rItem ): _pData( rItem._pData)
4815 //---------------------------------------------------------------------
4816 class copy_assin_Ctors : public CppUnit::TestFixture
4817 {
4818 ::osl::FileBase::RC nError1;
4819
4820 public:
4821 // initialization
4822 void setUp()
4823 {
4824 // create a tempfile in $TEMP/tmpname.
4825 createTestFile( aTmpName6 );
4826 }
4827
4828 void tearDown()
4829 {
4830 // remove the tempfile in $TEMP/tmpname.
4831 deleteTestFile( aTmpName6 );
4832 }
4833
4834 // test code.
4835 void copy_assin_Ctors_001()
4836 {
4837 ::osl::DirectoryItem rItem; //constructor
4838 //get the DirectoryItem.
4839 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4840 CPPUNIT_ASSERT( FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(FileBase::E_None == nError1), CppUnit
::Message( "assertion failed", "Expression: " "FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4840 ) ) )
;
4841
4842 ::osl::DirectoryItem copyItem( rItem ); //copy constructor
4843 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 );
4844 nError1 = copyItem.getFileStatus( rFileStatus );
4845 CPPUNIT_ASSERT( nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4845 ) ) )
;
4846
4847 CPPUNIT_ASSERT_MESSAGE( "test for copy_assin_Ctors function: use copy constructor to get an item and check filename.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == compareFileName
( rFileStatus.getFileName(), aTmpName2 ) )), CppUnit::Message
( "assertion failed", "Expression: " "( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for copy_assin_Ctors function: use copy constructor to get an item and check filename."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4848 ) ) )
4848 ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == compareFileName
( rFileStatus.getFileName(), aTmpName2 ) )), CppUnit::Message
( "assertion failed", "Expression: " "( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for copy_assin_Ctors function: use copy constructor to get an item and check filename."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4848 ) ) )
;
4849 }
4850
4851 void copy_assin_Ctors_002()
4852 {
4853 ::osl::DirectoryItem rItem; //constructor
4854 //get the DirectoryItem.
4855 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4856 CPPUNIT_ASSERT( FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(FileBase::E_None == nError1), CppUnit
::Message( "assertion failed", "Expression: " "FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4856 ) ) )
;
4857
4858 ::osl::DirectoryItem copyItem;
4859 copyItem = rItem; //assinment operator
4860 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 );
4861 nError1 = copyItem.getFileStatus( rFileStatus );
4862 CPPUNIT_ASSERT( nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4862 ) ) )
;
4863
4864 CPPUNIT_ASSERT_MESSAGE( "test for copy_assin_Ctors function: test assinment operator here since it is same as copy constructor in test way.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == compareFileName
( rFileStatus.getFileName(), aTmpName2 ) )), CppUnit::Message
( "assertion failed", "Expression: " "( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for copy_assin_Ctors function: test assinment operator here since it is same as copy constructor in test way."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4865 ) ) )
4865 ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == compareFileName
( rFileStatus.getFileName(), aTmpName2 ) )), CppUnit::Message
( "assertion failed", "Expression: " "( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for copy_assin_Ctors function: test assinment operator here since it is same as copy constructor in test way."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4865 ) ) )
;
4866 }
4867
4868 CPPUNIT_TEST_SUITE( copy_assin_Ctors )public: typedef copy_assin_Ctors TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(copy_assin_Ctors) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
4869 CPPUNIT_TEST( copy_assin_Ctors_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "copy_assin_Ctors_001"), &TestFixtureType
::copy_assin_Ctors_001, context.makeFixture() ) ) )
;
4870 CPPUNIT_TEST( copy_assin_Ctors_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "copy_assin_Ctors_002"), &TestFixtureType
::copy_assin_Ctors_002, context.makeFixture() ) ) )
;
4871 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4872 };// class copy_assin_Ctors
4873
4874 //---------------------------------------------------------------------
4875 // testing the method
4876 // inline sal_Bool is()
4877 //---------------------------------------------------------------------
4878 class is : public CppUnit::TestFixture
4879 {
4880 ::osl::FileBase::RC nError1;
4881
4882 public:
4883 // initialization
4884 void setUp()
4885 {
4886 // create a tempfile in $TEMP/tmpname.
4887 createTestFile( aTmpName6 );
4888 }
4889
4890 void tearDown()
4891 {
4892 // remove the tempfile in $TEMP/tmpname.
4893 deleteTestFile( aTmpName6 );
4894 }
4895
4896 // test code.
4897 void is_001()
4898 {
4899 ::osl::DirectoryItem rItem; //constructor
4900
4901 CPPUNIT_ASSERT_MESSAGE( "test for is function: use an uninitialized instance.",( CppUnit::Asserter::failIf( !(!rItem.is()), CppUnit::Message
( "assertion failed", "Expression: " "!rItem.is()", "test for is function: use an uninitialized instance."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4902 ) ) )
4902 !rItem.is() )( CppUnit::Asserter::failIf( !(!rItem.is()), CppUnit::Message
( "assertion failed", "Expression: " "!rItem.is()", "test for is function: use an uninitialized instance."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4902 ) ) )
;
4903 }
4904
4905 void is_002()
4906 {
4907 ::osl::DirectoryItem rItem; //constructor
4908 //get the DirectoryItem.
4909 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4910 CPPUNIT_ASSERT( FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(FileBase::E_None == nError1), CppUnit
::Message( "assertion failed", "Expression: " "FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4910 ) ) )
;
4911
4912 CPPUNIT_ASSERT_MESSAGE( "test for is function: use an uninitialized instance.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == rItem.is() )
), CppUnit::Message( "assertion failed", "Expression: " "( sal_True == rItem.is() )"
, "test for is function: use an uninitialized instance." ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4913 ) ) )
4913 ( sal_True == rItem.is() ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == rItem.is() )
), CppUnit::Message( "assertion failed", "Expression: " "( sal_True == rItem.is() )"
, "test for is function: use an uninitialized instance." ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4913 ) ) )
;
4914 }
4915
4916 CPPUNIT_TEST_SUITE( is )public: typedef is TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(is) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4917 CPPUNIT_TEST( is_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "is_001"), &TestFixtureType
::is_001, context.makeFixture() ) ) )
;
4918 CPPUNIT_TEST( is_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "is_002"), &TestFixtureType
::is_002, context.makeFixture() ) ) )
;
4919 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4920 };// class is
4921
4922 //---------------------------------------------------------------------
4923 // testing the method
4924 // static inline RC get( const ::rtl::OUString& ustrFileURL, DirectoryItem& rItem )
4925 //---------------------------------------------------------------------
4926 class get : public CppUnit::TestFixture
4927 {
4928 ::osl::FileBase::RC nError1, nError2;
4929
4930 public:
4931 // initialization
4932 void setUp()
4933 {
4934 // create a tempfile in $TEMP/tmpname.
4935 createTestFile( aTmpName6 );
4936 }
4937
4938 void tearDown()
4939 {
4940 // remove the tempfile in $TEMP/tmpname.
4941 deleteTestFile( aTmpName6 );
4942 }
4943
4944 // test code.
4945 void get_001()
4946 {
4947 ::osl::DirectoryItem rItem; //constructor
4948 //get the DirectoryItem.
4949 nError2 = ::osl::DirectoryItem::get( aTmpName6, rItem );
4950
4951 //check the file name
4952 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 );
4953 nError1 = rItem.getFileStatus( rFileStatus );
4954 CPPUNIT_ASSERT( nError1 == FileBase::E_None )( CppUnit::Asserter::failIf( !(nError1 == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "nError1 == FileBase::E_None"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4954 ) ) )
;
4955
4956 CPPUNIT_ASSERT_MESSAGE( "test for get function: use copy constructor to get an item and check filename.",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == compareFileName( rFileStatus
.getFileName(), aTmpName2 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for get function: use copy constructor to get an item and check filename."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4958 ) ) )
4957 ( ::osl::FileBase::E_None == nError2 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == compareFileName( rFileStatus
.getFileName(), aTmpName2 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for get function: use copy constructor to get an item and check filename."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4958 ) ) )
4958 ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == compareFileName( rFileStatus
.getFileName(), aTmpName2 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for get function: use copy constructor to get an item and check filename."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4958 ) ) )
;
4959 }
4960
4961 void get_002()
4962 {
4963 ::osl::DirectoryItem rItem;
4964 //get the DirectoryItem.
4965 nError1 = ::osl::DirectoryItem::get( aSysPath1, rItem );
4966
4967 CPPUNIT_ASSERT_MESSAGE( "test for get function: use a system name instead of a URL.",( CppUnit::Asserter::failIf( !(FileBase::E_INVAL == nError1),
CppUnit::Message( "assertion failed", "Expression: " "FileBase::E_INVAL == nError1"
, "test for get function: use a system name instead of a URL."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4968 ) ) )
4968 FileBase::E_INVAL == nError1 )( CppUnit::Asserter::failIf( !(FileBase::E_INVAL == nError1),
CppUnit::Message( "assertion failed", "Expression: " "FileBase::E_INVAL == nError1"
, "test for get function: use a system name instead of a URL."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4968 ) ) )
;
4969 }
4970
4971 void get_003()
4972 {
4973 ::osl::DirectoryItem rItem;
4974 //get the DirectoryItem.
4975 nError1 = ::osl::DirectoryItem::get( aTmpName3, rItem );
4976
4977 CPPUNIT_ASSERT_MESSAGE( "test for get function: use a non existed file URL.",( CppUnit::Asserter::failIf( !(FileBase::E_NOENT == nError1),
CppUnit::Message( "assertion failed", "Expression: " "FileBase::E_NOENT == nError1"
, "test for get function: use a non existed file URL." ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4978 ) ) )
4978 FileBase::E_NOENT == nError1 )( CppUnit::Asserter::failIf( !(FileBase::E_NOENT == nError1),
CppUnit::Message( "assertion failed", "Expression: " "FileBase::E_NOENT == nError1"
, "test for get function: use a non existed file URL." ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 4978 ) ) )
;
4979 }
4980
4981 CPPUNIT_TEST_SUITE( get )public: typedef get TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(get) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
4982 CPPUNIT_TEST( get_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "get_001"), &TestFixtureType
::get_001, context.makeFixture() ) ) )
;
4983 CPPUNIT_TEST( get_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "get_002"), &TestFixtureType
::get_002, context.makeFixture() ) ) )
;
4984 CPPUNIT_TEST( get_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "get_003"), &TestFixtureType
::get_003, context.makeFixture() ) ) )
;
4985 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
4986 };// class get
4987
4988 //---------------------------------------------------------------------
4989 // testing the method
4990 // inline RC getFileStatus( FileStatus& rStatus )
4991 //---------------------------------------------------------------------
4992 class getFileStatus : public CppUnit::TestFixture
4993 {
4994 ::osl::FileBase::RC nError1, nError2;
4995
4996 public:
4997 // initialization
4998 void setUp()
4999 {
5000 // create a tempfile in $TEMP/tmpdir/tmpname.
5001 createTestDirectory( aTmpName3 );
5002 createTestFile( aTmpName4 );
5003 }
5004
5005 void tearDown()
5006 {
5007 // remove the tempfile in $TEMP/tmpdir/tmpname.
5008 deleteTestFile( aTmpName4 );
5009 deleteTestDirectory( aTmpName3 );
5010 }
5011
5012 // test code.
5013 void getFileStatus_001()
5014 {
5015 ::osl::DirectoryItem rItem; //constructor
5016 //get the DirectoryItem.
5017 nError1 = ::osl::DirectoryItem::get( aTmpName4, rItem );
5018 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5018 ) ) )
;
5019
5020 //check the file name
5021 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 );
5022 nError2 = rItem.getFileStatus( rFileStatus );
5023
5024 CPPUNIT_ASSERT_MESSAGE( "test for getFileStatus function: get file status and check filename",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == compareFileName( rFileStatus
.getFileName(), aTmpName2 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for getFileStatus function: get file status and check filename"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5026 ) ) )
5025 ( ::osl::FileBase::E_None == nError2 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == compareFileName( rFileStatus
.getFileName(), aTmpName2 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for getFileStatus function: get file status and check filename"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5026 ) ) )
5026 ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == compareFileName( rFileStatus
.getFileName(), aTmpName2 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName2 ) )"
, "test for getFileStatus function: get file status and check filename"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5026 ) ) )
;
5027 }
5028
5029 void getFileStatus_002()
5030 {
5031 ::osl::DirectoryItem rItem; //constructor
5032 //get the DirectoryItem.
5033 nError1 = ::osl::DirectoryItem::get( aTmpName6, rItem );
5034
5035 //check the file name
5036 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 );
5037 nError2 = rItem.getFileStatus( rFileStatus );
5038
5039 CPPUNIT_ASSERT_MESSAGE( "test for getFileStatus function: file not existed",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError2
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError2 )"
, "test for getFileStatus function: file not existed" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5040 ) ) )
5040 ( ::osl::FileBase::E_INVAL == nError2 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError2
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError2 )"
, "test for getFileStatus function: file not existed" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5040 ) ) )
;
5041 }
5042
5043 void getFileStatus_003()
5044 {
5045 ::osl::DirectoryItem rItem; //constructor
5046 //get the DirectoryItem.
5047 nError1 = ::osl::DirectoryItem::get( aTmpName3, rItem );
5048 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5048 ) ) )
;
5049
5050 //check the file name
5051 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 );
5052 nError2 = rItem.getFileStatus( rFileStatus );
5053
5054 CPPUNIT_ASSERT_MESSAGE( "test for getFileStatus function: get directory information",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == compareFileName( rFileStatus
.getFileName(), aTmpName1 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName1 ) )"
, "test for getFileStatus function: get directory information"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5056 ) ) )
5055 ( ::osl::FileBase::E_None == nError2 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == compareFileName( rFileStatus
.getFileName(), aTmpName1 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName1 ) )"
, "test for getFileStatus function: get directory information"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5056 ) ) )
5056 ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName1 ) ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == compareFileName( rFileStatus
.getFileName(), aTmpName1 ) )), CppUnit::Message( "assertion failed"
, "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == compareFileName( rFileStatus.getFileName(), aTmpName1 ) )"
, "test for getFileStatus function: get directory information"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5056 ) ) )
;
5057 }
5058
5059
5060 CPPUNIT_TEST_SUITE( getFileStatus )public: typedef getFileStatus TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getFileStatus) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
5061 CPPUNIT_TEST( getFileStatus_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileStatus_001"), &TestFixtureType
::getFileStatus_001, context.makeFixture() ) ) )
;
5062 CPPUNIT_TEST( getFileStatus_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileStatus_002"), &TestFixtureType
::getFileStatus_002, context.makeFixture() ) ) )
;
5063 CPPUNIT_TEST( getFileStatus_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getFileStatus_003"), &TestFixtureType
::getFileStatus_003, context.makeFixture() ) ) )
;
5064 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5065 };// class getFileStatus
5066
5067
5068
5069 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::ctors, "osl_DirectoryItem" )static CppUnit::AutoRegisterSuite< osl_DirectoryItem::ctors
> autoRegisterRegistry__5069("osl_DirectoryItem")
;
5070 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::copy_assin_Ctors, "osl_DirectoryItem" )static CppUnit::AutoRegisterSuite< osl_DirectoryItem::copy_assin_Ctors
> autoRegisterRegistry__5070("osl_DirectoryItem")
;
5071 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::is, "osl_DirectoryItem" )static CppUnit::AutoRegisterSuite< osl_DirectoryItem::is >
autoRegisterRegistry__5071("osl_DirectoryItem")
;
5072 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::get, "osl_DirectoryItem" )static CppUnit::AutoRegisterSuite< osl_DirectoryItem::get >
autoRegisterRegistry__5072("osl_DirectoryItem")
;
5073 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( osl_DirectoryItem::getFileStatus, "osl_DirectoryItem" )static CppUnit::AutoRegisterSuite< osl_DirectoryItem::getFileStatus
> autoRegisterRegistry__5073("osl_DirectoryItem")
;
5074}// namespace osl_DirectoryItem
5075
5076//------------------------------------------------------------------------
5077// Beginning of the test cases for Directory class
5078//------------------------------------------------------------------------
5079namespace osl_Directory
5080{
5081 //---------------------------------------------------------------------
5082 // testing the method
5083 // Directory( const ::rtl::OUString& strPath ): _pData( 0 ), _aPath( strPath )
5084 //---------------------------------------------------------------------
5085 class ctors : public CppUnit::TestFixture
5086 {
5087 ::osl::FileBase::RC nError1, nError2;
5088
5089 public:
5090 // initialization
5091 void setUp()
5092 {
5093 // create a tempfile in $TEMP/tmpdir/tmpname.
5094 createTestDirectory( aTmpName3 );
5095 createTestFile( aTmpName4 );
5096 }
5097
5098 void tearDown()
5099 {
5100 // remove the tempfile in $TEMP/tmpdir/tmpname.
5101 deleteTestFile( aTmpName4 );
5102 deleteTestDirectory( aTmpName3 );
5103 // LLA: t_print("tearDown done.\n");
5104 }
5105
5106 // test code.
5107 void ctors_001()
5108 {
5109 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5110
5111 //open a directory
5112 nError1 = testDirectory.open();
5113 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5113 ) ) )
;
5114 //close a directory
5115 nError2 = testDirectory.close();
5116 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError2"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5116 ) ) )
;
5117
5118 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: create an instance and check open and close",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: create an instance and check open and close"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5120 ) ) )
5119 ( ::osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: create an instance and check open and close"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5120 ) ) )
5120 ( ::osl::FileBase::E_None == nError2 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: create an instance and check open and close"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5120 ) ) )
;
5121 }
5122
5123 void ctors_002()
5124 {
5125 ::osl::Directory testDirectory( aTmpName9 ); //constructor
5126
5127 //open a directory
5128 nError1 = testDirectory.open();
5129 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5129 ) ) )
;
5130 //close a directory
5131 nError2 = testDirectory.close();
5132 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError2"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5132 ) ) )
;
5133
5134 CPPUNIT_ASSERT_MESSAGE( "test for ctors function: relative URL, :-), it is also worked",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: relative URL, :-), it is also worked"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5136 ) ) )
5135 ( ::osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: relative URL, :-), it is also worked"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5136 ) ) )
5136 ( ::osl::FileBase::E_None == nError2 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError1
) && ( ::osl::FileBase::E_None == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for ctors function: relative URL, :-), it is also worked"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5136 ) ) )
;
5137 }
5138
5139 CPPUNIT_TEST_SUITE( ctors )public: typedef ctors TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(ctors) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
5140 CPPUNIT_TEST( ctors_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_001"), &TestFixtureType
::ctors_001, context.makeFixture() ) ) )
;
5141 CPPUNIT_TEST( ctors_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "ctors_002"), &TestFixtureType
::ctors_002, context.makeFixture() ) ) )
;
5142 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5143 };// class ctors
5144
5145 //---------------------------------------------------------------------
5146 // testing the method
5147 // inline RC open()
5148 //---------------------------------------------------------------------
5149 class open : public CppUnit::TestFixture
5150 {
5151 ::osl::FileBase::RC nError1, nError2;
5152
5153 public:
5154 // initialization
5155 void setUp()
5156 {
5157 // create a tempfile in $TEMP/tmpdir/tmpname.
5158 createTestDirectory( aTmpName3 );
5159 createTestFile( aTmpName4 );
5160 }
5161
5162 void tearDown()
5163 {
5164 // remove the tempfile in $TEMP/tmpdir/tmpname.
5165 deleteTestFile( aTmpName4 );
5166 deleteTestDirectory( aTmpName3 );
5167 }
5168
5169 // test code.
5170 void open_001()
5171 {
5172 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5173
5174 //open a directory
5175 nError1 = testDirectory.open();
5176 //check if directory is opened.
5177 sal_Bool bOk = testDirectory.isOpen();
5178 //close a directory
5179 nError2 = testDirectory.close();
5180
5181 CPPUNIT_ASSERT_MESSAGE( "test for open function: open a directory and check for open",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk ) &&
( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase
::E_None == nError2 )), CppUnit::Message( "assertion failed",
"Expression: " "( sal_True == bOk ) && ( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for open function: open a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5184 ) ) )
5182 ( sal_True == bOk ) &&( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk ) &&
( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase
::E_None == nError2 )), CppUnit::Message( "assertion failed",
"Expression: " "( sal_True == bOk ) && ( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for open function: open a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5184 ) ) )
5183 ( ::osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk ) &&
( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase
::E_None == nError2 )), CppUnit::Message( "assertion failed",
"Expression: " "( sal_True == bOk ) && ( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for open function: open a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5184 ) ) )
5184 ( ::osl::FileBase::E_None == nError2 ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk ) &&
( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase
::E_None == nError2 )), CppUnit::Message( "assertion failed",
"Expression: " "( sal_True == bOk ) && ( ::osl::FileBase::E_None == nError1 ) && ( ::osl::FileBase::E_None == nError2 )"
, "test for open function: open a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5184 ) ) )
;
5185 }
5186
5187 void open_002()
5188 {
5189 ::osl::Directory testDirectory( aTmpName6 ); //constructor
5190
5191 //open a directory
5192 nError1 = testDirectory.open();
5193 if ( ::osl::FileBase::E_None == nError1 )
5194 {
5195 nError2 = testDirectory.close();
5196 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError2"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5196 ) ) )
;
5197 }
5198
5199 CPPUNIT_ASSERT_MESSAGE( "test for open function: open a file that is not existed",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOENT == nError1 )"
, "test for open function: open a file that is not existed" )
, CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5200 ) ) )
5200 ( ::osl::FileBase::E_NOENT == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOENT == nError1 )"
, "test for open function: open a file that is not existed" )
, CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5200 ) ) )
;
5201 }
5202
5203 void open_003()
5204 {
5205 ::osl::Directory testDirectory( aUserDirectorySys ); //constructor
5206
5207 //open a directory
5208 nError1 = testDirectory.open();
5209 if ( ::osl::FileBase::E_None == nError1 )
5210 {
5211 nError2 = testDirectory.close();
5212 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError2"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5212 ) ) )
;
5213 }
5214
5215 CPPUNIT_ASSERT_MESSAGE( "test for open function: using system path",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError1 )"
, "test for open function: using system path" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 5216
) ) )
5216 ( ::osl::FileBase::E_INVAL == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError1 )"
, "test for open function: using system path" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 5216
) ) )
;
5217 }
5218
5219 void open_004()
5220 {
5221 ::osl::Directory testDirectory( aTmpName4 ); //constructor
5222
5223 //open a directory
5224 nError1 = testDirectory.open();
5225 if ( ::osl::FileBase::E_None == nError1 )
5226 {
5227 nError2 = testDirectory.close();
5228 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError2"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5228 ) ) )
;
5229 }
5230
5231 CPPUNIT_ASSERT_MESSAGE( "test for open function: open a file instead of a directory",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOTDIR ==
nError1 ) || ( ::osl::FileBase::E_ACCES )), CppUnit::Message
( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOTDIR == nError1 ) || ( ::osl::FileBase::E_ACCES )"
, "test for open function: open a file instead of a directory"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5232 ) ) )
5232 ( ::osl::FileBase::E_NOTDIR == nError1 ) || ( ::osl::FileBase::E_ACCES ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOTDIR ==
nError1 ) || ( ::osl::FileBase::E_ACCES )), CppUnit::Message
( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOTDIR == nError1 ) || ( ::osl::FileBase::E_ACCES )"
, "test for open function: open a file instead of a directory"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5232 ) ) )
;
5233 }
5234
5235 CPPUNIT_TEST_SUITE( open )public: typedef open TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(open) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
5236 CPPUNIT_TEST( open_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_001"), &TestFixtureType
::open_001, context.makeFixture() ) ) )
;
5237 CPPUNIT_TEST( open_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_002"), &TestFixtureType
::open_002, context.makeFixture() ) ) )
;
5238 CPPUNIT_TEST( open_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_003"), &TestFixtureType
::open_003, context.makeFixture() ) ) )
;
5239 CPPUNIT_TEST( open_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "open_004"), &TestFixtureType
::open_004, context.makeFixture() ) ) )
;
5240 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5241 };// class open
5242
5243 //---------------------------------------------------------------------
5244 // testing the method
5245 // inline sal_Bool isOpen() { return _pData != NULL; };
5246 //---------------------------------------------------------------------
5247 class isOpen : public CppUnit::TestFixture
5248 {
5249 ::osl::FileBase::RC nError1, nError2;
5250
5251 public:
5252 // initialization
5253 void setUp()
5254 {
5255 // create a tempfile in $TEMP/tmpdir/tmpname.
5256 createTestDirectory( aTmpName3 );
5257 createTestFile( aTmpName4 );
5258 }
5259
5260 void tearDown()
5261 {
5262 // remove the tempfile in $TEMP/tmpdir/tmpname.
5263 deleteTestFile( aTmpName4 );
5264 deleteTestDirectory( aTmpName3 );
5265 }
5266
5267 // test code.
5268 void isOpen_001()
5269 {
5270 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5271
5272 //open a directory
5273 nError1 = testDirectory.open();
5274 //check if directory is opened.
5275 sal_Bool bOk = testDirectory.isOpen();
5276 //close a directory
5277 nError2 = testDirectory.close();
5278
5279 CPPUNIT_ASSERT_MESSAGE( "test for isOpen function: open a directory and check for open",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for isOpen function: open a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5280 ) ) )
5280 ( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "( sal_True == bOk )"
, "test for isOpen function: open a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5280 ) ) )
;
5281 }
5282
5283 void isOpen_002()
5284 {
5285 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5286
5287 //check if directory is opened.
5288 sal_Bool bOk = testDirectory.isOpen();
5289
5290 CPPUNIT_ASSERT_MESSAGE( "test for isOpen function: do not open a directory and check for open",( CppUnit::Asserter::failIf( !(!( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "!( sal_True == bOk )"
, "test for isOpen function: do not open a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5291 ) ) )
5291 !( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(!( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "!( sal_True == bOk )"
, "test for isOpen function: do not open a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5291 ) ) )
;
5292 }
5293
5294 CPPUNIT_TEST_SUITE( isOpen )public: typedef isOpen TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(isOpen) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
5295 CPPUNIT_TEST( isOpen_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isOpen_001"), &TestFixtureType
::isOpen_001, context.makeFixture() ) ) )
;
5296 CPPUNIT_TEST( isOpen_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "isOpen_002"), &TestFixtureType
::isOpen_002, context.makeFixture() ) ) )
;
5297 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5298 };// class isOpen
5299
5300 //---------------------------------------------------------------------
5301 // testing the method
5302 // inline RC close()
5303 //---------------------------------------------------------------------
5304 class close : public CppUnit::TestFixture
5305 {
5306 ::osl::FileBase::RC nError1, nError2;
5307
5308 public:
5309 // initialization
5310 void setUp()
5311 {
5312 // create a tempdirectory : $TEMP/tmpdir.
5313 createTestDirectory( aTmpName3 );
5314 }
5315
5316 void tearDown()
5317 {
5318 // remove a tempdirectory : $TEMP/tmpdir.
5319 deleteTestDirectory( aTmpName3 );
5320 }
5321
5322 // test code.
5323 void close_001()
5324 {
5325 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5326
5327 //open a directory
5328 nError1 = testDirectory.open();
5329 //close a directory
5330 nError2 = testDirectory.close();
5331 //check if directory is opened.
5332 sal_Bool bOk = testDirectory.isOpen();
5333
5334 CPPUNIT_ASSERT_MESSAGE( "test for isOpen function: close a directory and check for open",( CppUnit::Asserter::failIf( !(!( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "!( sal_True == bOk )"
, "test for isOpen function: close a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5335 ) ) )
5335 !( sal_True == bOk ) )( CppUnit::Asserter::failIf( !(!( ((sal_Bool)1) == bOk )), CppUnit
::Message( "assertion failed", "Expression: " "!( sal_True == bOk )"
, "test for isOpen function: close a directory and check for open"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5335 ) ) )
;
5336 }
5337
5338 void close_002()
5339 {
5340 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5341
5342 //close a directory
5343 nError1 = testDirectory.close();
5344
5345 CPPUNIT_ASSERT_MESSAGE( "test for isOpen function: close a not opened directory",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_BADF == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_BADF == nError1 )"
, "test for isOpen function: close a not opened directory" ),
CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5346 ) ) )
5346 ( ::osl::FileBase::E_BADF == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_BADF == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_BADF == nError1 )"
, "test for isOpen function: close a not opened directory" ),
CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5346 ) ) )
;
5347 }
5348
5349
5350 CPPUNIT_TEST_SUITE( close )public: typedef close TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(close) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
5351 CPPUNIT_TEST( close_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "close_001"), &TestFixtureType
::close_001, context.makeFixture() ) ) )
;
5352 CPPUNIT_TEST( close_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "close_002"), &TestFixtureType
::close_002, context.makeFixture() ) ) )
;
5353 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5354 };// class close
5355
5356 //---------------------------------------------------------------------
5357 // testing the method
5358 // inline RC reset()
5359 //---------------------------------------------------------------------
5360 class reset : public CppUnit::TestFixture
5361 {
5362 ::osl::FileBase::RC nError1, nError2;
5363 ::osl::DirectoryItem rItem;
5364
5365 public:
5366 // initialization
5367 void setUp()
5368 {
5369 // create a tempdirectory : $TEMP/tmpdir.
5370 createTestDirectory( aTmpName3 );
5371 // create three files : $TEMP/tmpdir/tmpname, $TEMP/tmpdir/tmpdir, $TEMP/tmpdir/hiddenfile,
5372 createTestFile( aTmpName3, aTmpName2);
5373 createTestFile( aTmpName3, aTmpName1);
5374 createTestFile( aTmpName3, aHidURL1);
5375 }
5376
5377 void tearDown()
5378 {
5379 // remove three files : $TEMP/tmpdir/tmpname, $TEMP/tmpdir/tmpdir, $TEMP/tmpdir/hiddenfile,
5380 deleteTestFile( aTmpName3, aHidURL1);
5381 deleteTestFile( aTmpName3, aTmpName1);
5382 deleteTestFile( aTmpName3, aTmpName2);
5383 // remove a tempdirectory : $TEMP/tmpdir.
5384 deleteTestDirectory( aTmpName3 );
5385 }
5386
5387 // test code.
5388 void reset_001()
5389 {
5390 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5391
5392 //open a directory
5393 nError1 = testDirectory.open();
5394 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5394 ) ) )
;
5395 //get first Item
5396 nError1 = testDirectory.getNextItem( rItem, 1 );
5397 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5397 ) ) )
;
5398 //check the file name of first Item
5399 ::osl::FileStatus rFileStatusFirst( osl_FileStatus_Mask_FileName0x00000100 );
5400 nError1 = rItem.getFileStatus( rFileStatusFirst );
5401
5402 //get second Item
5403 //mindy: nError1 = testDirectory.getNextItem( rItem, 0 );
5404 //mindy: CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 );
5405
5406 //reset enumeration
5407 nError2 = testDirectory.reset();
5408 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError2 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError2
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError2"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5408 ) ) )
;
5409 //get reseted Item, if reset does not work, getNextItem() should return the second Item (aTmpName1)
5410 nError1 = testDirectory.getNextItem( rItem, 0 );
5411 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5411 ) ) )
;
5412
5413 //check the file name again
5414 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 );
5415 nError1 = rItem.getFileStatus( rFileStatus );
5416 //close a directory
5417 nError1 = testDirectory.close();
5418 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5418 ) ) )
;
5419
5420 sal_Bool bOK1,bOK2,bOK3;
5421 bOK1 = compareFileName( rFileStatus.getFileName(), aTmpName2 );
5422 bOK2 = compareFileName( rFileStatus.getFileName(), aHidURL1 );
5423 bOK3 = compareFileName( rFileStatus.getFileName(), rFileStatusFirst.getFileName() );
5424 CPPUNIT_ASSERT_MESSAGE( "test for reset function: get two directory item, reset it, then get again, check the filename",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == bOK1 || bOK2 || bOK3 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == bOK1 || bOK2 || bOK3 )"
, "test for reset function: get two directory item, reset it, then get again, check the filename"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5426 ) ) )
5425 ( ::osl::FileBase::E_None == nError2 ) &&( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == bOK1 || bOK2 || bOK3 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == bOK1 || bOK2 || bOK3 )"
, "test for reset function: get two directory item, reset it, then get again, check the filename"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5426 ) ) )
5426 ( sal_True == bOK1 || bOK2 || bOK3 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_None == nError2
) && ( ((sal_Bool)1) == bOK1 || bOK2 || bOK3 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_None == nError2 ) && ( sal_True == bOK1 || bOK2 || bOK3 )"
, "test for reset function: get two directory item, reset it, then get again, check the filename"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5426 ) ) )
;
5427 }
5428
5429 void reset_002()
5430 {
5431 ::osl::Directory testDirectory( aTmpName6 ); //constructor
5432
5433 //close a directory
5434 nError1 = testDirectory.reset();
5435
5436 CPPUNIT_ASSERT_MESSAGE( "test for reset function: reset a non existed directory",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOENT == nError1 )"
, "test for reset function: reset a non existed directory" ),
CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5437 ) ) )
5437 ( ::osl::FileBase::E_NOENT == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOENT == nError1 )"
, "test for reset function: reset a non existed directory" ),
CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5437 ) ) )
;
5438 }
5439
5440
5441 void reset_003()
5442 {
5443 ::osl::Directory testDirectory( aTmpName4 ); //constructor
5444
5445 //close a directory
5446 nError1 = testDirectory.reset();
5447
5448 CPPUNIT_ASSERT_MESSAGE( "test for reset function: reset a file instead of a directory",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOTDIR ==
nError1 ) || ( ::osl::FileBase::E_NOENT == nError1 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOTDIR == nError1 ) || ( ::osl::FileBase::E_NOENT == nError1 )"
, "test for reset function: reset a file instead of a directory"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5449 ) ) )
5449 ( ::osl::FileBase::E_NOTDIR == nError1 ) || ( ::osl::FileBase::E_NOENT == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOTDIR ==
nError1 ) || ( ::osl::FileBase::E_NOENT == nError1 )), CppUnit
::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOTDIR == nError1 ) || ( ::osl::FileBase::E_NOENT == nError1 )"
, "test for reset function: reset a file instead of a directory"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5449 ) ) )
;
5450 }
5451
5452 void reset_004()
5453 {
5454 ::osl::Directory testDirectory( aUserDirectorySys ); //constructor
5455
5456 //close a directory
5457 nError1 = testDirectory.reset();
5458
5459 CPPUNIT_ASSERT_MESSAGE( "test for reset function: use a system path",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError1 )"
, "test for reset function: use a system path" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 5460
) ) )
5460 ( ::osl::FileBase::E_INVAL == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError1 )"
, "test for reset function: use a system path" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 5460
) ) )
;
5461 }
5462
5463 CPPUNIT_TEST_SUITE( reset )public: typedef reset TestFixtureType; private: static const CppUnit
::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(reset) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
5464 CPPUNIT_TEST( reset_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "reset_001"), &TestFixtureType
::reset_001, context.makeFixture() ) ) )
;
5465 CPPUNIT_TEST( reset_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "reset_002"), &TestFixtureType
::reset_002, context.makeFixture() ) ) )
;
5466 CPPUNIT_TEST( reset_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "reset_003"), &TestFixtureType
::reset_003, context.makeFixture() ) ) )
;
5467 CPPUNIT_TEST( reset_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "reset_004"), &TestFixtureType
::reset_004, context.makeFixture() ) ) )
;
5468 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5469 };// class reset
5470
5471 //---------------------------------------------------------------------
5472 // testing the method
5473 // inline RC getNextItem( DirectoryItem& rItem, sal_uInt32 nHint = 0 )
5474 //---------------------------------------------------------------------
5475 class getNextItem : public CppUnit::TestFixture
5476 {
5477 ::osl::FileBase::RC nError1, nError2;
5478 ::osl::DirectoryItem rItem;
5479
5480 public:
5481 // initialization
5482 void setUp()
5483 {
5484 // create a tempdirectory : $TEMP/tmpdir.
5485 createTestDirectory( aTmpName3 );
5486 // create three files : $TEMP/tmpdir/tmpname, $TEMP/tmpdir/tmpdir, $TEMP/tmpdir/hiddenfile,
5487 createTestFile( aTmpName3, aTmpName2 );
5488 createTestFile( aTmpName3, aTmpName1 );
5489 createTestFile( aTmpName3, aHidURL1 );
5490
5491 }
5492
5493 void tearDown()
5494 {
5495 // remove three files : $TEMP/tmpdir/tmpname, $TEMP/tmpdir/tmpdir, $TEMP/tmpdir/hiddenfile,
5496 deleteTestFile( aTmpName3, aHidURL1 );
5497 deleteTestFile( aTmpName3, aTmpName1 );
5498 deleteTestFile( aTmpName3, aTmpName2 );
5499 // remove a tempdirectory : $TEMP/tmpdir.
5500 deleteTestDirectory( aTmpName3 );
5501 }
5502
5503 // test code.
5504 void getNextItem_001()
5505 {
5506 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5507
5508 //open a directory
5509 nError1 = testDirectory.open();
5510 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5510 ) ) )
;
5511
5512 //check the file name
5513 ::rtl::OUString strFilename;
5514 sal_Bool bOk1 = sal_False((sal_Bool)0);
5515 sal_Bool bOk2 = sal_False((sal_Bool)0);
5516 sal_Bool bOk3 = sal_False((sal_Bool)0);
5517 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 );
5518 for ( int nCount = 0; nCount < 3; nCount++ )
5519 {
5520 //get three Items
5521 nError1 = testDirectory.getNextItem( rItem, 2 );
5522 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5522 ) ) )
;
5523 nError1 = rItem.getFileStatus( rFileStatus );
5524 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5524 ) ) )
;
5525
5526 // a special order is not guaranteed. So any file may occur on any time.
5527 // But every file name should occur only once.
5528 if ( bOk1 == sal_False((sal_Bool)0) && compareFileName( rFileStatus.getFileName(), aTmpName1 ) )
5529 {
5530 bOk1 = sal_True((sal_Bool)1);
5531 }
5532
5533 if ( bOk2 == sal_False((sal_Bool)0) && compareFileName( rFileStatus.getFileName(), aTmpName2 ) )
5534 {
5535 bOk2 = sal_True((sal_Bool)1);
5536 }
5537
5538 if ( bOk3 == sal_False((sal_Bool)0) && compareFileName( rFileStatus.getFileName(), aHidURL1 ) )
5539 {
5540 bOk3 = sal_True((sal_Bool)1);
5541 }
5542 }
5543
5544 //close a directory
5545 nError1 = testDirectory.close();
5546 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5546 ) ) )
;
5547
5548 CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrive three items and check their names.",( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
)), CppUnit::Message( "assertion failed", "Expression: " "( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 )"
, "test for getNextItem function: retrive three items and check their names."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5549 ) ) )
5549 ( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 ) )( CppUnit::Asserter::failIf( !(( ((sal_Bool)1) == bOk1 ) &&
( ((sal_Bool)1) == bOk2 ) && ( ((sal_Bool)1) == bOk3
)), CppUnit::Message( "assertion failed", "Expression: " "( sal_True == bOk1 ) && ( sal_True == bOk2 ) && ( sal_True == bOk3 )"
, "test for getNextItem function: retrive three items and check their names."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5549 ) ) )
;
5550 }
5551
5552 void getNextItem_002()
5553 {
5554 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5555 nError1 = testDirectory.getNextItem( rItem );
5556
5557 CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrive an item in a directory which is not opened, also test for nHint's default value.",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError1 )"
, "test for getNextItem function: retrive an item in a directory which is not opened, also test for nHint's default value."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5558 ) ) )
5558 ( ::osl::FileBase::E_INVAL == nError1 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_INVAL == nError1 )"
, "test for getNextItem function: retrive an item in a directory which is not opened, also test for nHint's default value."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5558 ) ) )
;
5559 }
5560
5561 void getNextItem_003()
5562 {
5563 ::osl::Directory testDirectory( aTmpName3 ); //constructor
5564
5565 //open a directory
5566 nError1 = testDirectory.open();
5567 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5567 ) ) )
;
5568
5569 for ( int nCount = 0; nCount < 4; nCount++ )
5570 {
5571 nError2 = testDirectory.getNextItem( rItem, 3 );
5572 }
5573
5574 //close a directory
5575 nError1 = testDirectory.close();
5576 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5576 ) ) )
;
5577
5578 CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: retrive 4 times in a directory which contain only 3 files.",( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOENT == nError2
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOENT == nError2 )"
, "test for getNextItem function: retrive 4 times in a directory which contain only 3 files."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5579 ) ) )
5579 ( ::osl::FileBase::E_NOENT == nError2 ) )( CppUnit::Asserter::failIf( !(( ::osl::FileBase::E_NOENT == nError2
)), CppUnit::Message( "assertion failed", "Expression: " "( ::osl::FileBase::E_NOENT == nError2 )"
, "test for getNextItem function: retrive 4 times in a directory which contain only 3 files."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5579 ) ) )
;
5580 }
5581
5582 void getNextItem_004()
5583 {
5584 //create a link file(can not on Windows), then check if getNextItem can get it.
5585#ifdef UNX1
5586 sal_Bool bLnkOK = sal_False((sal_Bool)0);
5587 sal_Bool bFoundOK = sal_False((sal_Bool)0);
5588
5589 ::rtl::OUString aUStr_LnkFileSys( aTempDirectorySys ), aUStr_SrcFileSys( aTempDirectorySys );
5590 ( aUStr_LnkFileSys += aSlashURL ) += ::rtl::OUString("/tmpdir/link.file");
5591 ( aUStr_SrcFileSys += aSlashURL ) += ::rtl::OUString("/tmpdir/tmpname");
5592
5593 ::rtl::OString strLinkFileName, strSrcFileName;
5594 strLinkFileName = OUStringToOString( aUStr_LnkFileSys, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
5595 strSrcFileName = OUStringToOString( aUStr_SrcFileSys, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)) );
5596
5597 // create a link file and link it to file "/tmp/PID/tmpdir/tmpname"
5598 sal_Int32 fd = symlink( strSrcFileName.getStr(), strLinkFileName.getStr() );
5599 CPPUNIT_ASSERT( fd == 0 )( CppUnit::Asserter::failIf( !(fd == 0), CppUnit::Message( "assertion failed"
, "Expression: " "fd == 0"), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5599 ) ) )
;
5600 ::osl::Directory testDirectory( aTmpName3 );
5601
5602 //open a directory
5603 nError1 = testDirectory.open();
5604 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5604 ) ) )
;
5605 ::rtl::OUString aFileName ("link.file");
5606
5607 while (1) {
5608 nError1 = testDirectory.getNextItem( rItem, 4 );
5609 if (::osl::FileBase::E_None == nError1) {
5610 ::osl::FileStatus rFileStatus( osl_FileStatus_Mask_FileName0x00000100 | osl_FileStatus_Mask_Type0x00000001 );
5611 rItem.getFileStatus( rFileStatus );
5612 if ( compareFileName( rFileStatus.getFileName(), aFileName) == sal_True((sal_Bool)1) )
5613 {
5614 bFoundOK = sal_True((sal_Bool)1);
5615 if ( FileStatus::Link == rFileStatus.getFileType())
5616 {
5617 bLnkOK = sal_True((sal_Bool)1);
5618 break;
5619 }
5620 }
5621 }
5622 else
5623 break;
5624 };
5625 fd = std::remove( strLinkFileName.getStr() );
5626 CPPUNIT_ASSERT_MESSAGE( "remove link file failed", fd == 0 )( CppUnit::Asserter::failIf( !(fd == 0), CppUnit::Message( "assertion failed"
, "Expression: " "fd == 0", "remove link file failed" ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5626 ) ) )
;
5627 CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: check if can retrieve the link file name",( CppUnit::Asserter::failIf( !(( bFoundOK == ((sal_Bool)1) ))
, CppUnit::Message( "assertion failed", "Expression: " "( bFoundOK == sal_True )"
, "test for getNextItem function: check if can retrieve the link file name"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5628 ) ) )
5628 ( bFoundOK == sal_True ) )( CppUnit::Asserter::failIf( !(( bFoundOK == ((sal_Bool)1) ))
, CppUnit::Message( "assertion failed", "Expression: " "( bFoundOK == sal_True )"
, "test for getNextItem function: check if can retrieve the link file name"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5628 ) ) )
;
5629 CPPUNIT_ASSERT_MESSAGE( "test for getNextItem function: check if link file has file type link",( CppUnit::Asserter::failIf( !(( bLnkOK == ((sal_Bool)1) )), CppUnit
::Message( "assertion failed", "Expression: " "( bLnkOK == sal_True )"
, "test for getNextItem function: check if link file has file type link"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5630 ) ) )
5630 ( bLnkOK == sal_True ) )( CppUnit::Asserter::failIf( !(( bLnkOK == ((sal_Bool)1) )), CppUnit
::Message( "assertion failed", "Expression: " "( bLnkOK == sal_True )"
, "test for getNextItem function: check if link file has file type link"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5630 ) ) )
;
5631#endif
5632 }
5633
5634 CPPUNIT_TEST_SUITE( getNextItem )public: typedef getNextItem TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(getNextItem) ); return testNamer; } public
: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
5635 CPPUNIT_TEST( getNextItem_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getNextItem_001"), &TestFixtureType
::getNextItem_001, context.makeFixture() ) ) )
;
5636 CPPUNIT_TEST( getNextItem_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getNextItem_002"), &TestFixtureType
::getNextItem_002, context.makeFixture() ) ) )
;
5637 CPPUNIT_TEST( getNextItem_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getNextItem_003"), &TestFixtureType
::getNextItem_003, context.makeFixture() ) ) )
;
5638 CPPUNIT_TEST( getNextItem_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getNextItem_004"), &TestFixtureType
::getNextItem_004, context.makeFixture() ) ) )
;
5639 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5640 };// class getNextItem
5641
5642 //---------------------------------------------------------------------
5643 // testing the method
5644 // inline static RC getVolumeInfo( const ::rtl::OUString& ustrDirectoryURL, VolumeInfo& rInfo )
5645 //---------------------------------------------------------------------
5646 class getVolumeInfo : public CppUnit::TestFixture
5647 {
5648 ::osl::FileBase::RC nError1;
5649
5650 public:
5651
5652 // test code.
5653 void checkValidMask(osl::VolumeInfo const& _aVolumeInfo, sal_Int32 _nMask)
5654 {
5655 if (_nMask == osl_VolumeInfo_Mask_FileSystemName0x00000040L)
5656 {
5657 //get file system name
5658 ::rtl::OUString aFileSysName( aNullURL );
5659 aFileSysName = _aVolumeInfo.getFileSystemName();
5660
5661 sal_Bool bRes2 = compareFileName( aFileSysName, aNullURL );
5662 CPPUNIT_ASSERT_MESSAGE( "test for getVolumeInfo function: getVolumeInfo of root directory.",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)0) == bRes2 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_False == bRes2 )"
, "test for getVolumeInfo function: getVolumeInfo of root directory."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5664 ) ) )
5663 ( osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)0) == bRes2 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_False == bRes2 )"
, "test for getVolumeInfo function: getVolumeInfo of root directory."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5664 ) ) )
5664 ( sal_False == bRes2 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( ((sal_Bool)0) == bRes2 )), CppUnit::Message( "assertion failed"
, "Expression: " "( osl::FileBase::E_None == nError1 ) && ( sal_False == bRes2 )"
, "test for getVolumeInfo function: getVolumeInfo of root directory."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5664 ) ) )
;
5665 }
5666 if (_nMask == osl_VolumeInfo_Mask_Attributes0x00000001L)
5667 {
5668 sal_Bool b1 = _aVolumeInfo.getRemoteFlag();
5669 sal_Bool b2 = _aVolumeInfo.getRemoveableFlag();
5670 sal_Bool b3 = _aVolumeInfo.getCompactDiscFlag();
5671 sal_Bool b4 = _aVolumeInfo.getFloppyDiskFlag();
5672 sal_Bool b5 = _aVolumeInfo.getFixedDiskFlag();
5673 sal_Bool b6 = _aVolumeInfo.getRAMDiskFlag();
5674
5675 rtl::OString sAttr;
5676 if (b1) sAttr = "Remote";
5677 if (b2) sAttr += " Removeable";
5678 if (b3) sAttr += " CDROM";
5679 if (b4) sAttr += " Floppy";
5680 if (b5) sAttr += " FixedDisk";
5681 if (b6) sAttr += " RAMDisk";
5682
5683 printf("Attributes: %s\n", sAttr.getStr() );
5684 }
5685 if (_nMask == osl_VolumeInfo_Mask_TotalSpace0x00000002L)
5686 {
5687 // within Linux, df / * 1024 bytes is the result
5688 sal_uInt64 nSize = _aVolumeInfo.getTotalSpace();
5689 printf("Total space: %" SAL_PRIuUINT64"llu" "\n", nSize);
5690 }
5691 if (_nMask == osl_VolumeInfo_Mask_UsedSpace0x00000004L)
5692 {
5693 sal_uInt64 nSize = _aVolumeInfo.getUsedSpace();
5694 printf(" Used space: %" SAL_PRIuUINT64"llu" "\n", nSize);
5695 }
5696 if (_nMask == osl_VolumeInfo_Mask_FreeSpace0x00000008L)
5697 {
5698 sal_uInt64 nSize = _aVolumeInfo.getFreeSpace();
5699 printf(" Free space: %" SAL_PRIuUINT64"llu" "\n", nSize);
5700 }
5701 if (_nMask == osl_VolumeInfo_Mask_MaxNameLength0x00000010L)
5702 {
5703 sal_uInt32 nLength = _aVolumeInfo.getMaxNameLength();
5704 printf("max name length: %" SAL_PRIuUINT32"lu" "\n", nLength);
5705 }
5706 if (_nMask == osl_VolumeInfo_Mask_MaxPathLength0x00000020L)
5707 {
5708 sal_uInt32 nLength = _aVolumeInfo.getMaxPathLength();
5709 printf("max path length: %" SAL_PRIuUINT32"lu" "\n", nLength);
5710 }
5711 if (_nMask == osl_VolumeInfo_Mask_FileSystemCaseHandling0x00000100L)
5712 {
5713 bool bIsCase = _aVolumeInfo.isCaseSensitiveFileSystem();
5714 printf("filesystem case sensitive: %s\n", bIsCase ? "yes" : "no");
5715 }
5716 }
5717
5718 void checkVolumeInfo(sal_Int32 _nMask)
5719 {
5720 ::osl::VolumeInfo aVolumeInfo( _nMask );
5721 //call getVolumeInfo here
5722 nError1 = ::osl::Directory::getVolumeInfo( aVolURL1, aVolumeInfo );
5723 // LLA: IMHO it's not a bug, if VolumeInfo is not valid, it's a feature
5724 // LLA: CPPUNIT_ASSERT_MESSAGE("mask is not valid", sal_True == aVolumeInfo.isValid( _nMask ) );
5725 if (aVolumeInfo.isValid( _nMask))
5726 {
5727 checkValidMask(aVolumeInfo, _nMask);
5728 }
5729 }
5730
5731
5732 void getVolumeInfo_001_1()
5733 {
5734 sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemName0x00000040L;
5735 checkVolumeInfo(mask);
5736 }
5737 void getVolumeInfo_001_2()
5738 {
5739 sal_Int32 mask = osl_VolumeInfo_Mask_Attributes0x00000001L;
5740 checkVolumeInfo(mask);
5741 }
5742 void getVolumeInfo_001_3()
5743 {
5744 sal_Int32 mask = osl_VolumeInfo_Mask_TotalSpace0x00000002L;
5745 checkVolumeInfo(mask);
5746 }
5747 void getVolumeInfo_001_4()
5748 {
5749 sal_Int32 mask = osl_VolumeInfo_Mask_UsedSpace0x00000004L;
5750 checkVolumeInfo(mask);
5751 }
5752 void getVolumeInfo_001_5()
5753 {
5754 sal_Int32 mask = osl_VolumeInfo_Mask_FreeSpace0x00000008L;
5755 checkVolumeInfo(mask);
5756 }
5757 void getVolumeInfo_001_6()
5758 {
5759 sal_Int32 mask = osl_VolumeInfo_Mask_MaxNameLength0x00000010L;
5760 checkVolumeInfo(mask);
5761 }
5762 void getVolumeInfo_001_7()
5763 {
5764 sal_Int32 mask = osl_VolumeInfo_Mask_MaxPathLength0x00000020L;
5765 checkVolumeInfo(mask);
5766 }
5767 void getVolumeInfo_001_8()
5768 {
5769 sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemCaseHandling0x00000100L;
5770 checkVolumeInfo(mask);
5771 }
5772
5773 void getVolumeInfo_002()
5774 {
5775 sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemName0x00000040L;
5776 ::osl::VolumeInfo aVolumeInfo( mask );
5777 //call getVolumeInfo here
5778
5779 // LLA: rtl::OUString aRootSysURL;
5780 // LLA: nError1 = osl::File::getFileURLFromSystemPath(aRootSys, aRootSysURL);
5781 // LLA:
5782 // LLA: CPPUNIT_ASSERT_MESSAGE( "can't convert root path to file url",
5783 // LLA: ( osl::FileBase::E_NONE == nError1 ) );
5784
5785 nError1 = ::osl::Directory::getVolumeInfo( aRootSys, aVolumeInfo );
5786
5787 CPPUNIT_ASSERT_MESSAGE( "test for getVolumeInfo function: use system path as parameter.",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_INVAL == nError1 )"
, "test for getVolumeInfo function: use system path as parameter."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5788 ) ) )
5788 ( osl::FileBase::E_INVAL == nError1 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_INVAL == nError1 )"
, "test for getVolumeInfo function: use system path as parameter."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5788 ) ) )
;
5789 }
5790
5791 void getVolumeInfo_003()
5792 {
5793 sal_Int32 mask = osl_VolumeInfo_Mask_FileSystemName0x00000040L;
5794 ::osl::VolumeInfo aVolumeInfo( mask );
5795 //call getVolumeInfo here
5796 nError1 = ::osl::Directory::getVolumeInfo( aTmpName3, aVolumeInfo );
5797
5798// LLA: in Windows, it reply no error, it did not pass in (W32).
5799#if defined(UNX1) && !defined(IOS)
5800 CPPUNIT_ASSERT_MESSAGE( "test for getVolumeInfo function: non-existence test. ",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_NOENT == nError1 )"
, "test for getVolumeInfo function: non-existence test. " ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5801 ) ) )
5801 ( osl::FileBase::E_NOENT == nError1 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_NOENT == nError1 )"
, "test for getVolumeInfo function: non-existence test. " ), CppUnit
::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5801 ) ) )
;
5802#endif
5803 }
5804
5805 CPPUNIT_TEST_SUITE( getVolumeInfo )public: typedef getVolumeInfo TestFixtureType; private: static
const CppUnit::TestNamer &getTestNamer__() { static CppUnit
::TestNamer testNamer( typeid(getVolumeInfo) ); return testNamer
; } public: typedef CppUnit::TestSuiteBuilderContext<TestFixtureType
> TestSuiteBuilderContextType; static void addTestsToSuite
( CppUnit::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
5806 CPPUNIT_TEST( getVolumeInfo_001_1 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_001_1"), &TestFixtureType
::getVolumeInfo_001_1, context.makeFixture() ) ) )
;
5807 CPPUNIT_TEST( getVolumeInfo_001_2 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_001_2"), &TestFixtureType
::getVolumeInfo_001_2, context.makeFixture() ) ) )
;
5808 CPPUNIT_TEST( getVolumeInfo_001_3 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_001_3"), &TestFixtureType
::getVolumeInfo_001_3, context.makeFixture() ) ) )
;
5809 CPPUNIT_TEST( getVolumeInfo_001_4 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_001_4"), &TestFixtureType
::getVolumeInfo_001_4, context.makeFixture() ) ) )
;
5810 CPPUNIT_TEST( getVolumeInfo_001_5 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_001_5"), &TestFixtureType
::getVolumeInfo_001_5, context.makeFixture() ) ) )
;
5811 CPPUNIT_TEST( getVolumeInfo_001_6 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_001_6"), &TestFixtureType
::getVolumeInfo_001_6, context.makeFixture() ) ) )
;
5812 CPPUNIT_TEST( getVolumeInfo_001_7 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_001_7"), &TestFixtureType
::getVolumeInfo_001_7, context.makeFixture() ) ) )
;
5813 CPPUNIT_TEST( getVolumeInfo_001_8 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_001_8"), &TestFixtureType
::getVolumeInfo_001_8, context.makeFixture() ) ) )
;
5814 CPPUNIT_TEST( getVolumeInfo_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_002"), &TestFixtureType
::getVolumeInfo_002, context.makeFixture() ) ) )
;
5815 CPPUNIT_TEST( getVolumeInfo_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "getVolumeInfo_003"), &TestFixtureType
::getVolumeInfo_003, context.makeFixture() ) ) )
;
5816 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5817 };// class getVolumeInfo
5818
5819
5820 //---------------------------------------------------------------------
5821 // testing the method
5822 // inline static RC create( const ::rtl::OUString& ustrDirectoryURL )
5823 //---------------------------------------------------------------------
5824 class create : public CppUnit::TestFixture
5825 {
5826 ::osl::FileBase::RC nError1, nError2;
5827
5828 public:
5829
5830 // test code.
5831 void create_001()
5832 {
5833 //create directory in $TEMP/tmpdir
5834 nError1 = ::osl::Directory::create( aTmpName3 );
5835 //check for existence
5836 nError2 = ::osl::Directory::create( aTmpName3 );
5837 //remove it
5838 deleteTestDirectory( aTmpName3 );
5839
5840 CPPUNIT_ASSERT_MESSAGE( "test for create function: create a directory and check its existence.",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_EXIST== nError2 )), CppUnit::
Message( "assertion failed", "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST== nError2 )"
, "test for create function: create a directory and check its existence."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5842 ) ) )
5841 ( osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_EXIST== nError2 )), CppUnit::
Message( "assertion failed", "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST== nError2 )"
, "test for create function: create a directory and check its existence."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5842 ) ) )
5842 ( osl::FileBase::E_EXIST== nError2 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_EXIST== nError2 )), CppUnit::
Message( "assertion failed", "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_EXIST== nError2 )"
, "test for create function: create a directory and check its existence."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5842 ) ) )
;
5843 }
5844
5845 void create_002()
5846 {
5847#if !defined (WNT) && !defined (MACOSX) && defined (SAL_UNX)
5848 if (geteuid() == 0) //don't test if building as root
5849 return;
5850
5851 rtl::OUString aTmpDir;
5852 nError1 = FileBase::createTempFile(NULL__null, NULL__null, &aTmpDir);
5853 CPPUNIT_ASSERT_MESSAGE("temp File creation failed", osl::FileBase::E_None == nError1)( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
, "temp File creation failed" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5853 ) ) )
;
5854
5855 nError1 = ::osl::File::remove(aTmpDir);
5856 CPPUNIT_ASSERT_MESSAGE("temp File removal failed", osl::FileBase::E_None == nError1)( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
, "temp File removal failed" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5856 ) ) )
;
5857
5858 nError1 = ::osl::Directory::create(aTmpDir);
5859 ::rtl::OString sError("test for create function: create a directory '");
5860 sError += ::rtl::OUStringToOString(aTmpDir, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)));
5861 sError += "' and check its existence.";
5862 CPPUNIT_ASSERT_MESSAGE(sError.getStr(), osl::FileBase::E_None == nError1)( CppUnit::Asserter::failIf( !(osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_None == nError1"
, sError.getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5862 ) ) )
;
5863 osl_setFileAttributes(aTmpDir.pData, 0); //no access allowed now
5864
5865 //Shouldn't be possible now to create a dir underneath it
5866 rtl::OUString aTmpSubLevel = aTmpDir + OUString("/notallowedhere");
5867 nError1 = ::osl::Directory::create(aTmpSubLevel);
5868
5869 //allow removal
5870 osl_setFileAttributes(aTmpDir.pData,
5871 osl_File_Attribute_OwnRead0x00000200 |
5872 osl_File_Attribute_OwnWrite0x00000100 |
5873 osl_File_Attribute_OwnExe0x00000400);
5874 deleteTestDirectory(aTmpDir);
5875 sError = ::rtl::OString("test for create function: create a directory under '");
5876 sError += ::rtl::OUStringToOString(aTmpDir, RTL_TEXTENCODING_ASCII_US(((rtl_TextEncoding) 11)));
5877 sError += "' for access test.";
5878 CPPUNIT_ASSERT_MESSAGE(sError.getStr(), osl::FileBase::E_ACCES == nError1)( CppUnit::Asserter::failIf( !(osl::FileBase::E_ACCES == nError1
), CppUnit::Message( "assertion failed", "Expression: " "osl::FileBase::E_ACCES == nError1"
, sError.getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5878 ) ) )
;
5879#endif
5880 }
5881
5882 void create_003()
5883 {
5884 //create directory in /tmpname
5885 nError1 = ::osl::Directory::create( aSysPath1 );
5886
5887 CPPUNIT_ASSERT_MESSAGE( "test for create function: create a directory using system path.",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_INVAL == nError1 )"
, "test for create function: create a directory using system path."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5888 ) ) )
5888 ( osl::FileBase::E_INVAL == nError1 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_INVAL == nError1 )"
, "test for create function: create a directory using system path."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5888 ) ) )
;
5889 }
5890
5891 CPPUNIT_TEST_SUITE( create )public: typedef create TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(create) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
5892 CPPUNIT_TEST( create_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "create_001"), &TestFixtureType
::create_001, context.makeFixture() ) ) )
;
5893 CPPUNIT_TEST( create_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "create_002"), &TestFixtureType
::create_002, context.makeFixture() ) ) )
;
5894 CPPUNIT_TEST( create_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "create_003"), &TestFixtureType
::create_003, context.makeFixture() ) ) )
;
5895 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5896 };// class create
5897
5898 //---------------------------------------------------------------------
5899 // testing the method
5900 // inline static RC remove( const ::rtl::OUString& ustrDirectoryURL )
5901 //---------------------------------------------------------------------
5902 class remove : public CppUnit::TestFixture
5903 {
5904 ::osl::FileBase::RC nError1, nError2;
5905
5906 public:
5907
5908 // test code.
5909 void remove_001()
5910 {
5911 //create directory in $TEMP/tmpdir
5912 nError1 = ::osl::Directory::create( aTmpName3 );
5913 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5913 ) ) )
;
5914 //remove it
5915 nError1 = ::osl::Directory::remove( aTmpName3 );
5916 //check for existence
5917 ::osl::Directory rDirectory( aTmpName3 );
5918 nError2 = rDirectory.open();
5919
5920 CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a directory and check its existence.",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_NOENT == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_NOENT == nError2 )"
, "test for remove function: remove a directory and check its existence."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5922 ) ) )
5921 ( osl::FileBase::E_None == nError1 ) &&( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_NOENT == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_NOENT == nError2 )"
, "test for remove function: remove a directory and check its existence."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5922 ) ) )
5922 ( osl::FileBase::E_NOENT == nError2 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_None == nError1
) && ( osl::FileBase::E_NOENT == nError2 )), CppUnit
::Message( "assertion failed", "Expression: " "( osl::FileBase::E_None == nError1 ) && ( osl::FileBase::E_NOENT == nError2 )"
, "test for remove function: remove a directory and check its existence."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5922 ) ) )
;
5923 }
5924
5925 void remove_002()
5926 {
5927 //create directory in $TEMP/tmpdir
5928 nError1 = ::osl::Directory::create( aTmpName3 );
5929 CPPUNIT_ASSERT( ::osl::FileBase::E_None == nError1 )( CppUnit::Asserter::failIf( !(::osl::FileBase::E_None == nError1
), CppUnit::Message( "assertion failed", "Expression: " "::osl::FileBase::E_None == nError1"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5929 ) ) )
;
5930 //try to remove it by system path
5931 nError1 = ::osl::Directory::remove( aSysPath3 );
5932 //check for existence
5933 ::osl::Directory rDirectory( aTmpName3 );
5934 nError2 = rDirectory.open();
5935 if ( osl::FileBase::E_NOENT != nError2 )
5936 ::osl::Directory::remove( aTmpName3 );
5937
5938 CPPUNIT_ASSERT_MESSAGE( "test for remove function: remove a directory by its system path, and check its existence.",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_INVAL == nError1 )"
, "test for remove function: remove a directory by its system path, and check its existence."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5939 ) ) )
5939 ( osl::FileBase::E_INVAL == nError1 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_INVAL == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_INVAL == nError1 )"
, "test for remove function: remove a directory by its system path, and check its existence."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5939 ) ) )
;
5940 }
5941
5942 void remove_003()
5943 {
5944 //try to remove a non-existed directory
5945 nError1 = ::osl::Directory::remove( aTmpName6 );
5946
5947 CPPUNIT_ASSERT_MESSAGE( "test for remove function: try to remove a non-existed directory.",( CppUnit::Asserter::failIf( !(( osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_NOENT == nError1 )"
, "test for remove function: try to remove a non-existed directory."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5948 ) ) )
5948 ( osl::FileBase::E_NOENT == nError1 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_NOENT == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_NOENT == nError1 )"
, "test for remove function: try to remove a non-existed directory."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5948 ) ) )
;
5949 }
5950
5951 void remove_004()
5952 {
5953 createTestFile( aTmpName6 );
5954 sal_Bool bExist = ifFileExist( aTmpName6 );
5955 //try to remove file.
5956 nError1 = ::osl::Directory::remove( aTmpName6 );
5957 deleteTestFile( aTmpName6 );
5958
5959 CPPUNIT_ASSERT_MESSAGE( "test for remove function: try to remove a file but not directory.",( CppUnit::Asserter::failIf( !(bExist == ((sal_Bool)1) &&
(( osl::FileBase::E_NOTDIR == nError1 ) || ( osl::FileBase::E_NOENT
== nError1 ))), CppUnit::Message( "assertion failed", "Expression: "
"bExist == sal_True &&(( osl::FileBase::E_NOTDIR == nError1 ) || ( osl::FileBase::E_NOENT == nError1 ))"
, "test for remove function: try to remove a file but not directory."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5960 ) ) )
5960 bExist == sal_True &&(( osl::FileBase::E_NOTDIR == nError1 ) || ( osl::FileBase::E_NOENT == nError1 )) )( CppUnit::Asserter::failIf( !(bExist == ((sal_Bool)1) &&
(( osl::FileBase::E_NOTDIR == nError1 ) || ( osl::FileBase::E_NOENT
== nError1 ))), CppUnit::Message( "assertion failed", "Expression: "
"bExist == sal_True &&(( osl::FileBase::E_NOTDIR == nError1 ) || ( osl::FileBase::E_NOENT == nError1 ))"
, "test for remove function: try to remove a file but not directory."
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5960 ) ) )
;
5961 }
5962
5963 void remove_005()
5964 {
5965 createTestDirectory( aTmpName3 );
5966 createTestFile( aTmpName4 );
5967 nError1 = ::osl::Directory::remove( aTmpName3 );
5968 deleteTestFile( aTmpName4 );
5969 deleteTestDirectory( aTmpName3 );
5970 ::rtl::OString sError = "test for remove function: try to remove a directory that is not empty.";
5971 sError += errorToStr( nError1 ).getStr();
5972#if defined ( SOLARIS )
5973 //on UNX, the implementation uses rmdir(), which EEXIST is thrown on Solaris when the directory is not empty, refer to: 'man -s 2 rmdir', while on linux, ENOTEMPTY is thrown.
5974 //EEXIST The directory contains entries other than those for "." and "..".
5975 printf("#Solaris test\n");
5976 CPPUNIT_ASSERT_MESSAGE( sError.getStr(), ( osl::FileBase::E_EXIST == nError1 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_EXIST == nError1
)), CppUnit::Message( "assertion failed", "Expression: " "( osl::FileBase::E_EXIST == nError1 )"
, sError.getStr() ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5976 ) ) )
;
5977#else
5978 CPPUNIT_ASSERT_MESSAGE( sError.getStr(), ( osl::FileBase::E_NOTEMPTY == nError1 ) )( CppUnit::Asserter::failIf( !(( osl::FileBase::E_NOTEMPTY ==
nError1 )), CppUnit::Message( "assertion failed", "Expression: "
"( osl::FileBase::E_NOTEMPTY == nError1 )", sError.getStr() )
, CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 5978 ) ) )
;
5979#endif
5980 }
5981
5982 CPPUNIT_TEST_SUITE( remove )public: typedef remove TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(remove) ); return testNamer; } public: typedef
CppUnit::TestSuiteBuilderContext<TestFixtureType> TestSuiteBuilderContextType
; static void addTestsToSuite( CppUnit::TestSuiteBuilderContextBase
&baseContext ) { TestSuiteBuilderContextType context( baseContext
)
;
5983 CPPUNIT_TEST( remove_001 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "remove_001"), &TestFixtureType
::remove_001, context.makeFixture() ) ) )
;
5984 CPPUNIT_TEST( remove_002 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "remove_002"), &TestFixtureType
::remove_002, context.makeFixture() ) ) )
;
5985 CPPUNIT_TEST( remove_003 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "remove_003"), &TestFixtureType
::remove_003, context.makeFixture() ) ) )
;
5986 CPPUNIT_TEST( remove_004 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "remove_004"), &TestFixtureType
::remove_004, context.makeFixture() ) ) )
;
5987 CPPUNIT_TEST( remove_005 )context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "remove_005"), &TestFixtureType
::remove_005, context.makeFixture() ) ) )
;
5988 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
5989 };// class remove
5990
5991 //########################################
5992 // TEST Directory::createPath
5993 //########################################
5994
5995 #ifdef WNT
5996 # define PATH_BUFFER_SIZE4096 MAX_PATH
5997 #else
5998 # define PATH_BUFFER_SIZE4096 PATH_MAX4096
5999 #endif
6000
6001#define TEST_PATH_POSTFIX"hello/world" "hello/world"
6002
6003 //########################################
6004 OUString get_test_path()
6005 {
6006 static OUString test_path;
6007 if (test_path.isEmpty())
6008 {
6009 OUString tmp;
6010 FileBase::RC rc = FileBase::getTempDirURL(tmp);
6011
6012 CPPUNIT_ASSERT_MESSAGE( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Getting the location of TMP dir failed" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6016
) ) )
6013 (( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Getting the location of TMP dir failed" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6016
) ) )
6014 "Getting the location of TMP dir failed",( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Getting the location of TMP dir failed" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6016
) ) )
6015 rc == FileBase::E_None( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Getting the location of TMP dir failed" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6016
) ) )
6016 )( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Getting the location of TMP dir failed" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6016
) ) )
;
6017
6018 OUString system_path;
6019 rc = FileBase::getSystemPathFromFileURL(tmp, system_path);
6020
6021 CPPUNIT_ASSERT_MESSAGE( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the TMP dir to system path" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6025
) ) )
6022 (( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the TMP dir to system path" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6025
) ) )
6023 "Cannot convert the TMP dir to system path",( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the TMP dir to system path" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6025
) ) )
6024 rc == FileBase::E_None( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the TMP dir to system path" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6025
) ) )
6025 )( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the TMP dir to system path" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6025
) ) )
;
6026
6027 OString tmp_x(rtl::OUStringToOString(system_path, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76)) ));
6028 if (tmp_x.lastIndexOf('/') != (tmp_x.getLength() - 1))
6029 tmp_x += rtl::OString('/');
6030
6031#if !defined(WNT) && !defined(ANDROID)
6032 // FIXME would be nice to create unique dir even on Windows
6033 tmp_x += rtl::OString("XXXXXX");
6034 char *out = mkdtemp(const_cast<char*>(tmp_x.getStr()));
6035
6036 CPPUNIT_ASSERT_MESSAGE( CppUnit::Asserter::failIf( !(out != __null), CppUnit::Message
( "assertion failed", "Expression: " "out != NULL", "mkdtemp call failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6040 ) ) )
6037 (( CppUnit::Asserter::failIf( !(out != __null), CppUnit::Message
( "assertion failed", "Expression: " "out != NULL", "mkdtemp call failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6040 ) ) )
6038 "mkdtemp call failed",( CppUnit::Asserter::failIf( !(out != __null), CppUnit::Message
( "assertion failed", "Expression: " "out != NULL", "mkdtemp call failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6040 ) ) )
6039 out != NULL( CppUnit::Asserter::failIf( !(out != __null), CppUnit::Message
( "assertion failed", "Expression: " "out != NULL", "mkdtemp call failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6040 ) ) )
6040 )( CppUnit::Asserter::failIf( !(out != __null), CppUnit::Message
( "assertion failed", "Expression: " "out != NULL", "mkdtemp call failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6040 ) ) )
;
6041
6042 tmp_x += rtl::OString('/');
6043#endif
6044 tmp_x += rtl::OString(TEST_PATH_POSTFIX"hello/world");
6045
6046 rc = FileBase::getFileURLFromSystemPath(rtl::OStringToOUString(tmp_x, RTL_TEXTENCODING_UTF8(((rtl_TextEncoding) 76))), test_path);
6047
6048 CPPUNIT_ASSERT_MESSAGE( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the system path back to an URL" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6052 ) ) )
6049 (( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the system path back to an URL" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6052 ) ) )
6050 "Cannot convert the system path back to an URL",( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the system path back to an URL" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6052 ) ) )
6051 rc == FileBase::E_None( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the system path back to an URL" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6052 ) ) )
6052 )( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "Cannot convert the system path back to an URL" ), CppUnit::
SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6052 ) ) )
;
6053 }
6054 return test_path;
6055 }
6056
6057 //########################################
6058 void rm_test_path(const OUString& path)
6059 {
6060 sal_Unicode buffer[PATH_BUFFER_SIZE4096];
6061 memcpy(buffer, path.getStr(), (path.getLength() + 1) * sizeof(sal_Unicode));
6062
6063 sal_Int32 i = rtl_ustr_lastIndexOfChar(buffer, '/');
6064 if (i == path.getLength())
6065 buffer[i] = 0;
6066
6067 Directory::remove(buffer);
6068
6069 i = rtl_ustr_lastIndexOfChar(buffer, '/');
6070 buffer[i] = 0;
6071 Directory::remove(buffer);
6072 }
6073
6074 //########################################
6075 class DirCreatedObserver : public DirectoryCreationObserver
6076 {
6077 public:
6078 DirCreatedObserver() : i(0)
6079 {
6080 }
6081
6082 virtual void DirectoryCreated(const rtl::OUString& /*aDirectoryUrl*/)
6083 {
6084 i++;
6085 };
6086
6087 int number_of_dirs_created() const
6088 {
6089 return i;
6090 }
6091
6092 private:
6093 int i;
6094 };
6095
6096
6097 //########################################
6098 class createPath : public CppUnit::TestFixture
6099 {
6100 public:
6101 //##########################################
6102 createPath()
6103 {}
6104
6105 //##########################################
6106 void with_relative_path()
6107 {
6108 FileBase::RC rc = Directory::createPath( OUString(TEST_PATH_POSTFIX"hello/world"));
6109
6110
6111 CPPUNIT_ASSERT_MESSAGE( CppUnit::Asserter::failIf( !(rc == FileBase::E_INVAL), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_INVAL"
, "osl_createDirectoryPath contract broken" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6115
) ) )
6112 (( CppUnit::Asserter::failIf( !(rc == FileBase::E_INVAL), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_INVAL"
, "osl_createDirectoryPath contract broken" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6115
) ) )
6113 "osl_createDirectoryPath contract broken",( CppUnit::Asserter::failIf( !(rc == FileBase::E_INVAL), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_INVAL"
, "osl_createDirectoryPath contract broken" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6115
) ) )
6114 rc == FileBase::E_INVAL( CppUnit::Asserter::failIf( !(rc == FileBase::E_INVAL), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_INVAL"
, "osl_createDirectoryPath contract broken" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6115
) ) )
6115 )( CppUnit::Asserter::failIf( !(rc == FileBase::E_INVAL), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_INVAL"
, "osl_createDirectoryPath contract broken" ), CppUnit::SourceLine
( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx", 6115
) ) )
;
6116 }
6117
6118 //##########################################
6119 void without_callback()
6120 {
6121 OUString tp_url = get_test_path();
6122
6123 rm_test_path(tp_url);
6124
6125 FileBase::RC rc = Directory::createPath(tp_url);
6126
6127 rm_test_path(tp_url);
6128
6129 CPPUNIT_ASSERT_MESSAGE( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "osl_createDirectoryPath failed" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6133 ) ) )
6130 (( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "osl_createDirectoryPath failed" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6133 ) ) )
6131 "osl_createDirectoryPath failed",( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "osl_createDirectoryPath failed" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6133 ) ) )
6132 rc == FileBase::E_None( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "osl_createDirectoryPath failed" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6133 ) ) )
6133 )( CppUnit::Asserter::failIf( !(rc == FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc == FileBase::E_None"
, "osl_createDirectoryPath failed" ), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6133 ) ) )
;
6134 }
6135
6136 //##########################################
6137 void with_callback()
6138 {
6139 OUString tp_url = get_test_path();
6140
6141 rm_test_path(tp_url);
6142
6143 DirCreatedObserver* observer = new DirCreatedObserver;
6144 FileBase::RC rc = Directory::createPath(tp_url, observer);
6145 int nDirs = observer->number_of_dirs_created();
6146 delete observer;
6147
6148 rm_test_path(tp_url);
6149
6150 CPPUNIT_ASSERT_MESSAGE( CppUnit::Asserter::failIf( !((rc == FileBase::E_None) &&
(nDirs > 0)), CppUnit::Message( "assertion failed", "Expression: "
"(rc == FileBase::E_None) && (nDirs > 0)", "osl_createDirectoryPath failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6154 ) ) )
6151 (( CppUnit::Asserter::failIf( !((rc == FileBase::E_None) &&
(nDirs > 0)), CppUnit::Message( "assertion failed", "Expression: "
"(rc == FileBase::E_None) && (nDirs > 0)", "osl_createDirectoryPath failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6154 ) ) )
6152 "osl_createDirectoryPath failed",( CppUnit::Asserter::failIf( !((rc == FileBase::E_None) &&
(nDirs > 0)), CppUnit::Message( "assertion failed", "Expression: "
"(rc == FileBase::E_None) && (nDirs > 0)", "osl_createDirectoryPath failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6154 ) ) )
6153 (rc == FileBase::E_None) && (nDirs > 0)( CppUnit::Asserter::failIf( !((rc == FileBase::E_None) &&
(nDirs > 0)), CppUnit::Message( "assertion failed", "Expression: "
"(rc == FileBase::E_None) && (nDirs > 0)", "osl_createDirectoryPath failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6154 ) ) )
6154 )( CppUnit::Asserter::failIf( !((rc == FileBase::E_None) &&
(nDirs > 0)), CppUnit::Message( "assertion failed", "Expression: "
"(rc == FileBase::E_None) && (nDirs > 0)", "osl_createDirectoryPath failed"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6154 ) ) )
;
6155
6156 }
6157
6158#ifdef WNT
6159
6160 //##########################################
6161 char* get_unused_drive_letter()
6162 {
6163 static char m_aBuff[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
6164
6165 DWORD ld = GetLogicalDrives();
6166 DWORD i = 4;
6167 DWORD j = 2;
6168
6169 while ((ld & i) && (i > 1))
6170 { i = i << 1; j++; }
6171
6172 if (i > 2)
6173 return m_aBuff + j;
6174
6175 return NULL__null;
6176 }
6177
6178 //##########################################
6179 void at_invalid_logical_drive()
6180 {
6181 char* drv = get_unused_drive_letter();
6182 char buff[PATH_BUFFER_SIZE4096];
6183 memset(buff, 0, sizeof(buff));
6184
6185 strncpy(buff, drv, 1);
6186 strcat(buff, ":\\");
6187 strcat(buff, TEST_PATH_POSTFIX"hello/world");
6188
6189 OUString path = OUString::createFromAscii(buff);
6190 OUString tp_url;
6191 FileBase::getFileURLFromSystemPath(path, tp_url);
6192
6193 FileBase::RC rc = Directory::createPath(tp_url);
6194
6195 CPPUNIT_ASSERT_MESSAGE( CppUnit::Asserter::failIf( !(rc != FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc != FileBase::E_None"
, "osl_createDirectoryPath doesn't fail on unused logical drive letters"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6199 ) ) )
6196 (( CppUnit::Asserter::failIf( !(rc != FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc != FileBase::E_None"
, "osl_createDirectoryPath doesn't fail on unused logical drive letters"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6199 ) ) )
6197 "osl_createDirectoryPath doesn't fail on unused logical drive letters",( CppUnit::Asserter::failIf( !(rc != FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc != FileBase::E_None"
, "osl_createDirectoryPath doesn't fail on unused logical drive letters"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6199 ) ) )
6198 rc != FileBase::E_None( CppUnit::Asserter::failIf( !(rc != FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc != FileBase::E_None"
, "osl_createDirectoryPath doesn't fail on unused logical drive letters"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6199 ) ) )
6199 )( CppUnit::Asserter::failIf( !(rc != FileBase::E_None), CppUnit
::Message( "assertion failed", "Expression: " "rc != FileBase::E_None"
, "osl_createDirectoryPath doesn't fail on unused logical drive letters"
), CppUnit::SourceLine( "/usr/local/src/libreoffice/sal/qa/osl/file/osl_File.cxx"
, 6199 ) ) )
;
6200 }
6201#endif /* WNT */
6202
6203 CPPUNIT_TEST_SUITE(createPath)public: typedef createPath TestFixtureType; private: static const
CppUnit::TestNamer &getTestNamer__() { static CppUnit::TestNamer
testNamer( typeid(createPath) ); return testNamer; } public:
typedef CppUnit::TestSuiteBuilderContext<TestFixtureType>
TestSuiteBuilderContextType; static void addTestsToSuite( CppUnit
::TestSuiteBuilderContextBase &baseContext ) { TestSuiteBuilderContextType
context( baseContext )
;
6204 CPPUNIT_TEST(with_relative_path)context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "with_relative_path"), &TestFixtureType
::with_relative_path, context.makeFixture() ) ) )
;
6205 CPPUNIT_TEST(without_callback)context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "without_callback"), &TestFixtureType
::without_callback, context.makeFixture() ) ) )
;
6206 CPPUNIT_TEST(with_callback)context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "with_callback"), &TestFixtureType
::with_callback, context.makeFixture() ) ) )
;
6207#ifdef WNT
6208 CPPUNIT_TEST(at_invalid_logical_drive)context.addTest( ( new CppUnit::TestCaller<TestFixtureType
>( context.getTestNameFor( "at_invalid_logical_drive"), &
TestFixtureType::at_invalid_logical_drive, context.makeFixture
() ) ) )
;
6209#endif
6210 CPPUNIT_TEST_SUITE_END()} static CppUnit::TestSuite *suite() { const CppUnit::TestNamer
&namer = getTestNamer__(); std::auto_ptr<CppUnit::TestSuite
> suite( new CppUnit::TestSuite( namer.getFixtureName() ))
; CppUnit::ConcretTestFixtureFactory<TestFixtureType> factory
; CppUnit::TestSuiteBuilderContextBase context( *suite.get(),
namer, factory ); TestFixtureType::addTestsToSuite( context )
; return suite.release(); } private: typedef int CppUnitDummyTypedefForSemiColonEnding__
;
6211
6212 }; // class createPath
6213
6214 // -----------------------------------------------------------------------------
6215 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::ctors )static CppUnit::AutoRegisterSuite< osl_Directory::ctors >
autoRegisterRegistry__6215
;
6216 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::open )static CppUnit::AutoRegisterSuite< osl_Directory::open >
autoRegisterRegistry__6216
;
6217 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::isOpen )static CppUnit::AutoRegisterSuite< osl_Directory::isOpen >
autoRegisterRegistry__6217
;
6218 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::close )static CppUnit::AutoRegisterSuite< osl_Directory::close >
autoRegisterRegistry__6218
;
6219 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::reset )static CppUnit::AutoRegisterSuite< osl_Directory::reset >
autoRegisterRegistry__6219
;
6220 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::getNextItem )static CppUnit::AutoRegisterSuite< osl_Directory::getNextItem
> autoRegisterRegistry__6220
;
6221 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::getVolumeInfo )static CppUnit::AutoRegisterSuite< osl_Directory::getVolumeInfo
> autoRegisterRegistry__6221
;
6222 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::create )static CppUnit::AutoRegisterSuite< osl_Directory::create >
autoRegisterRegistry__6222
;
6223 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::remove )static CppUnit::AutoRegisterSuite< osl_Directory::remove >
autoRegisterRegistry__6223
;
6224 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Directory::createPath )static CppUnit::AutoRegisterSuite< osl_Directory::createPath
> autoRegisterRegistry__6224
;
6225}// namespace osl_Directory
6226
6227
6228
6229CPPUNIT_PLUGIN_IMPLEMENT()extern "C" __attribute__ ((visibility("default"))) CppUnitTestPlugIn
*cppunitTestPlugIn(void) { static CppUnit::TestPlugInDefaultImpl
plugIn; return &plugIn; } typedef char __CppUnitPlugInExportFunctionDummyTypeDef
; int main( int, char *[] ) { return 0; } typedef char __CppUnitPlugInImplementMainDummyTypeDef
;
6230
6231
6232
6233/** get Current PID.
6234*/
6235inline ::rtl::OUString getCurrentPID( )
6236{
6237 //~ Get current PID and turn it into OUString;
6238 int nPID = 0;
6239#ifdef WNT
6240 nPID = GetCurrentProcessId();
6241#else
6242 nPID = getpid();
6243#endif
6244 return ( ::rtl::OUString::valueOf( ( long )nPID ) );
6245}
6246
6247
6248//~ do some clean up work after all test completed.
6249class GlobalObject
6250{
6251 public:
6252 ~GlobalObject()
6253 {
6254 try
6255 {
6256 //~ special clean up task in Windows and Unix seperately;
6257#if ( defined UNX1 )
6258 //~ some clean up task for UNIX OS
6259 ;
6260#else
6261 //~ some clean up task for Windows OS
6262 //~ check if some files are in the way, remove them if necessary.
6263 if ( ifFileExist( aTmpName6 ) == sal_True((sal_Bool)1) )
6264 deleteTestFile( aTmpName6 );
6265 if ( ifFileExist( aTmpName4 ) == sal_True((sal_Bool)1) )
6266 deleteTestFile( aTmpName4 );
6267 if ( checkDirectory( aTmpName4, osl_Check_Mode_Exist ) == sal_True((sal_Bool)1) )
6268 deleteTestDirectory( aTmpName4 );
6269 if ( ifFileExist( aTmpName3 ) == sal_True((sal_Bool)1) )
6270 deleteTestFile( aTmpName3 );
6271 if ( checkDirectory( aTmpName3, osl_Check_Mode_Exist ) == sal_True((sal_Bool)1) )
6272 deleteTestDirectory( aTmpName3 );
6273
6274 ::rtl::OUString aUStr( aUserDirectoryURL );
6275 concatURL( aUStr, aHidURL1 );
6276 if ( ifFileExist( aUStr ) == sal_True((sal_Bool)1) )
6277 deleteTestFile( aUStr );
6278
6279 ::rtl::OUString aUStr1( aRootURL );
6280 concatURL( aUStr1, aTmpName2 );
6281 if ( ifFileExist( aUStr1 ) == sal_True((sal_Bool)1) )
6282 deleteTestFile( aUStr1 );
6283#endif
6284 }
6285 catch (const CppUnit::Exception &e)
6286 {
6287 printf("Exception caught in GlobalObject dtor(). Exception message: '%s'. Source line: %d\n", e.what(), e.sourceLine().lineNumber());
6288 }
6289 catch (...)
6290 {
6291 printf("Exception caught (...) in GlobalObject dtor()\n");
6292 }
6293 }
6294};
6295
6296GlobalObject theGlobalObject;
6297
6298/* vim:set shiftwidth=4 softtabstop=4 expandtab: */