ctkEATopicWildcardTestSuite_p.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 CTKEATOPICWILDCARDTESTSUITE_P_H
  16. #define CTKEATOPICWILDCARDTESTSUITE_P_H
  17. #include <QObject>
  18. #include <QReadWriteLock>
  19. #include <ctkServiceReference.h>
  20. #include <ctkTestSuiteInterface.h>
  21. #include <service/event/ctkEventHandler.h>
  22. class ctkPluginContext;
  23. struct ctkEventAdmin;
  24. class ctkEATopicWildcardTestHelper : public QObject, public ctkEventHandler
  25. {
  26. Q_OBJECT
  27. Q_INTERFACES(ctkEventHandler)
  28. private:
  29. mutable QReadWriteLock rwlock;
  30. ctkEvent last;
  31. public Q_SLOTS:
  32. void handleEvent(const ctkEvent& event);
  33. public:
  34. ctkEvent clearLastEvent();
  35. ctkEvent lastEvent() const;
  36. };
  37. class ctkEATopicWildcardTestSuite : public QObject,
  38. public ctkTestSuiteInterface
  39. {
  40. Q_OBJECT
  41. Q_INTERFACES(ctkTestSuiteInterface)
  42. public:
  43. ctkEATopicWildcardTestSuite(ctkPluginContext* pc, long eventPluginId, bool useSignalSlot);
  44. Q_SIGNALS:
  45. void syncSignal(const ctkDictionary& event);
  46. private Q_SLOTS:
  47. void initTestCase();
  48. void init();
  49. void cleanup();
  50. /*
  51. * Ensures ctkEventAdmin does not deliver an event published on topic "a/b/c"
  52. * to a ctkEventHandler listening to topic a/b/c/&#42;.
  53. */
  54. void testEventDeliveryForWildcardTopic1();
  55. /*
  56. * Ensures ctkEventAdmin does not deliver an event published on topic "a/b" to
  57. * an ctkEventHandler listening to topic a/b/c/&#42;.
  58. */
  59. void testEventDeliveryForWildcardTopic2();
  60. /*
  61. * Ensures ctkEventAdmin does not deliver an event published on topic "a" to
  62. * an ctkEventHandler listening to topic a/b/c/&#42;.
  63. */
  64. void testEventDeliveryForWildcardTopic3();
  65. /*
  66. * Ensures ctkEventAdmin delivers an event published on topic "a/b/c/d" to an
  67. * ctkEventHandler listening to topic "a/b/c/&#42;".
  68. */
  69. void testEventDeliveryForWildcardTopic4();
  70. /*
  71. * Ensures ctkEventAdmin delivers an event published on topic "a/b/c/d/e" to
  72. * an ctkEventHandler listening to topic "a/b/c/&#42;".
  73. */
  74. void testEventDeliveryForWildcardTopic5();
  75. /*
  76. * Ensures ctkEventAdmin delivers an event published on topic "a/b/c/d/e/f" to
  77. * an ctkEventHandler listening to topic "a/b/c/&#42;".
  78. */
  79. void testEventDeliveryForWildcardTopic6();
  80. /*
  81. * Ensures ctkEventAdmin delivers an event published to topics "a/b/c" and
  82. * "a/b/c/d" to an ctkEventHandler listening to topics "a/b/c" and "a/b/c/&#42;".
  83. */
  84. void testEventDeliveryForWildcardTopic7();
  85. private:
  86. ctkPluginContext* context;
  87. long eventPluginId;
  88. bool useSignalSlot;
  89. ctkEventAdmin* eventAdmin;
  90. ctkServiceReference reference;
  91. };
  92. #endif // CTKEATOPICWILDCARDTESTSUITE_P_H