ctkEventAdminPerfTestSuite_p.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKEAPERFTESTSUITE_P_H
  16. #define CTKEAPERFTESTSUITE_P_H
  17. #include "ctkTestSuiteInterface.h"
  18. #include <service/event/ctkEventHandler.h>
  19. #include <ctkServiceRegistration.h>
  20. #include <QDebug>
  21. struct ctkEventAdmin;
  22. class ctkEventAdminPerfTestSuite : public QObject, public ctkTestSuiteInterface
  23. {
  24. Q_OBJECT
  25. Q_INTERFACES(ctkTestSuiteInterface)
  26. private:
  27. ctkPluginContext* pc;
  28. int pluginId;
  29. int nSendEvents;
  30. int nHandlers;
  31. int nEvent1Handled;
  32. int nEvent2Handled;
  33. ctkEventAdmin* eventAdmin;
  34. QList<ctkEventHandler*> handlers;
  35. QList<ctkServiceRegistration> handlerRegistrations;
  36. public:
  37. ctkEventAdminPerfTestSuite(ctkPluginContext* context, int pluginId);
  38. private:
  39. void addHandlers();
  40. void removeHandlers();
  41. void sendEvents();
  42. void postEvents();
  43. private Q_SLOTS:
  44. void initTestCase();
  45. void testSendEvents();
  46. void testPostEvents();
  47. void cleanupTestCase();
  48. };
  49. class TestEventHandler : public QObject, public ctkEventHandler
  50. {
  51. Q_OBJECT
  52. Q_INTERFACES(ctkEventHandler)
  53. private:
  54. int& counter;
  55. public:
  56. TestEventHandler(int& counter);
  57. void handleEvent(const ctkEvent& );
  58. };
  59. #endif // CTKEAPERFTESTSUITE_P_H