From 0faf38f2ad9672fb46c77cae7317f44c72ebd10e Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 15 Jan 2015 23:08:34 +0100 Subject: Async message queue processing. The Job/Future in Pipeline::newEntity for some reason crashes with async pipeline processing. --- tests/dummyresourcetest.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index ddb59a5..c469796 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp @@ -14,7 +14,7 @@ static void removeFromDisk(const QString &name) { - Akonadi2::Storage store(Akonadi2::Store::storageLocation(), "org.kde.dummy", Akonadi2::Storage::ReadWrite); + Akonadi2::Storage store(Akonadi2::Store::storageLocation(), name, Akonadi2::Storage::ReadWrite); store.removeFromDisk(); } @@ -33,6 +33,9 @@ private Q_SLOTS: void cleanupTestCase() { + removeFromDisk("org.kde.dummy"); + removeFromDisk("org.kde.dummy.userqueue"); + removeFromDisk("org.kde.dummy.synchronizerqueue"); } void testProcessCommand() @@ -60,13 +63,23 @@ private Q_SLOTS: Akonadi2::Commands::FinishCreateEntityBuffer(fbb, location); const QByteArray command(reinterpret_cast(fbb.GetBufferPointer()), fbb.GetSize()); + { + flatbuffers::Verifier verifyer(reinterpret_cast(command.data()), command.size()); + QVERIFY(Akonadi2::Commands::VerifyCreateEntityBuffer(verifyer)); + } + //Actual test Akonadi2::Pipeline pipeline("org.kde.dummy"); + QSignalSpy revisionSpy(&pipeline, SIGNAL(revisionUpdated())); DummyResource resource; resource.configurePipeline(&pipeline); resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, command.size(), &pipeline); - //TODO wait until the pipeline has processed the command - QTest::qWait(1000); + resource.processCommand(Akonadi2::Commands::CreateEntityCommand, command, command.size(), &pipeline); + + QVERIFY(revisionSpy.isValid()); + QTRY_COMPARE(revisionSpy.count(), 2); + QTest::qWait(100); + QCOMPARE(revisionSpy.count(), 2); } // void testResourceSync() -- cgit v1.2.3