00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "../GeneralInclude/CompilerSwitches.h"
00011
#include "../GeneralInclude/ClassId.h"
00012
#include "../GeneralInclude/TestConstants.h"
00013
#include "../Base/CC_RootObject.h"
00014
#include "../Event/DC_EventRepository.h"
00015
#include "../Telecommand/DC_DummyTelecommandLoader.h"
00016
#include "../Telecommand/CC_TelecommandManager.h"
00017
#include "../System/DC_DummyObsClock.h"
00018
#include "../Telecommand/TelecommandLoader.h"
00019
#include "../Telecommand/DC_DummyTelecommand.h"
00020
#include "TestCaseTelecommandManager_3.h"
00021
00022 TestCaseTelecommandManager_3::TestCaseTelecommandManager_3(
void) :
00023
TestCaseGenericSetUp(ID_TELECOMMANDMANAGER*10+3,"
TestCaseTelecommandManager_3") {
00024
return;
00025 }
00026
00027 void TestCaseTelecommandManager_3::runTestCase(
void) {
00028
00029
00030
DC_EventRepository* pRep =
CC_RootObject::getEventRepository();
00031
00032
00033
CC_TelecommandManager* pTcm =
new CC_TelecommandManager();
00034
00035
00036
TD_ObsTime tcTt1 = 0;
00037
TD_ObsTime tcTt2 = 0;
00038
TD_ObsTime tcTt3 = 0;
00039
TD_TelecommandId tcId1 = 1;
00040
TD_TelecommandId tcId2 = 2;
00041
TD_TelecommandId tcId3 = 3;
00042
00043
00044
DC_DummyObsClock* pClk =
new DC_DummyObsClock();
00045 pClk->
setTime(tcTt1+1);
00046 pClk->
setCycle(0);
00047 pTcm->
setObsClock(pClk);
00048
00049
00050
DC_DummyTelecommand* pTc1 =
new DC_DummyTelecommand();
00051 DC_DummyTelecommand* pTc2 =
new DC_DummyTelecommand();
00052 DC_DummyTelecommand* pTc3 =
new DC_DummyTelecommand();
00053 pTc1->
setTelecommandId(tcId1);
00054 pTc2->
setTelecommandId(tcId2);
00055 pTc3->
setTelecommandId(tcId3);
00056 pTc1->
setTimeTag(tcTt1);
00057 pTc2->
setTimeTag(tcTt2);
00058 pTc3->
setTimeTag(tcTt3);
00059 pTc1->
setExecutionCheckValue(
TC_CANNOT_EXECUTE);
00060 pTc2->
setValidityCheckValue(
NOT_VALID);
00061
00062
00063
DC_DummyTelecommandLoader* pTcl =
new DC_DummyTelecommandLoader();
00064 pTcl->
setSampleTelecommand(0,pTc1);
00065 pTcl->
setSampleTelecommand(1,pTc2);
00066 pTcl->
setSampleTelecommand(2,pTc3);
00067 pTcm->
setTelecommandLoader(pTcl);
00068 pTcl->
setTelecommandManager(pTcm);
00069
00070
00071 pTcm->
setPendingTelecommandListSize(2);
00072
00073
00074
if ( !pTcm->
isObjectConfigured() )
00075 { setTestResult(
TEST_FAILURE,
"Wrong configuration status");
00076
return;
00077 }
00078
00079
00080
00081 pTcl->
activate();
00082 pTcl->
activate();
00083 pRep->
latest();
00084
if ( (pRep->
getEventType() != EVT_TC_NOT_VALID) )
00085 { setTestResult(
TEST_FAILURE,
"Wrong event type");
00086
return;
00087 }
00088
00089
00090
00091
00092
00093 pTcl->
setSampleTelecommand(1,pTc3);
00094 pTcl->
activate();
00095 pTcl->
activate();
00096 pRep->
latest();
00097
if ( (pRep->
getEventType() != EVT_TC_LIST_FULL) )
00098 { setTestResult(
TEST_FAILURE,
"Wrong event type");
00099
return;
00100 }
00101
00102
00103
00104
00105 pTcm->
activate();
00106
if (pTc3->
getExecutionCounter() != 1)
00107 { setTestResult(
TEST_FAILURE,
"Third telecommand was not executed");
00108
return;
00109 }
00110
if (pTc1->
getExecutionCounter() != 0)
00111 { setTestResult(
TEST_FAILURE,
"First telecommand was executed");
00112
return;
00113 }
00114
00115
00116 pRep->
latest();
00117 pRep->
previous();
00118 pRep->
previous();
00119
if ( (pRep->
getEventType() != EVT_TC_EXEC_CHECK_FAIL) )
00120 { setTestResult(
TEST_FAILURE,
"Wrong event type");
00121
return;
00122 }
00123
00124
00125
if ( pTcl->
getAllocationCounter() != 0 )
00126 { setTestResult(
TEST_FAILURE,
"Wrong allocation counter value");
00127
return;
00128 }
00129
00130
00131
00132 pTcl->
activate();
00133 pTcl->
activate();
00134 pTcl->
activate();
00135
if ( pTcm->
getPendingTelecommands()!=2 )
00136 { setTestResult(
TEST_FAILURE,
"Wrong number of pending telecommands");
00137
return;
00138 }
00139
if ( pTcl->
getAllocationCounter() != 2 )
00140 { setTestResult(
TEST_FAILURE,
"Wrong allocation counter value");
00141
return;
00142 }
00143
00144
00145
unsigned int nEvt = pRep->
getCounter();
00146 pTcm->
reset();
00147
if ( pTcm->
getPendingTelecommands()!=0 )
00148 { setTestResult(
TEST_FAILURE,
"Wrong number of pending telecommands");
00149
return;
00150 }
00151
00152
00153
if ( (pRep->
getCounter() != nEvt+2) )
00154 { setTestResult(
TEST_FAILURE,
"Wrong number of events");
00155
return;
00156 }
00157 pRep->
latest();
00158
if ( (pRep->
getEventType() != EVT_TC_ABORTED) )
00159 { setTestResult(
TEST_FAILURE,
"Wrong event type");
00160
return;
00161 }
00162 pRep->
previous();
00163
if ( (pRep->
getEventType() != EVT_TC_ABORTED) )
00164 { setTestResult(
TEST_FAILURE,
"Wrong event type");
00165
return;
00166 }
00167
00168
00169
if ( pTcl->
getAllocationCounter() != 0 )
00170 { setTestResult(
TEST_FAILURE,
"Wrong allocation counter value");
00171
return;
00172 }
00173
00174
00175
00176 pTcl->
activate();
00177 pTcl->
activate();
00178 pTcl->
activate();
00179
if ( pTcm->
getPendingTelecommands()!=2 )
00180 { setTestResult(
TEST_FAILURE,
"Wrong number of pending telecommands");
00181
return;
00182 }
00183
if ( pTcl->
getAllocationCounter() != 2 )
00184 { setTestResult(
TEST_FAILURE,
"Wrong allocation counter value");
00185
return;
00186 }
00187
00188
00189 nEvt = pRep->
getCounter();
00190 pTcm->
abort(pTc1->
getTelecommandId());
00191
if ( pTcm->
getPendingTelecommands()!=1 )
00192 { setTestResult(
TEST_FAILURE,
"Wrong number of pending telecommands");
00193
return;
00194 }
00195
if ( pTcl->
getAllocationCounter() != 1 )
00196 { setTestResult(
TEST_FAILURE,
"Wrong allocation counter value");
00197
return;
00198 }
00199
00200
00201
if ( (pRep->
getCounter() != nEvt+1) )
00202 { setTestResult(
TEST_FAILURE,
"Wrong number of events");
00203
return;
00204 }
00205 pRep->
latest();
00206
if ( (pRep->
getEventType() != EVT_TC_ABORTED) )
00207 { setTestResult(
TEST_FAILURE,
"Wrong event type");
00208
return;
00209 }
00210
00211
00212 pTcm->
abort(pTc3);
00213
if ( pTcm->
getPendingTelecommands()!=0 )
00214 { setTestResult(
TEST_FAILURE,
"Wrong number of pending telecommands");
00215
return;
00216 }
00217
if ( pTcl->
getAllocationCounter() != 0 )
00218 { setTestResult(
TEST_FAILURE,
"Wrong allocation counter value");
00219
return;
00220 }
00221
00222
00223
if ( (pRep->
getCounter() != nEvt+2) )
00224 { setTestResult(
TEST_FAILURE,
"Wrong number of events");
00225
return;
00226 }
00227 pRep->
latest();
00228
if ( (pRep->
getEventType() != EVT_TC_ABORTED) )
00229 { setTestResult(
TEST_FAILURE,
"Wrong event type");
00230
return;
00231 }
00232
00233 setTestResult(
TEST_SUCCESS,
"Test Successful");
00234
return;
00235
00236 }