ctkPluginFrameworkTestSuite_p.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. public:
  28. ctkPluginFrameworkTestSuite(ctkPluginContext* pc);
  29. protected slots:
  30. void frameworkListener(const ctkPluginFrameworkEvent& fwEvent);
  31. void pluginListener(const ctkPluginEvent& event);
  32. void syncPluginListener(const ctkPluginEvent& event);
  33. void serviceListener(const ctkServiceEvent& event);
  34. private slots:
  35. void initTestCase();
  36. void cleanupTestCase();
  37. // test functions
  38. void frame005a();
  39. void frame020a();
  40. void frame025b();
  41. private:
  42. ctkPluginEvent getPluginEvent() const;
  43. ctkPluginEvent getSyncPluginEvent() const;
  44. ctkPluginFrameworkEvent getFrameworkEvent() const;
  45. ctkServiceEvent getServiceEvent() const;
  46. // Check that the expected events have reached the listeners and
  47. // reset the events
  48. bool checkListenerEvents(
  49. bool fwexp, ctkPluginFrameworkEvent::Type fwtype,
  50. bool pexp, ctkPluginEvent::Type ptype,
  51. bool sexp, ctkServiceEvent::Type stype,
  52. QSharedPointer<ctkPlugin> pluginX, ctkServiceReference* servX);
  53. // Check that the expected events have reached the listeners and
  54. // reset the events
  55. bool checkListenerEvents(
  56. const QList<ctkPluginFrameworkEvent>& fwEvts,
  57. const QList<ctkPluginEvent>& pEvts,
  58. const QList<ctkServiceEvent>& seEvts);
  59. // Check that the expected events have reached the listeners and
  60. // reset the events
  61. bool checkSyncListenerEvents(
  62. bool pexp, ctkPluginEvent::Type ptype, ctkPlugin* pX,
  63. ctkServiceReference servX);
  64. // Check that the expected events have reached the listeners and
  65. // reset the events
  66. bool checkSyncListenerEvents(const QList<ctkPluginEvent>& pEvts);
  67. static int nRunCount;
  68. QList<ctkPluginEvent> pluginEvents;
  69. QList<ctkPluginEvent> syncPluginEvents;
  70. QList<ctkPluginFrameworkEvent> frameworkEvents;
  71. QList<ctkServiceEvent> serviceEvents;
  72. int eventDelay;
  73. ctkPluginContext* pc;
  74. QSharedPointer<ctkPlugin> p;
  75. QSharedPointer<ctkPlugin> pA;
  76. };
  77. #endif // CTKPLUGINFRAMEWORKTESTSUITE_P_H