v1.9.0 #175
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include <catch2/catch_test_macros.hpp>
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include "../mocks/EventManagerMock.h"
|
||||||
|
|
||||||
TEST_CASE("Thermal Controller", "[ThermalController]") {
|
TEST_CASE("Thermal Controller", "[ThermalController]") {
|
||||||
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
|
const object_id_t THERMAL_CONTROLLER_ID = 0x123;
|
||||||
@ -16,6 +16,10 @@ TEST_CASE("Thermal Controller", "[ThermalController]") {
|
|||||||
|
|
||||||
controller.initializeAfterTaskCreation();
|
controller.initializeAfterTaskCreation();
|
||||||
|
|
||||||
|
EventManagerMock* eventmanager =
|
||||||
|
ObjectManager::instance()->get<EventManagerMock>(objects::EVENT_MANAGER);
|
||||||
|
REQUIRE(eventmanager->isEventInEventList(THERMAL_CONTROLLER_ID, HasModesIF::MODE_INFO) == false);
|
||||||
|
|
||||||
MessageQueueId_t controllerQueue = controller.getCommandQueue();
|
MessageQueueId_t controllerQueue = controller.getCommandQueue();
|
||||||
|
|
||||||
CommandMessage modeMessage;
|
CommandMessage modeMessage;
|
||||||
@ -23,23 +27,21 @@ TEST_CASE("Thermal Controller", "[ThermalController]") {
|
|||||||
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND,
|
ModeMessage::setModeMessage(&modeMessage, ModeMessage::CMD_MODE_COMMAND,
|
||||||
ControllerBase::MODE_NORMAL, HasModesIF::SUBMODE_NONE);
|
ControllerBase::MODE_NORMAL, HasModesIF::SUBMODE_NONE);
|
||||||
|
|
||||||
MessageQueueIF* commandQueue = QueueFactory::instance()->createMessageQueue(
|
MessageQueueIF* commandQueue =
|
||||||
5, MessageQueueMessage::MAX_MESSAGE_SIZE);
|
QueueFactory::instance()->createMessageQueue(5, MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||||
|
|
||||||
commandQueue->sendMessage(controllerQueue,&modeMessage);
|
commandQueue->sendMessage(controllerQueue, &modeMessage);
|
||||||
|
|
||||||
REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK);
|
REQUIRE(controller.performOperation(0) == HasReturnvaluesIF::RETURN_OK);
|
||||||
|
|
||||||
|
eventmanager->clearEventList();
|
||||||
|
|
||||||
thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID);
|
thermalControllerDefinitions::ComponentTemperatures componentTemperatures(THERMAL_CONTROLLER_ID);
|
||||||
|
|
||||||
componentTemperatures.read();
|
componentTemperatures.read();
|
||||||
REQUIRE(componentTemperatures.rw == 0);
|
REQUIRE(componentTemperatures.rw == 0);
|
||||||
|
|
||||||
componentTemperatures.commit();
|
componentTemperatures.commit();
|
||||||
|
|
||||||
ExecutableObjectIF *eventmanager = ObjectManager::instance()->get<ExecutableObjectIF>(objects::EVENT_MANAGER);
|
|
||||||
eventmanager->performOperation();
|
|
||||||
|
|
||||||
|
|
||||||
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
||||||
}
|
}
|
@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
EventManagerMock::EventManagerMock() : EventManager(objects::EVENT_MANAGER) {}
|
EventManagerMock::EventManagerMock() : EventManager(objects::EVENT_MANAGER) {}
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t EventManagerMock::performOperation(uint8_t opCode) {
|
ReturnValue_t EventManagerMock::performOperation(uint8_t opCode) {
|
||||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
while (result == HasReturnvaluesIF::RETURN_OK) {
|
while (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
@ -12,7 +11,53 @@ ReturnValue_t EventManagerMock::performOperation(uint8_t opCode) {
|
|||||||
result = eventReportQueue->receiveMessage(&message);
|
result = eventReportQueue->receiveMessage(&message);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
notifyListeners(&message);
|
notifyListeners(&message);
|
||||||
|
eventList.emplace_back(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::list<EventMessage>* EventManagerMock::getEventList() {
|
||||||
|
// call performOperation() to get all events still in the message Queue into the list
|
||||||
|
this->performOperation(0);
|
||||||
|
return &eventList;
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventManagerMock::clearEventList() { // call performOperation() to get all events still in the
|
||||||
|
// message Queue into the list
|
||||||
|
this->performOperation(0);
|
||||||
|
eventList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EventManagerMock::isEventInEventList(object_id_t object, Event event) {
|
||||||
|
return isEventInEventList(object, event::getEventId(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EventManagerMock::isEventInEventList(object_id_t object, EventId_t eventId) {
|
||||||
|
// call performOperation() to get all events still in the message Queue into the list
|
||||||
|
this->performOperation(0);
|
||||||
|
for (auto iter = eventList.begin(); iter != eventList.end(); iter++) {
|
||||||
|
if ((iter->getReporter() == object) && (iter->getEventId() == eventId)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EventManagerMock::isEventInEventList(object_id_t object, Event event, uint32_t parameter1,
|
||||||
|
uint32_t parameter2) {
|
||||||
|
return isEventInEventList(object, event::getEventId(event), parameter1, parameter2);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EventManagerMock::isEventInEventList(object_id_t object, EventId_t eventId,
|
||||||
|
uint32_t parameter1, uint32_t parameter2) {
|
||||||
|
// call performOperation() to get all events still in the message Queue into the list
|
||||||
|
this->performOperation(0);
|
||||||
|
for (auto iter = eventList.begin(); iter != eventList.end(); iter++) {
|
||||||
|
if ((iter->getReporter() == object) && (iter->getEventId() == eventId) &&
|
||||||
|
(iter->getParameter1() == parameter1) && (iter->getParameter2() == parameter2)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
@ -3,11 +3,25 @@
|
|||||||
|
|
||||||
#include <fsfw/events/EventManager.h>
|
#include <fsfw/events/EventManager.h>
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
|
||||||
class EventManagerMock : public EventManager {
|
class EventManagerMock : public EventManager {
|
||||||
public:
|
public:
|
||||||
EventManagerMock();
|
EventManagerMock();
|
||||||
|
|
||||||
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
||||||
|
|
||||||
|
const std::list<EventMessage>* getEventList();
|
||||||
|
void clearEventList();
|
||||||
|
|
||||||
|
bool isEventInEventList(object_id_t object, Event event);
|
||||||
|
bool isEventInEventList(object_id_t object, Event event, uint32_t parameter1, uint32_t parameter2);
|
||||||
|
|
||||||
|
bool isEventInEventList(object_id_t object, EventId_t eventId);
|
||||||
|
bool isEventInEventList(object_id_t object, EventId_t eventId, uint32_t parameter1, uint32_t parameter2);
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::list<EventMessage> eventList;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* EVENTMANAGERMOCK_H_ */
|
#endif /* EVENTMANAGERMOCK_H_ */
|
Loading…
x
Reference in New Issue
Block a user