[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kio
From: David Faure <faure () kde ! org>
Date: 2007-04-10 0:25:34
Message-ID: 1176164734.292857.7727.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 652050 by dfaure:
kdirlister.h: fixed wrong documentation - found by unit tests
tests: share file/dir/symlink creation code between jobtest, kdirlistertest and \
kdirmodeltest, to avoid duplication. First kdirlister unit test written, more to \
come.
M +0 -2 kio/kdirlister.h
M +1 -0 tests/CMakeLists.txt
M +3 -59 tests/jobtest.cpp
A tests/kdirlistertest.cpp [License: LGPL (v2+)]
A tests/kdirlistertest.h [License: LGPL (v2+)]
M +1 -36 tests/kdirmodeltest.cpp
A tests/kiotesthelper.h [License: LGPL (v2+)]
--- trunk/KDE/kdelibs/kio/kio/kdirlister.h #652049:652050
@@ -436,7 +436,6 @@
/**
* Tell the view that the listing of the directory @p _url is finished.
* There might be other running jobs left.
- * This signal is only emitted if KDirLister is watching more than one directory.
* @param _url the directory URL
*/
void completed( const KUrl& _url );
@@ -449,7 +448,6 @@
/**
* Tell the view that the listing of the directory @p _url was canceled.
* There might be other running jobs left.
- * This signal is only emitted if KDirLister is watching more than one directory.
* @param _url the directory URL
*/
void canceled( const KUrl& _url );
--- trunk/KDE/kdelibs/kio/tests/CMakeLists.txt #652049:652050
@@ -39,6 +39,7 @@
kbookmarktest
kacltest
kdirmodeltest
+ kdirlistertest
)
KIO_BUILD_TESTS(
--- trunk/KDE/kdelibs/kio/tests/jobtest.cpp #652049:652050
@@ -24,7 +24,6 @@
#include <config.h>
#include <kurl.h>
-#include <kde_file.h>
#include <kio/netaccess.h>
#include <kdebug.h>
#include <klocale.h>
@@ -39,15 +38,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <sys/types.h>
-#include <utime.h>
#include <kprotocolinfo.h>
#include <kio/scheduler.h>
#include <kio/directorysizejob.h>
#include <kio/copyjob.h>
+#include "kiotesthelper.h"
QTEST_KDEMAIN( JobTest, GUI )
@@ -84,6 +82,8 @@
void JobTest::initTestCase()
{
+ s_referenceTimeStamp = QDateTime::currentDateTime().addSecs( -30 ); // 30 \
seconds ago +
// Start with a clean base dir
cleanupTestCase();
QDir dir; // TT: why not a static method?
@@ -115,62 +115,6 @@
}
}
-static void setTimeStamp( const QString& path )
-{
-#ifdef Q_OS_UNIX
- // Put timestamp in the past so that we can check that the
- // copy actually preserves it.
- struct timeval tp;
- gettimeofday( &tp, 0 );
- struct utimbuf utbuf;
- utbuf.actime = tp.tv_sec - 30; // 30 seconds ago
- utbuf.modtime = tp.tv_sec - 60; // 60 second ago
- utime( QFile::encodeName( path ), &utbuf );
- kDebug() << "Time changed for " << path << endl;
-#endif
-}
-
-static void createTestFile( const QString& path )
-{
- QFile f( path );
- if ( !f.open( QIODevice::WriteOnly ) )
- kFatal() << "Can't create " << path << endl;
- f.write( QByteArray( "Hello world" ) );
- f.close();
- setTimeStamp( path );
-}
-
-static void createTestSymlink( const QString& path )
-{
- // Create symlink if it doesn't exist yet
- KDE_struct_stat buf;
- if ( KDE_lstat( QFile::encodeName( path ), &buf ) != 0 ) {
- bool ok = symlink( "/IDontExist", QFile::encodeName( path ) ) == 0; // \
broken symlink
- if ( !ok )
- kFatal() << "couldn't create symlink: " << strerror( errno ) << endl;
- QVERIFY( KDE_lstat( QFile::encodeName( path ), &buf ) == 0 );
- QVERIFY( S_ISLNK( buf.st_mode ) );
- } else {
- QVERIFY( S_ISLNK( buf.st_mode ) );
- }
- //qDebug( "symlink %s created", qPrintable( path ) );
- QVERIFY( QFileInfo( path ).isSymLink() );
-}
-
-static void createTestDirectory( const QString& path )
-{
- QDir dir;
- bool ok = dir.mkdir( path );
- if ( !ok && !dir.exists() )
- kFatal() << "couldn't create " << path << endl;
- createTestFile( path + "/testfile" );
-#ifndef Q_WS_WIN
- createTestSymlink( path + "/testlink" );
- QVERIFY( QFileInfo( path + "/testlink" ).isSymLink() );
-#endif
- setTimeStamp( path );
-}
-
void JobTest::enterLoop()
{
QEventLoop eventLoop;
--- trunk/KDE/kdelibs/kio/tests/kdirmodeltest.cpp #652049:652050
@@ -31,45 +31,10 @@
#include <kio/deletejob.h>
#include <kio/netaccess.h>
#include <kdirwatch.h>
+#include "kiotesthelper.h"
QTEST_KDEMAIN( KDirModelTest, NoGUI )
-QDateTime s_referenceTimeStamp;
-
-static void setTimeStamp( const QString& path, const QDateTime& mtime )
-{
-#ifdef Q_OS_UNIX
- // Put timestamp in the past so that we can check that the listing is correct
- struct utimbuf utbuf;
- utbuf.actime = mtime.toTime_t();
- utbuf.modtime = utbuf.actime;
- utime( QFile::encodeName( path ), &utbuf );
- qDebug( "Time changed for %s", qPrintable( path ) );
-#endif
-}
-
-static void createTestFile( const QString& path )
-{
- QFile f( path );
- if ( !f.open( QIODevice::WriteOnly ) )
- kFatal() << "Can't create " << path << endl;
- f.write( QByteArray( "Hello world" ) );
- f.close();
- setTimeStamp( path, s_referenceTimeStamp );
-}
-
-static void createTestDirectory( const QString& path )
-{
- QDir dir;
- bool ok = dir.mkdir( path );
- if ( !ok && !dir.exists() )
- kFatal() << "couldn't create " << path << endl;
- createTestFile( path + "/testfile" );
- //createTestSymlink( path + "/testlink" );
- //QVERIFY( QFileInfo( path + "/testlink" ).isSymLink() );
- setTimeStamp( path, s_referenceTimeStamp );
-}
-
void KDirModelTest::initTestCase()
{
s_referenceTimeStamp = QDateTime::currentDateTime().addSecs( -30 ); // 30 \
seconds ago
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic