ctkPluginFrameworkTestSuite_p.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 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 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. private:
  51. ctkPluginEvent getPluginEvent() const;
  52. ctkPluginEvent getSyncPluginEvent() const;
  53. ctkPluginFrameworkEvent getFrameworkEvent() const;
  54. ctkServiceEvent getServiceEvent() const;
  55. // Check that the expected events have reached the listeners and
  56. // reset the events
  57. bool checkListenerEvents(
  58. bool fwexp, ctkPluginFrameworkEvent::Type fwtype,
  59. bool pexp, ctkPluginEvent::Type ptype,
  60. bool sexp, ctkServiceEvent::Type stype,
  61. QSharedPointer<ctkPlugin> pluginX, ctkServiceReference* servX);
  62. // Check that the expected events have reached the listeners and
  63. // reset the events
  64. bool checkListenerEvents(
  65. const QList<ctkPluginFrameworkEvent>& fwEvts,
  66. const QList<ctkPluginEvent>& pEvts,
  67. const QList<ctkServiceEvent>& seEvts);
  68. // Check that the expected events have reached the listeners and
  69. // reset the events
  70. bool checkSyncListenerEvents(
  71. bool pexp, ctkPluginEvent::Type ptype, QSharedPointer<ctkPlugin> pX,
  72. ctkServiceReference servX);
  73. // Check that the expected events have reached the listeners and
  74. // reset the events
  75. bool checkSyncListenerEvents(const QList<ctkPluginEvent>& pEvts);
  76. static int nRunCount;
  77. QList<ctkPluginEvent> pluginEvents;
  78. QList<ctkPluginEvent> syncPluginEvents;
  79. QList<ctkPluginFrameworkEvent> frameworkEvents;
  80. QList<ctkServiceEvent> serviceEvents;
  81. int eventDelay;
  82. ctkPluginContext* pc;
  83. QSharedPointer<ctkPlugin> p;
  84. QSharedPointer<ctkPlugin> pA;
  85. QSharedPointer<ctkPlugin> pD;
  86. };
  87. class ctkServiceListenerPFW : public QObject
  88. {
  89. Q_OBJECT
  90. public:
  91. ctkServiceEvent getEvent() const;
  92. QList<ctkServiceEvent> getEvents() const;
  93. void clearEvent();
  94. public slots:
  95. void serviceChanged(const ctkServiceEvent& evt);
  96. private:
  97. QList<ctkServiceEvent> events;
  98. };
  99. #endif // CTKPLUGINFRAMEWORKTESTSUITE_P_H