123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- /*=============================================================================
- Library: CTK
- Copyright (c) German Cancer Research Center,
- Division of Medical and Biological Informatics
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- =============================================================================*/
- #ifndef CTKEASCENARIO2TESTSUITE_P_H
- #define CTKEASCENARIO2TESTSUITE_P_H
- #include <QObject>
- #include <QThread>
- #include <QMutex>
- #include <service/event/ctkEventHandler.h>
- #include <ctkTestSuiteInterface.h>
- #include <ctkServiceRegistration.h>
- #include <ctkRuntimeException.h>
- struct ctkEventAdmin;
- class ctkEAScenario2EventConsumer : public QObject, public ctkEventHandler
- {
- Q_OBJECT
- Q_INTERFACES(ctkEventHandler)
- private:
- ctkPluginContext* context;
- /** class variable for service registration */
- ctkServiceRegistration serviceRegistration;
- /** class variable indicating the topics */
- QStringList topicsToConsume;
- /** class variable keeping number of asynchronus message */
- int asynchMessages;
- /** class variable keeping number of synchronus message */
- int synchMessages;
- /** class variable indication the number of synchronous messages to be received */
- int numSyncMessages;
- /** class variable indication the number of asynchronous messages to be received */
- int numAsyncMessages;
- bool error;
- ctkRuntimeException exc;
- QMutex mutex;
- public:
- /**
- * Constructor creates a consumer service
- */
- ctkEAScenario2EventConsumer(ctkPluginContext* pluginContext, const QStringList& topics,
- int numSyncMsg, int numAsyncMsg);
- void runTest();
- void cleanup();
- /**
- * This method takes events from the event admin service.
- */
- void handleEvent(const ctkEvent& event);
- };
- class ctkEAScenario2EventPublisher : public QObject
- {
- Q_OBJECT
- private:
- /** A reference to a service */
- ctkServiceReference serviceReference;
- /** The admin which delivers the events */
- ctkEventAdmin* eventAdmin;
- /** class variable holding plugin context */
- ctkPluginContext* context;
- /** variable holding messages to send */
- int messageTosend;
- /** variable holding the topic to send */
- QStringList topicsToSend;
- QThread thread;
- public:
- ctkEAScenario2EventPublisher(ctkPluginContext* context,
- const QString& name, const QStringList topics,
- int id, int numOfMessage);
- void runTest();
- protected slots:
- void sendEvents();
- void postEvents();
- };
- /**
- * Test suite for testing the requirements specified in the test specification
- * for the EventAdmin service.
- *
- * Check the Topic sorting of events, both synchronous and asynchronous.
- *
- */
- class ctkEAScenario2TestSuite : public QObject, public ctkTestSuiteInterface
- {
- Q_OBJECT
- Q_INTERFACES(ctkTestSuiteInterface)
- private:
- /** plugin context variable */
- ctkPluginContext* pluginContext;
- long eventPluginId;
- QList<ctkEAScenario2EventConsumer*> eventConsumers;
- ctkEAScenario2EventPublisher* eventPublisher;
- public:
- /**
- * Constructor for the TestSuite class.
- *
- * @param context the handle to the frame work
- * @param eventPluginId The id of the plugin implementing the EventAdmin spec
- */
- ctkEAScenario2TestSuite(ctkPluginContext* context, long eventPluginId);
- private slots:
- void initTestCase();
- void cleanupTestCase();
- void testRegisterConsumer();
- void testPublishEvents();
- };
- #endif // CTKEASCENARIO2TESTSUITE_P_H
|