[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/akonadi/resources/mbox/libmbox
From: Bertjan Broeksema <b.broeksema () home ! nl>
Date: 2009-06-18 12:49:44
Message-ID: 1245329384.114961.29149.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 983481 by bbroeksema:
Make sure that an MBox cannot be locked if not file is loaded.
M +4 -1 mbox.cpp
M +29 -3 tests/mboxtest.cpp
M +1 -0 tests/mboxtest.h
--- trunk/KDE/kdepim/akonadi/resources/mbox/libmbox/mbox.cpp #983480:983481
@@ -202,7 +202,10 @@
bool MBox::lock()
{
- if (d->mLockType == None)
+ if ( d->mMboxFile.fileName().isEmpty() )
+ return false; // We cannot lock if there is no file loaded.
+
+ if ( d->mLockType == None )
return true;
d->mFileLocked = false;
--- trunk/KDE/kdepim/akonadi/resources/mbox/libmbox/tests/mboxtest.cpp #983480:983481
@@ -75,13 +75,40 @@
QVERIFY( mbox1.setLockType( MBox::KDELockFile ) );
}
+void MboxTest::testLockBeforeLoad()
+{
+ // Should fail because it's not known which file to lock.
+ MBox mbox;
+
+ if ( !KStandardDirs::findExe( "lockfile" ).isEmpty() ) {
+ QVERIFY( mbox.setLockType(MBox::ProcmailLockfile) );
+ QVERIFY( !mbox.lock() );
+ }
+
+ if ( !KStandardDirs::findExe("mutt_dotlock").isEmpty() ) {
+ QVERIFY( mbox.setLockType( MBox::MuttDotlock ) );
+ QVERIFY( !mbox.lock() );
+ QVERIFY( mbox.setLockType( MBox::MuttDotlockPrivileged ) );
+ QVERIFY( !mbox.lock() );
+ }
+
+ QVERIFY( mbox.setLockType( MBox::None ) );
+ QVERIFY( !mbox.lock() );
+
+ QEXPECT_FAIL("", "KDELockFile method is not yet implmented", Continue);
+ QVERIFY( mbox.setLockType( MBox::KDELockFile ) );
+ QVERIFY( !mbox.lock() );
+}
+
void MboxTest::testProcMailLock()
{
- /*
// It really only makes sense to test this if the lockfile executable can be
// found.
+ /*
MBox mbox(fileName(), true);
- mbox.setLockType(MBox::ProcmailLockfile);
+
+ 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);
@@ -91,7 +118,6 @@
} else {
QVERIFY(!QFile(fileName() + ".lock").exists());
QVERIFY(mbox.open() != 0);
- QEXPECT_FAIL("", "This only works when procmail is installed.", Continue);
QVERIFY(QFile(fileName() + ".lock").exists());
mbox.close();
QVERIFY(!QFile(fileName() + ".lock").exists());
--- trunk/KDE/kdepim/akonadi/resources/mbox/libmbox/tests/mboxtest.h #983480:983481
@@ -30,6 +30,7 @@
private Q_SLOTS:
void initTestCase();
void testSetLockMethod();
+ void testLockBeforeLoad();
void testProcMailLock();
void cleanupTestCase();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic