[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kio/tests
From:       Ralf Habacker <Ralf.Habacker () freenet ! de>
Date:       2006-12-23 21:10:29
Message-ID: 1166908229.706420.8369.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 616146 by habacker:

more win32 fixes

 M  +67 -8     jobtest.cpp  


--- trunk/KDE/kdelibs/kio/tests/jobtest.cpp #616145:616146
@@ -61,13 +61,21 @@
 
 QString JobTest::otherTmpDir() const
 {
+#ifdef Q_WS_WIN
+    return QDir::tempPath() + "/jobtest/";
+#else
     // This one needs to be on another partition
     return "/tmp/jobtest/";
+#endif
 }
 
 KUrl JobTest::systemTmpDir() const
 {
+#ifdef Q_WS_WIN
+    return KUrl( "system:" + QDir::homePath() + "/.kde-unit-test/jobtest-system/" );
+#else
     return KUrl( "system:/home/.kde-unit-test/jobtest-system/" );
+#endif
 }
 
 QString JobTest::realSystemPath() const
@@ -158,8 +166,10 @@
     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 );
 }
 
@@ -216,7 +226,13 @@
         // The datapump solution ignores mtime, the app has to call \
FileCopyJob::setModificationTime()  QFileInfo srcInfo( src );
         QFileInfo destInfo( dest );
+#ifdef Q_WS_WIN
+        // win32 time may differs in msec part 
+        QCOMPARE( srcInfo.lastModified().toString("dd.MM.yyyy hh:mm"),
+                  destInfo.lastModified().toString("dd.MM.yyyy hh:mm") );
+#else
         QCOMPARE( srcInfo.lastModified(), destInfo.lastModified() );
+#endif
     }
 
     // cleanup and retry with KIO::copy()
@@ -229,7 +245,13 @@
         // check that the timestamp is the same (#24443)
         QFileInfo srcInfo( src );
         QFileInfo destInfo( dest );
+#ifdef Q_WS_WIN
+        // win32 time may differs in msec part 
+        QCOMPARE( srcInfo.lastModified().toString("dd.MM.yyyy hh:mm"),
+                  destInfo.lastModified().toString("dd.MM.yyyy hh:mm") );
+#else
         QCOMPARE( srcInfo.lastModified(), destInfo.lastModified() );
+#endif
     }
 }
 
@@ -263,7 +285,13 @@
         // check that the timestamp is the same (#24443)
         QFileInfo srcInfo( src );
         QFileInfo destInfo( dest );
+#ifdef Q_WS_WIN
+        // win32 time may differs in msec part 
+        QCOMPARE( srcInfo.lastModified().toString("dd.MM.yyyy hh:mm"),
+                  destInfo.lastModified().toString("dd.MM.yyyy hh:mm") );
+#else
         QCOMPARE( srcInfo.lastModified(), destInfo.lastModified() );
+#endif
     }
 }
 
@@ -368,7 +396,9 @@
     QVERIFY( QFile::exists( src ) );
     QVERIFY( QFileInfo( src ).isDir() );
     QVERIFY( QFileInfo( src + "/testfile" ).isFile() );
+#ifndef Q_WS_WIN
     QVERIFY( QFileInfo( src + "/testlink" ).isSymLink() );
+#endif
     KUrl u;
     u.setPath( src );
     KUrl d;
@@ -380,8 +410,9 @@
     QVERIFY( QFileInfo( dest ).isDir() );
     QVERIFY( QFileInfo( dest + "/testfile" ).isFile() );
     QVERIFY( !QFile::exists( src ) ); // not there anymore
-
+#ifndef Q_WS_WIN
     QVERIFY( QFileInfo( dest + "/testlink" ).isSymLink() );
+#endif
 }
 
 void JobTest::moveFileToSamePartition()
@@ -413,25 +444,32 @@
 
 void JobTest::moveSymlinkToOtherPartition()
 {
+#ifndef Q_WS_WIN
     kDebug() << k_funcinfo << endl;
     const QString filePath = homeTmpDir() + "testlink";
     const QString dest = otherTmpDir() + "testlink_moved";
     createTestSymlink( filePath );
     moveLocalSymlink( filePath, dest );
+#endif
 }
 
 void JobTest::moveDirectoryToOtherPartition()
 {
     kDebug() << k_funcinfo << endl;
+#ifndef Q_WS_WIN
     const QString src = homeTmpDir() + "dirFromHome";
     const QString dest = otherTmpDir() + "dirFromHome_moved";
     createTestDirectory( src );
     moveLocalDirectory( src, dest );
+#endif
 }
 
 void JobTest::moveFileNoPermissions()
 {
     kDebug() << k_funcinfo << endl;
+#ifdef Q_WS_WIN
+    kDebug() << "port to win32" << endl;
+#else
     const QString src = "/etc/passwd";
     const QString dest = homeTmpDir() + "passwd";
     QVERIFY( QFile::exists( src ) );
@@ -454,11 +492,15 @@
     // In fact we assume /home is a separate partition, in this test, so:
     QVERIFY( QFile::exists( dest ) );
     QVERIFY( QFile::exists( src ) );
+#endif
 }
 
 void JobTest::moveDirectoryNoPermissions()
 {
     kDebug() << k_funcinfo << endl;
+#ifdef Q_WS_WIN
+    kDebug() << "port to win32" << endl;
+#else
 #if 1
     QString src = "/etc/rc.d";
     if ( !QFile::exists( src ) )
@@ -466,7 +508,7 @@
 #else
     QString src = "/etc";
 #endif
-    const QString dest = homeTmpDir() + "mdnp";
+   const QString dest = homeTmpDir() + "mdnp";
     QVERIFY( QFile::exists( src ) );
     QVERIFY( QFileInfo( src ).isDir() );
     KUrl u;
@@ -483,6 +525,7 @@
     QVERIFY( KIO::NetAccess::lastError() == KIO::ERR_ACCESS_DENIED );
     QVERIFY( QFile::exists( dest ) ); // see moveFileNoPermissions
     QVERIFY( QFile::exists( src ) );
+#endif
 }
 
 void JobTest::listRecursive()
@@ -490,10 +533,11 @@
     // Note: many other tests must have been run before since we rely on the files \
they created  
     const QString src = homeTmpDir();
+#ifndef Q_WS_WIN
     // Add a symlink to a dir, to make sure we don't recurse into those
     bool symlinkOk = symlink( "dirFromHome", QFile::encodeName( src + \
"/dirFromHome_link" ) ) == 0;  QVERIFY( symlinkOk );
-
+#endif
     KIO::ListJob* job = KIO::listRecursive( KUrl(src) );
     job->setUiDelegate( 0 );
     connect( job, SIGNAL( entries( KIO::Job*, const KIO::UDSEntryList& ) ),
@@ -501,12 +545,21 @@
     bool ok = KIO::NetAccess::synchronousRun( job, 0 );
     QVERIFY( ok );
     m_names.sort();
+		QByteArray ref_names = QByteArray( ".,..,"
+            "dirFromHome,dirFromHome/testfile,"
+#ifndef Q_WS_WIN
+            "dirFromHome/testlink,"
+#endif
+            "dirFromHome_copied,"
+            "dirFromHome_copied/dirFromHome,dirFromHome_copied/dirFromHome/testfile,dirFromHome_copied/testfile,"
 +#ifndef Q_WS_WIN
+            "dirFromHome_copied/testlink,dirFromHome_link,"
+#endif
+            "fileFromHome,fileFromHome_copied");
+            
     qDebug( "%s", qPrintable( m_names.join( "," ) ) );
-    QCOMPARE( m_names.join( "," ).toLatin1(), QByteArray( ".,..,"
-            "dirFromHome,dirFromHome/testfile,dirFromHome/testlink,dirFromHome_copied,"
                
-            "dirFromHome_copied/dirFromHome,dirFromHome_copied/dirFromHome/testfile,dirFromHome_copied/dirFromHome/testlink,"
                
-            "dirFromHome_copied/testfile,dirFromHome_copied/testlink,dirFromHome_link,"
                
-            "fileFromHome,fileFromHome_copied" ) );
+    qDebug( "%s", ref_names.data() );
+    QCOMPARE( m_names.join( "," ).toLatin1(), ref_names );
 }
 
 void JobTest::directorySize()
@@ -522,9 +575,15 @@
     kDebug() << "totalSize: " << job->totalSize() << endl;
     kDebug() << "totalFiles: " << job->totalFiles() << endl;
     kDebug() << "totalSubdirs: " << job->totalSubdirs() << endl;
+#ifdef Q_WS_WIN
+    QCOMPARE(job->totalFiles(), 5ULL); // see expected result in listRecursive() \
above +    QCOMPARE(job->totalSubdirs(), 3ULL); // see expected result in \
listRecursive() above +    QVERIFY(job->totalSize() > 54);
+#else
     QCOMPARE(job->totalFiles(), 8ULL); // see expected result in listRecursive() \
                above
     QCOMPARE(job->totalSubdirs(), 4ULL); // see expected result in listRecursive() \
above  QVERIFY(job->totalSize() > 512);
+#endif
 
     // TODO test error case
 }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic