ctkBusEventTest.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * ctkBusEventTest.cpp
  3. * ctkEventBusTest
  4. *
  5. * Created by Daniele Giunchi on 20/04/10.
  6. * Copyright 2010 B3C. All rights reserved.
  7. *
  8. * See Licence at: http://tiny.cc/QXJ4D
  9. *
  10. */
  11. #include "ctkTestSuite.h"
  12. #include <ctkEventDefinitions.h>
  13. #include <ctkBusEvent.h>
  14. using namespace ctkEventBus;
  15. /**
  16. Class name: ctkBusEventTest
  17. This class implements the test suite for ctkBusEvent.
  18. */
  19. //! <title>
  20. //ctkBusEvent
  21. //! </title>
  22. //! <description>
  23. //ctkBusEvent is the object which contain information in a dictionary structure,
  24. //regarding message between classes through ctkEventBus
  25. //! </description>
  26. class ctkBusEventTest : public QObject {
  27. Q_OBJECT
  28. private Q_SLOTS:
  29. /// Initialize test variables
  30. void initTestCase() {
  31. m_Event = new ctkBusEvent("", ctkDictionary());
  32. }
  33. /// Cleanup test variables memory allocation.
  34. void cleanupTestCase() {
  35. delete m_Event;
  36. }
  37. /// ctkEventDispatcherRemote allocation test case.
  38. void ctkEventAllocationTest();
  39. /// test all the accessors of a ctkBusEvent
  40. void ctkEventAccessorsTest();
  41. private:
  42. ctkBusEvent *m_Event; ///< Test var.
  43. };
  44. void ctkBusEventTest::ctkEventAllocationTest() {
  45. QVERIFY(m_Event != NULL);
  46. }
  47. void ctkBusEventTest::ctkEventAccessorsTest() {
  48. m_Event->setEventType(ctkEventTypeRemote);
  49. QVERIFY(m_Event->eventType() == ctkEventTypeRemote);
  50. QVERIFY(m_Event->isEventLocal() != true);
  51. QString topic = "ctk/level1/level2/level3";
  52. m_Event->setEventTopic(topic);
  53. QCOMPARE(m_Event->eventTopic(), topic);
  54. QVariant var = (*m_Event)[TOPIC];
  55. QString check = var.toString();
  56. QCOMPARE(check, topic);
  57. delete m_Event;
  58. topic = "ctk/lev1/lev2/lev3";
  59. m_Event = new ctkBusEvent(topic, ctkEventTypeLocal, ctkSignatureTypeSignal, this, "testmethod");
  60. QCOMPARE(m_Event->eventTopic(), topic);
  61. }
  62. CTK_REGISTER_TEST(ctkBusEventTest);
  63. #include "ctkBusEventTest.moc"