00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
#include "../GeneralInclude/CompilerSwitches.h"
00011
#include "../GeneralInclude/ClassId.h"
00012
#include "../GeneralInclude/BasicTypes.h"
00013
#include "../GeneralInclude/Constants.h"
00014
#include "../FSM/CC_FSM.h"
00015
#include "../FSM/DC_DummyFsmState.h"
00016
#include "../Utilities/TestCaseWithEvtCheck.h"
00017
#include "TestCaseFSM_1.h"
00018
00019 TestCaseFSM_1::TestCaseFSM_1(
void) :
00020
TestCaseWithEvtCheck(ID_FSM*10+1,"
TestCaseFSM_1") {
00021
return;
00022 }
00023
00024 void TestCaseFSM_1::runTestCase(
void) {
00025
00026
CC_FSM* pFsm =
new CC_FSM();
00027
unsigned int nEvt =
getNumberOfEvents();
00028
00029
00030
if ( (pFsm->
getClassId() != ID_FSM) )
00031 { setTestResult(
TEST_FAILURE,
"Wrong class identifier for the FSM class");
00032
return;
00033 }
00034
00035
00036
if ( (pFsm->
isObjectConfigured() ==
CONFIGURED) )
00037 { setTestResult(
TEST_FAILURE,
"Wrong event repository configuration status upon repository creation");
00038
return;
00039 }
00040
00041
00042 pFsm->
setNumberOfStates(4);
00043
if ( (pFsm->
getNumberOfStates() != 4 ) )
00044 { setTestResult(
TEST_FAILURE,
"Wrong number of FSM states");
00045
return;
00046 }
00047
00048
00049
DC_DummyFsmState* pState[4];
00050
for (
TD_FsmStateIndex i=0; i<pFsm->
getNumberOfStates(); i++)
00051 pState[i] =
new DC_DummyFsmState();
00052
for (
TD_FsmStateIndex i=0; i<pFsm->
getNumberOfStates(); i++)
00053 pFsm->
setState(i,pState[i]);
00054
for (
TD_FsmStateIndex i=0; i<pFsm->
getNumberOfStates(); i++)
00055
if (pFsm->
getState(i) != pState[i])
00056 { setTestResult(
TEST_FAILURE,
"Wrong loaded state is reported");
00057
return;
00058 }
00059
00060
00061
if (
isNonNominalCheckAllowed()) {
00062 pFsm->
setState(5,pState[0]);
00063
if ( !verifyLatestEvent(nEvt+1,EVT_ILLEGAL_FS) )
00064
return;
00065 }
00066
00067
00068 pFsm->
reset();
00069
00070
00071
if ( pFsm->
getCurrentState() != 0)
00072 { setTestResult(
TEST_FAILURE,
00073
"Wrong default state");
00074
return;
00075 }
00076
00077
00078
for (
TD_FsmStateIndex i=0; i<pFsm->
getNumberOfStates(); i++)
00079
if ( !pFsm->
isTransitionEnabled(i) )
00080 { setTestResult(
TEST_FAILURE,
00081
"All state transitions should be enabled");
00082
return;
00083 }
00084
00085
00086
if (
isNonNominalCheckAllowed()) {
00087 pFsm->
setState(0,pNULL);
00088
if ( (pFsm->
isObjectConfigured() ==
CONFIGURED) )
00089 { setTestResult(
TEST_FAILURE,
00090
"Wrong FSM configuration status");
00091
return;
00092 }
00093 }
00094
00095
00096 pFsm->
setState(0,pState[0]);
00097
if ( (pFsm->
isObjectConfigured() ==
NOT_CONFIGURED) )
00098 { setTestResult(
TEST_FAILURE,
00099
"Wrong FSM configuration status after configuration was completed");
00100
return;
00101 }
00102
00103 setTestResult(
TEST_SUCCESS,
"Test Successful");
00104
return;
00105 }