fix delete; test for it

This commit is contained in:
Marco Martin 2011-04-28 23:58:40 +02:00
parent 1ee07ca959
commit 6d6826e603
4 changed files with 31 additions and 1 deletions

View File

@ -94,7 +94,7 @@ void StorageJob::start()
} else if (operationName() == "retrieve") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "retrieve", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
} else if (operationName() == "delete") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "delete", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "deleteEntry", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
} else if (operationName() == "expire") {
QMetaObject::invokeMethod(Plasma::StorageThread::self(), "expire", Qt::QueuedConnection, Q_ARG(QWeakPointer<StorageJob>, me), Q_ARG(const QVariantMap&, params));
} else {

View File

@ -270,6 +270,7 @@ void StorageThread::deleteEntry(QWeakPointer<StorageJob> wcaller, const QVariant
}
const bool success = query.exec();
m_db.commit();
emit newResult(caller, success);
}

View File

@ -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<StorageJob *>(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<StorageJob *>(job);
QVERIFY(storageJob);
if (storageJob) {
QVERIFY(storageJob->exec());
QVERIFY(storageJob->result().type() != QVariant::Bool);
QVERIFY(storageJob->data().isEmpty());
}
}
QTEST_KDEMAIN(StorageTest, NoGUI)

View File

@ -32,6 +32,7 @@ public Q_SLOTS:
private Q_SLOTS:
void store();
void retrieve();
void deleteEntry();
private: