ctkPluginFrameworkTestSuite_p.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 CTKPLUGINFRAMEWORKTESTSUITE_P_H
  16. #define CTKPLUGINFRAMEWORKTESTSUITE_P_H
  17. #include <QObject>
  18. #include <ctkPluginFrameworkEvent.h>
  19. #include <ctkPluginEvent.h>
  20. #include <ctkServiceEvent.h>
  21. #include <ctkTestSuiteInterface.h>
  22. class ctkPluginContext;
  23. class ctkPluginFrameworkTestSuite : public QObject,
  24. public ctkTestSuiteInterface
  25. {
  26. Q_OBJECT
  27. Q_INTERFACES(ctkTestSuiteInterface)
  28. public:
  29. ctkPluginFrameworkTestSuite(ctkPluginContext* pc);
  30. protected Q_SLOTS:
  31. void frameworkListener(const ctkPluginFrameworkEvent& fwEvent);
  32. void pluginListener(const ctkPluginEvent& event);
  33. void syncPluginListener(const ctkPluginEvent& event);
  34. void serviceListener(const ctkServiceEvent& event);
  35. private Q_SLOTS:
  36. void initTestCase();
  37. void cleanupTestCase();
  38. // test functions
  39. void frame005a();
  40. void frame007a();
  41. void frame010a();
  42. void frame018a();
  43. void frame020a();
  44. void frame025b();
  45. void frame030b();
  46. void frame035b();
  47. void frame040a();
  48. void frame042a();
  49. void frame045a();
  50. void frame070a();
  51. private:
  52. ctkPluginEvent getPluginEvent() const;
  53. ctkPluginEvent getSyncPluginEvent() const;
  54. ctkPluginFrameworkEvent getFrameworkEvent() const;
  55. ctkServiceEvent getServiceEvent() const;
  56. // Check that the expected events have reached the listeners and
  57. // reset the events
  58. bool checkListenerEvents(
  59. bool fwexp, ctkPluginFrameworkEvent::Type fwtype,
  60. bool pexp, ctkPluginEvent::Type ptype,
  61. bool sexp, ctkServiceEvent::Type stype,
  62. QSharedPointer<ctkPlugin> pluginX, ctkServiceReference* servX);
  63. // Check that the expected events have reached the listeners and
  64. // reset the events
  65. bool checkListenerEvents(
  66. const QList<ctkPluginFrameworkEvent>& fwEvts,
  67. const QList<ctkPluginEvent>& pEvts,
  68. const QList<ctkServiceEvent>& seEvts);
  69. // Check that the expected events have reached the listeners and
  70. // reset the events
  71. bool checkSyncListenerEvents(
  72. bool pexp, ctkPluginEvent::Type ptype, QSharedPointer<ctkPlugin> pX,
  73. ctkServiceReference servX);
  74. // Check that the expected events have reached the listeners and
  75. // reset the events
  76. bool checkSyncListenerEvents(const QList<ctkPluginEvent>& pEvts);
  77. void clearEvents();
  78. static int nRunCount;
  79. QList<ctkPluginEvent> pluginEvents;
  80. QList<ctkPluginEvent> syncPluginEvents;
  81. QList<ctkPluginFrameworkEvent> frameworkEvents;
  82. QList<ctkServiceEvent> serviceEvents;
  83. int eventDelay;
  84. ctkPluginContext* pc;
  85. QSharedPointer<ctkPlugin> p;
  86. QSharedPointer<ctkPlugin> pA;
  87. QSharedPointer<ctkPlugin> pD;
  88. };
  89. class ctkServiceListenerPFW : public QObject
  90. {
  91. Q_OBJECT
  92. public:
  93. ctkServiceEvent getEvent() const;
  94. QList<ctkServiceEvent> getEvents() const;
  95. void clearEvent();
  96. public Q_SLOTS:
  97. void serviceChanged(const ctkServiceEvent& evt);
  98. private:
  99. QList<ctkServiceEvent> events;
  100. };
  101. #endif // CTKPLUGINFRAMEWORKTESTSUITE_P_H