00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "TestCaseManoeuvreManager_2.h"
00011
#include "../GeneralInclude/ClassId.h"
00012
#include "../GeneralInclude/Constants.h"
00013
#include "../GeneralInclude/CompilerSwitches.h"
00014
#include "../Manoeuvre/DC_DummyConfigurableManoeuvre.h"
00015
#include "../Manoeuvre/CC_ManoeuvreManager.h"
00016
00017
static const int nMan=5;
00018
static const int maxActivations=100;
00019
static const struct {
00020
unsigned int continueToFalse;
00021
unsigned int finishedToTrue;
00022 } manoeuvreStateChange[nMan]={
00023 { 5,4},
00024 { 4,3},
00025 { 6,7},
00026 {10,9},
00027 { 8,9}
00028 };
00029
static const struct {
00030
int activation;
00031
TD_EventType eventType;
00032
unsigned int offset;
00033 } expectedEvent[nMan]={
00034 { 4,EVT_MAN_TERMINATED,2*nMan+1},
00035 { 5,EVT_MAN_TERMINATED,2*nMan+3},
00036 { 7,EVT_MAN_ABORTED, 2*nMan+5},
00037 { 9,EVT_MAN_ABORTED, 2*nMan+7},
00038 {10,EVT_MAN_TERMINATED,2*nMan+9}
00039 };
00040
00041 TestCaseManoeuvreManager_2::TestCaseManoeuvreManager_2(
void) :
00042
TestCaseWithEvtCheck(ID_MANOEUVREMANAGER*10+2,"
TestCaseManoeuvreManager_2") {
00043
return;
00044 }
00045
00046 void TestCaseManoeuvreManager_2::runTestCase(
void) {
00047
CC_ManoeuvreManager *pMM =
new CC_ManoeuvreManager();
00048
const unsigned int nEvt=this->
getNumberOfEvents();
00049
DC_DummyConfigurableManoeuvre *pDCM[nMan];
00050
00051
00052 pMM->
setPendingManoeuvreListSize(nMan);
00053
00054
00055
for (
int i=0;i<nMan;i++) {
00056 pDCM[i]=
new DC_DummyConfigurableManoeuvre();
00057 pDCM[i]->
setInUse(
true);
00058 pMM->
load(pDCM[i]);
00059 pDCM[i]->
setStartCheckStatus(
MAN_CAN_START);
00060 pDCM[i]->
setContinuationCheckStatus(
MAN_CAN_CONTINUE);
00061 pDCM[i]->
setTerminationCheckStatus(
MAN_HAS_NOT_TERMINATED);
00062 }
00063
00064
00065
00066 pMM->
activate();
00067
for (
int i=0;i<nMan;i++) {
00068
if (pDCM[i]->
getInitializationActionCounter()!=1) {
00069 setTestResult(
TEST_FAILURE,
"Failed to initialize the manoeuvres");
00070
return;
00071 }
00072
00073
if (pDCM[i]->
getContinuationActionCounter()!=1) {
00074 setTestResult(
TEST_FAILURE,
"Failed to call doContinue()");
00075
return;
00076 }
00077 }
00078
00079
00080
00081
00082
int activationCalls=1;
00083
00084
do {
00085
00086
for (
int i=0;i<nMan;i++) {
00087
if (pDCM[i]->
isInUse()) {
00088
unsigned int n=pDCM[i]->
getContinuationActionCounter();
00089
00090 pDCM[i]->setStartCheckStatus(
MAN_CAN_START);
00091 pDCM[i]->setContinuationCheckStatus((n<manoeuvreStateChange[i].continueToFalse));
00092 pDCM[i]->setTerminationCheckStatus((n>=manoeuvreStateChange[i].finishedToTrue));
00093 }
00094 }
00095
00096 pMM->
activate();
00097 activationCalls++;
00098
00099
for (
int i=0;i<nMan;i++) {
00100
00101
if (pDCM[i]->
isInUse()) {
00102
if (pDCM[i]->
getContinuationActionCounter()!=activationCalls) {
00103 setTestResult(
TEST_FAILURE,
"Failed to call doContinue()");
00104
return;
00105 }
00106 }
00107
00108
00109
00110
00111
00112
if (expectedEvent[i].activation==activationCalls &&
00113 (!verifySpecificEvent(nEvt+expectedEvent[i].offset,
00114 expectedEvent[i].eventType) ||
00115 !verifyLatestEvent(nEvt+expectedEvent[i].offset+1,
00116 EVT_MAN_UNLOADED))) {
00117
return;
00118 }
00119 }
00120 }
while (pMM->
getPendingManoeuvres()>0 && activationCalls<maxActivations);
00121
00122
if (activationCalls==maxActivations) {
00123 setTestResult(
TEST_FAILURE,
"Maximum number of activations reached");
00124
return;
00125 }
00126
00127 setTestResult(
TEST_SUCCESS,
"Test Successful");
00128
return;
00129 }