ctkPluginFrameworkPerfRegistryTestSuite_p.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 CTKPLUGINFRAMEWORKPERFREGISTRYTESTSUITE_P_H
  16. #define CTKPLUGINFRAMEWORKPERFREGISTRYTESTSUITE_P_H
  17. #include "ctkTestSuiteInterface.h"
  18. #include "ctkServiceRegistration.h"
  19. #include <QDebug>
  20. class ctkPluginContext;
  21. class ctkServiceEvent;
  22. class ctkServiceListener;
  23. class ctkPluginFrameworkPerfRegistryTestSuite : public QObject, public ctkTestSuiteInterface
  24. {
  25. Q_OBJECT
  26. Q_INTERFACES(ctkTestSuiteInterface)
  27. private:
  28. ctkPluginContext* pc;
  29. int nListeners;
  30. int nServices;
  31. int nRegistered;
  32. int nUnregistering;
  33. int nModified;
  34. QList<ctkServiceRegistration> regs;
  35. QList<ctkServiceListener*> listeners;
  36. QList<QObject*> services;
  37. public:
  38. ctkPluginFrameworkPerfRegistryTestSuite(ctkPluginContext* context);
  39. QDebug log()
  40. {
  41. return qDebug() << "registry_perf:";
  42. }
  43. private:
  44. friend class ctkServiceListener;
  45. void addListeners(int n);
  46. void registerServices(int n);
  47. void modifyServices();
  48. void unregisterServices();
  49. private Q_SLOTS:
  50. void initTestCase();
  51. void cleanupTestCase();
  52. void testAddListeners();
  53. void testRegisterServices();
  54. void testModifyServices();
  55. void testUnregisterServices();
  56. };
  57. class ctkServiceListener : public QObject
  58. {
  59. Q_OBJECT
  60. private:
  61. ctkPluginFrameworkPerfRegistryTestSuite* ts;
  62. public:
  63. ctkServiceListener(ctkPluginFrameworkPerfRegistryTestSuite* ts);
  64. protected Q_SLOTS:
  65. void serviceChanged(const ctkServiceEvent& ev);
  66. };
  67. struct IPerfTestService
  68. {
  69. virtual ~IPerfTestService() {}
  70. };
  71. Q_DECLARE_INTERFACE(IPerfTestService, "org.commontk.test.PerfTestService")
  72. class PerfTestService : public QObject, public IPerfTestService
  73. {
  74. Q_OBJECT
  75. Q_INTERFACES(IPerfTestService)
  76. };
  77. #endif // CTKPLUGINFRAMEWORKPERFREGISTRYTESTSUITE_P_H