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

List:       kde-commits
Subject:    KDE/kdepim/akonadi/resources/mbox/libmbox/tests
From:       Bertjan Broeksema <b.broeksema () home ! nl>
Date:       2009-06-18 13:11:41
Message-ID: 1245330701.299218.2896.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 983527 by bbroeksema:

Reenable the Procmail lock method test.


 M  +26 -17    mboxtest.cpp  
 M  +1 -0      mboxtest.h  


--- trunk/KDE/kdepim/akonadi/resources/mbox/libmbox/tests/mboxtest.cpp #983526:983527
@@ -33,12 +33,18 @@
 
 static const char * testDir = "libmbox-unit-test";
 static const char * testFile = "test-mbox-file";
+static const char * testLockFile = "test-mbox-lock-file";
 
 QString MboxTest::fileName()
 {
   return mTempDir->name() + testFile;
 }
 
+QString MboxTest::lockFileName()
+{
+  return mTempDir->name() + testLockFile;
+}
+
 void MboxTest::initTestCase()
 {
   mTempDir = new KTempDir( KStandardDirs::locateLocal("tmp", testDir ) );
@@ -104,25 +110,28 @@
 {
   // It really only makes sense to test this if the lockfile executable can be
   // found.
-  /*
-  MBox mbox(fileName(), true);
 
-  QEXPECT_FAIL("", "This only works when procmail is installed.", Continue);
-  QVERIFY( mbox.setLockType( MBox::ProcmailLockfile ) );
-  if (!KStandardDirs::findExe("lockfile").isEmpty()) {
-    QVERIFY(!QFile(fileName() + ".lock").exists());
-    QCOMPARE(mbox.open(), 0);
-    QVERIFY(QFile(fileName() + ".lock").exists());
-    mbox.close();
-    QVERIFY(!QFile(fileName() + ".lock").exists());
-  } else {
-    QVERIFY(!QFile(fileName() + ".lock").exists());
-    QVERIFY(mbox.open() != 0);
-    QVERIFY(QFile(fileName() + ".lock").exists());
-    mbox.close();
-    QVERIFY(!QFile(fileName() + ".lock").exists());
+  MBox mbox;
+  if ( !mbox.setLockType( MBox::ProcmailLockfile ) ) {
+    QEXPECT_FAIL( "", "This test only works when procmail is installed.", Abort );
+    QVERIFY( false );
   }
-  */
+
+  QVERIFY( mbox.load( fileName() ) );
+
+  // By default the filename is used as part of the lockfile filename.
+  QVERIFY( !QFile( fileName() + ".lock" ).exists() );
+  QVERIFY( mbox.lock() );
+  QVERIFY( QFile( fileName() + ".lock" ).exists() );
+  QVERIFY( mbox.unlock() );
+  QVERIFY( !QFile( fileName() + ".lock" ).exists() );
+
+  mbox.setLockFile( lockFileName() );
+  QVERIFY( !QFile( lockFileName() ).exists() );
+  QVERIFY( mbox.lock() );
+  QVERIFY( QFile( lockFileName() ).exists() );
+  QVERIFY( mbox.unlock() );
+  QVERIFY( !QFile( lockFileName() ).exists() );
 }
 
 void MboxTest::cleanupTestCase()
--- trunk/KDE/kdepim/akonadi/resources/mbox/libmbox/tests/mboxtest.h #983526:983527
@@ -36,6 +36,7 @@
 
   private:
     QString fileName();
+    QString lockFileName();
 
   private:
     KTempDir *mTempDir;
[prev in list] [next in list] [prev in thread] [next in thread] 

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