/**
#TEST: Testing for state machine behavior when key2 is raised

The test expects that state 3 is left to reach state 1 independent of the trigger, that is set.
As the trigger is not used for the transition. It is still set after the call to runCycle().

Furthermore the variable st is set to 1 and the variable waitTime is not touched.

As the variable waitTime is smaller than 200, the transition to state 4 does not take place.
*/
void test_sm_afterTest_runCycle_inState3_key2()
{
	AfterTest_Handle handle;

    /* Initialize once and follow the different stages */
    specialInit(&handle, st_afterTest_State3);

    afterTest_Iface_raiseTrigger(&handle.ihandle, key2);

    /* at this point, the run has not completed */
    assert_equals(FALSE, sm_afterTest_runCycle(&handle.startHandle));

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State1, handle.state);
	assert_equals(1, afterTest_getVar_st(&handle));
	assert_equals(0, afterTest_getVar_waitTime(&handle));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(TRUE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));

    /* at this point, the run has not completed */
    assert_equals(TRUE, sm_afterTest_runCycle(&handle.startHandle));

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State1, handle.state);
	assert_equals(1, afterTest_getVar_st(&handle));
	assert_equals(0, afterTest_getVar_waitTime(&handle));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(TRUE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));
}
/**
#TEST:Test for the validation of function sm_afterTest_enter() with state2 as the actual state

This test set the state to st_afterTest_State2 and runs sm_afterTest_enter.
For validation the variables and triggers are tested against the expected values.
*/
void test_sm_afterTest_enter_in_state2()
{
	SM_afterTest_Handle handle;

    /* Test for state 2 */
    /********************/
    specialInit(&handle, st_afterTest_State2);

    /* run the function in question */
	sm_afterTest_enter(&handle.startHandle);

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State2, handle.state);
	assert_equals(2, afterTest_Iface_getVariable(&handle.ihandle, st));
	assert_equals(0, afterTest_Iface_getVariable(&handle.ihandle, waitTime));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));

}
/**
#TEST: Test for the validation of function sm_afterTest_runCycle() with the run to completion ability

This test set the state to st_afterTest_State3 and runs sm_afterTest_runCycle(). It is expected, that
at the first run the function returns FALSE to indicate that the statemachine has not entered a stable
state. As there is a unconditioned transition to state 1. This state is reached after the first run.
Therefor the variable st is set to 1. The variable waitTime is not touched in any kind, as the state 3
is not entered, nor is state 4 entered.

The second call of the function sm_afterTest_runCycle() returns TRUE, as there is no trigger for
a transition.
*/
void test_sm_afterTest_runCycle_inState3_RTC()
{
	AfterTest_Handle handle;

    /* Initialize once and follow the different stages */
    specialInit(&handle, st_afterTest_State3);

    /* run the state machine loop -> the state machine should be finished
       Return value is TRUE */
    assert_equals(FALSE, sm_afterTest_runCycle(&handle.startHandle));

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State1, handle.state);
	assert_equals(1, afterTest_getVar_st(&handle));
	assert_equals(0, afterTest_getVar_waitTime(&handle));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));

    /* run the state machine loop -> the state machine should be finished
       Return value is TRUE */
    assert_equals(TRUE, sm_afterTest_runCycle(&handle.startHandle));

	/* test the results, state, all variables and all triggers */
	assert_equals(st_afterTest_State1, handle.state);
	assert_equals(1, afterTest_getVar_st(&handle));
	assert_equals(0, afterTest_getVar_waitTime(&handle));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, trigger2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key1));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, key2));
	assert_equals(FALSE, afterTest_Iface_isTriggerRaised(&handle.ihandle, timer_afterTest_State1_TO_afterTest_State2_P1));

}
Esempio n. 4
0
CWVOID cwRepertory::initAll()
{
	m_pObjectMonitor = new cwObjectMonitor();

	//this->addValue(gValueWinWidth, cwValueMap(CWUINT(800)));
	//this->addValue(gValueWinHeight, cwValueMap(CWUINT(600)));

	addValue(gValueNearZ, cwValueMap(1.0f));
	addValue(gValueFarZ, cwValueMap(1000.0f));
	addValue(gValueFov, cwValueMap(0.25f*cwMathUtil::cwPI));

	cwPerformanceTimer timer;

	m_pSpatialFactory = new cwSpatialFactory();

	timer.begin();
	m_pRendererFactory = cwRendererFactory::create();
	CW_SAFE_RETAIN(m_pRendererFactory);
	timer.print("render factory");

	//m_pParserManager = cwParserManager::create();
	//CW_SAFE_RETAIN(m_pParserManager);

	timer.begin();
	m_pFileSystem = cwFileSystem::create();
	CW_SAFE_RETAIN(m_pFileSystem);
	timer.print("file system");

	timer.begin();
	m_pResourceLoader = cwResourceLoader::create();
	CW_SAFE_RETAIN(m_pResourceLoader);
	timer.print("resource loader");

	timer.begin();
	m_pEventManager = cwEventManager::create();
	CW_SAFE_RETAIN(m_pEventManager);
	timer.print("event manager");

	timer.begin();
	m_pGeoGenerator = cwGeometryGenerator::create();
	CW_SAFE_RETAIN(m_pGeoGenerator);
	timer.print("geometry generator");

	timer.begin();
	m_pSchedulerManager = cwSchedulerManager::create();
	CW_SAFE_RETAIN(m_pSchedulerManager);
	timer.print("scheduler manager");

	timer.begin();
	m_pTextureManager = cwTextureManager::create();
	CW_SAFE_RETAIN(m_pTextureManager);
	timer.print("texture manager");

	timer.begin();
	specialInit();
	timer.print("special init");

	timer.begin();
	m_pEffectManager = cwEffectManager::create();
	CW_SAFE_RETAIN(m_pEffectManager);
	timer.print("effect manager");

	timer.begin();
	m_pEngine = cwEngine::create();
	CW_SAFE_RETAIN(m_pEngine);
	timer.print("engine");
}