From 6d6826e6030a9cf2cedfac2fd68d037e9a142c33 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Thu, 28 Apr 2011 23:58:40 +0200 Subject: [PATCH] fix delete; test for it --- private/storage.cpp | 2 +- private/storagethread.cpp | 1 + tests/storagetest.cpp | 28 ++++++++++++++++++++++++++++ tests/storagetest.h | 1 + 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/private/storage.cpp b/private/storage.cpp index e65f061ae..746bb3ff2 100644 --- a/private/storage.cpp +++ b/private/storage.cpp @@ -94,7 +94,7 @@ void StorageJob::start() } else if (operationName() == "retrieve") { QMetaObject::invokeMethod(Plasma::StorageThread::self(), "retrieve", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap&, params)); } else if (operationName() == "delete") { - QMetaObject::invokeMethod(Plasma::StorageThread::self(), "delete", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap&, params)); + QMetaObject::invokeMethod(Plasma::StorageThread::self(), "deleteEntry", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap&, params)); } else if (operationName() == "expire") { QMetaObject::invokeMethod(Plasma::StorageThread::self(), "expire", Qt::QueuedConnection, Q_ARG(QWeakPointer, me), Q_ARG(const QVariantMap&, params)); } else { diff --git a/private/storagethread.cpp b/private/storagethread.cpp index 9b5d8281e..b7210d2df 100644 --- a/private/storagethread.cpp +++ b/private/storagethread.cpp @@ -270,6 +270,7 @@ void StorageThread::deleteEntry(QWeakPointer wcaller, const QVariant } const bool success = query.exec(); + m_db.commit(); emit newResult(caller, success); } diff --git a/tests/storagetest.cpp b/tests/storagetest.cpp index abcbeadf1..43ee5581c 100644 --- a/tests/storagetest.cpp +++ b/tests/storagetest.cpp @@ -64,5 +64,33 @@ void StorageTest::retrieve() } } +void StorageTest::deleteEntry() +{ + Storage storage; + KConfigGroup op = storage.operationDescription("delete"); + op.writeEntry("group", "Test"); + Plasma::ServiceJob *job = storage.startOperationCall(op); + StorageJob *storageJob = qobject_cast(job); + + QVERIFY(storageJob); + if (storageJob) { + storageJob->setData(m_data); + QVERIFY(storageJob->exec()); + QVERIFY(storageJob->result().toBool()); + } + + op = storage.operationDescription("retrieve"); + op.writeEntry("group", "Test"); + job = storage.startOperationCall(op); + storageJob = qobject_cast(job); + + QVERIFY(storageJob); + if (storageJob) { + QVERIFY(storageJob->exec()); + QVERIFY(storageJob->result().type() != QVariant::Bool); + QVERIFY(storageJob->data().isEmpty()); + } +} + QTEST_KDEMAIN(StorageTest, NoGUI) diff --git a/tests/storagetest.h b/tests/storagetest.h index c5cd43496..d48f00446 100644 --- a/tests/storagetest.h +++ b/tests/storagetest.h @@ -32,6 +32,7 @@ public Q_SLOTS: private Q_SLOTS: void store(); void retrieve(); + void deleteEntry(); private: