From 01adeefb24bf72f1015e93aa5f075f93f56d94da Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 30 Jul 2015 13:43:31 +0200 Subject: Made the pipeline an implementation detail of the resource. This removes one dependency from the Listener and will allow us to test the Listener better. --- tests/dummyresourcebenchmark.cpp | 11 ++++++----- tests/dummyresourcetest.cpp | 8 ++++---- tests/genericresourcetest.cpp | 22 ++++++++-------------- 3 files changed, 18 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index 7d40779..4c649a9 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp @@ -8,11 +8,13 @@ #include "commands.h" #include "entitybuffer.h" #include "synclistresult.h" +#include "pipeline.h" #include "event_generated.h" #include "entity_generated.h" #include "metadata_generated.h" #include "createentity_generated.h" + #include static void removeFromDisk(const QString &name) @@ -94,10 +96,9 @@ private Q_SLOTS: time.start(); int num = 10000; - Akonadi2::Pipeline pipeline("org.kde.dummy.instance1"); - QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated())); - DummyResource resource("org.kde.dummy.instance1"); - resource.configurePipeline(&pipeline); + auto pipeline = QSharedPointer::create("org.kde.dummy.instance1"); + QSignalSpy revisionSpy(pipeline.data(), SIGNAL(revisionUpdated())); + DummyResource resource("org.kde.dummy.instance1", pipeline); flatbuffers::FlatBufferBuilder eventFbb; eventFbb.Clear(); @@ -133,7 +134,7 @@ private Q_SLOTS: const QByteArray command(reinterpret_cast(fbb.GetBufferPointer()), fbb.GetSize()); for (int i = 0; i < num; i++) { - resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, &pipeline); + resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); } auto appendTime = time.elapsed(); diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index 10cd7e3..1a4d6ca 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp @@ -12,6 +12,7 @@ #include "commands.h" #include "entitybuffer.h" #include "resourceconfig.h" +#include "pipeline.h" static void removeFromDisk(const QString &name) { @@ -133,10 +134,9 @@ private Q_SLOTS: void testResourceSync() { - Akonadi2::Pipeline pipeline("org.kde.dummy.instance1"); - DummyResource resource("org.kde.dummy.instance1"); - resource.configurePipeline(&pipeline); - auto job = resource.synchronizeWithSource(&pipeline); + auto pipeline = QSharedPointer::create("org.kde.dummy.instance1"); + DummyResource resource("org.kde.dummy.instance1", pipeline); + auto job = resource.synchronizeWithSource(); //TODO pass in optional timeout? auto future = job.exec(); future.waitForFinished(); diff --git a/tests/genericresourcetest.cpp b/tests/genericresourcetest.cpp index 0b9a5c1..b6f629a 100644 --- a/tests/genericresourcetest.cpp +++ b/tests/genericresourcetest.cpp @@ -14,20 +14,15 @@ class TestResource : public Akonadi2::GenericResource { public: - TestResource(const QByteArray &instanceIdentifier) - : Akonadi2::GenericResource(instanceIdentifier) + TestResource(const QByteArray &instanceIdentifier, QSharedPointer pipeline) + : Akonadi2::GenericResource(instanceIdentifier, pipeline) { } - KAsync::Job synchronizeWithSource(Akonadi2::Pipeline *pipeline) Q_DECL_OVERRIDE + KAsync::Job synchronizeWithSource() Q_DECL_OVERRIDE { return KAsync::null(); } - - void configurePipeline(Akonadi2::Pipeline *pipeline) Q_DECL_OVERRIDE - { - GenericResource::configurePipeline(pipeline); - } }; @@ -89,12 +84,11 @@ private Q_SLOTS: } //Actual test - Akonadi2::Pipeline pipeline("org.kde.test.instance1"); - QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated(qint64))); - TestResource resource("org.kde.test.instance1"); - resource.configurePipeline(&pipeline); - resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, &pipeline); - resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, &pipeline); + auto pipeline = QSharedPointer::create("org.kde.test.instance1"); + QSignalSpy revisionSpy(pipeline.data(), SIGNAL(revisionUpdated(qint64))); + TestResource resource("org.kde.test.instance1", pipeline); + resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); + resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command); QVERIFY(revisionSpy.isValid()); QTRY_COMPARE(revisionSpy.count(), 2); -- cgit v1.2.3