blob: 27d40471ae301ab422c37e982f382159629356d4 [file] [log] [blame]
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (c) 2000-2019 Ericsson Telecom AB //
// //
// All rights reserved. This program and the accompanying materials //
// are made available under the terms of the Eclipse Public License v2.0 //
// which accompanies this distribution, and is available at //
// https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html //
///////////////////////////////////////////////////////////////////////////////
module EPTF_StatManager_Test_Testcases {
import from EPTF_CLL_Base_Functions all;
import from EPTF_StatManager_Test_Definitions all;
import from EPTF_StatManager_Test_Functions all;
import from EPTF_CLL_Variable_Functions all;
import from EPTF_CLL_DataSource_Definitions all;
import from EPTF_CLL_DataSource_Functions all;
import from EPTF_CLL_StatManager_Definitions all;
import from EPTF_CLL_StatManager_Functions all;
testcase tc_EPTF_StatManager_Test_FloatSourceFloatRef()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.floatVal := 0.0;
vl_refVarVal.floatVal := 0.0;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='refVarId' value='%refVar::ref%'/>
<dataparam name='redLimit' value='50.0'/>
<dataparam name='yellowLimit' value='25.0'/>
<dataparam name='greenLimit' value='0.0'/>
<dataparam name='defaultColor' value='black'/>
<dataparam name='enableValueInLEDText' value='yes'/>
</params>",
vl_sourceIdx, vl_refIdx);
timer t_wait;
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=110.0});
f_EPTF_Var_adjustContent(vl_refIdx, {floatVal:=100.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout; // EPTF_DataSource_sourceVar.StatManagerTest@StatManagerTest.sourceVar:{ }
f_EPTF_StatManager_Test_checkLED("*\[led:green\]110.0*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=126.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:yellow\]126.0*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=151.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:red\]151.0*");
f_EPTF_Base_stop(pass);
}
testcase tc_EPTF_StatManager_Test_FloatSourceIntRef()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.floatVal := 0.0;
vl_refVarVal.intVal := 0;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='refVarId' value='%refVar::ref%'/>
<dataparam name='redLimit' value='50.0'/>
<dataparam name='yellowLimit' value='25.0'/>
<dataparam name='greenLimit' value='0.0'/>
<dataparam name='defaultColor' value='black'/>
<dataparam name='enableValueInLEDText' value='yes'/>
</params>",
vl_sourceIdx, vl_refIdx);
timer t_wait;
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=110.0});
f_EPTF_Var_adjustContent(vl_refIdx, {intVal:=100});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:green\]110.0*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=126.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:yellow\]126.0*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=151.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:red\]151.0*");
f_EPTF_Base_stop(pass);
}
testcase tc_EPTF_StatManager_Test_IntSourceIntRef()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.intVal := 0;
vl_refVarVal.intVal := 0;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='refVarId' value='%refVar::ref%'/>
<dataparam name='redLimit' value='50.0'/>
<dataparam name='yellowLimit' value='25.0'/>
<dataparam name='greenLimit' value='0.0'/>
<dataparam name='defaultColor' value='black'/>
<dataparam name='enableValueInLEDText' value='yes'/>
</params>",
vl_sourceIdx, vl_refIdx);
timer t_wait;
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=110});
f_EPTF_Var_adjustContent(vl_refIdx, {intVal:=100});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:green\]110*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=126});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:yellow\]126*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=151});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:red\]151*");
f_EPTF_Base_stop(pass);
}
testcase tc_EPTF_StatManager_Test_IntSourceFloatRef()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.intVal := 0;
vl_refVarVal.floatVal := 0.0;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='refVarId' value='%refVar::ref%'/>
<dataparam name='redLimit' value='50.0'/>
<dataparam name='yellowLimit' value='25.0'/>
<dataparam name='greenLimit' value='0.0'/>
<dataparam name='defaultColor' value='black'/>
<dataparam name='enableValueInLEDText' value='yes'/>
</params>",
vl_sourceIdx, vl_refIdx);
timer t_wait;
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=110});
f_EPTF_Var_adjustContent(vl_refIdx, {floatVal:=100.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:green\]110*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=126});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:yellow\]126*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=151});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:red\]151*");
f_EPTF_Base_stop(pass);
}
testcase tc_EPTF_StatManager_Test_NoRef()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.intVal := 0;
vl_refVarVal.floatVal := -1.0;
timer t_wait;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='redLimit' value='50.0'/>
<dataparam name='yellowLimit' value='25.0'/>
<dataparam name='greenLimit' value='0.0'/>
<dataparam name='defaultColor' value='black'/>
<dataparam name='enableValueInLEDText' value='yes'/>
</params>",
vl_sourceIdx, vl_refIdx);
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=12});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:green\]12*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=26});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:yellow\]26*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=51});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:red\]51*");
f_EPTF_Base_stop(pass);
}
testcase tc_EPTF_StatManager_Test_NoLimitList()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.intVal := 0;
vl_refVarVal.floatVal := -1.0;
timer t_wait;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='defaultColor' value='black'/>
<dataparam name='enableValueInLEDText' value='yes'/>
</params>",
vl_sourceIdx, vl_refIdx);
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=12});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:black\]12*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=26});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:black\]26*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=51});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:black\]51*");
f_EPTF_Base_stop(pass);
}
testcase tc_EPTF_StatManager_Test_IllegalFloatInLimitList()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.floatVal := 0.0;
vl_refVarVal.floatVal := -1.0;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='redLimit' value='25'/>
<dataparam name='yellowLimit' value='50.0'/>
<dataparam name='greenLimit' value='80.0'/>
<dataparam name='defaultColor' value='black'/>
<dataparam name='enableValueInLEDText' value='yes'/>
</params>",
vl_sourceIdx, vl_refIdx, "*is not a legal float number!*");
timer t_wait;
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=26.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:black\]26.0*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=52.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:yellow\]52.0*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=88.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:green\]88.0*");
f_EPTF_Base_stop(pass);
}
testcase tc_EPTF_StatManager_Test_UnknownInLimitList()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.floatVal := 0.0;
vl_refVarVal.floatVal := -1.0;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='orangeLimit' value='35.0'/>
<dataparam name='redLimit' value='25.0'/>
<dataparam name='yellowLimit' value='50.0'/>
<dataparam name='greenLimit' value='80.0'/>
<dataparam name='defaultColor' value='black'/>
<dataparam name='enableValueInLEDText' value='yes'/>
</params>",
vl_sourceIdx, vl_refIdx, "*is not a valid parameter name!*");
timer t_wait;
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=26.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:red\]26.0*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=52.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:yellow\]52.0*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=88.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:green\]88.0*");
f_EPTF_Base_stop(pass);
}
testcase tc_EPTF_StatManager_Test_NoLedText()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.intVal := 0;
vl_refVarVal.floatVal := -1.0;
timer t_wait;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='defaultColor' value='black'/>
</params>",
vl_sourceIdx, vl_refIdx);
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=12});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:black\][^0-9]*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=26});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:black\][^0-9]*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {intVal:=51});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:black\][^0-9]*");
f_EPTF_Base_stop(pass);
}
testcase tc_EPTF_StatManager_Test_WrongParValue4LedText()runs on EPTF_StatManager_Test_CT{
var VarVal vl_sourceVarVal, vl_refVarVal;
var integer vl_sourceIdx, vl_refIdx;
vl_sourceVarVal.floatVal := 0.0;
vl_refVarVal.floatVal := -1.0;
f_EPTF_StatManager_Test_init(vl_sourceVarVal, vl_refVarVal, "<params>
<dataparam name='VarId' value='%srcVar::ref%'/>
<dataparam name='redLimit' value='25.0'/>
<dataparam name='yellowLimit' value='50.0'/>
<dataparam name='greenLimit' value='80.0'/>
<dataparam name='defaultColor' value='black'/>
<dataparam name='enableValueInLEDText' value='true'/>
</params>",
vl_sourceIdx, vl_refIdx, "*is not a legal parameter value for:*");
timer t_wait;
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=26.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:red\][^0-9]*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=52.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:yellow\][^0-9]*");
f_EPTF_Var_adjustContent(vl_sourceIdx, {floatVal:=88.0});
t_wait.start(2.0*f_EPTF_Var_getRefreshPeriod(0)+1.0); t_wait.timeout;
f_EPTF_StatManager_Test_checkLED("*\[led:green\][^0-9]*");
f_EPTF_Base_stop(pass);
}
group Help {
type component StatManager_HelpTest_CT extends EPTF_DataSource_CT, EPTF_StatManager_CT {
var boolean v_StatManager_ready := false;
}
function f_EPTF_StatManager_Test_checkStatManagerReady(
in charstring pl_source,
in charstring pl_ptcName
) runs on StatManager_HelpTest_CT {
if (pl_source==c_StatManager_DataSource_sourceId) {
v_StatManager_ready := true;
}
}
function f_EPTF_StatManager_Test_helpCheck(in charstring pl_source := "", in charstring pl_element := "", in charstring pl_expectedPattern := "") runs on StatManager_HelpTest_CT {
var charstring vl_helpTEXT;
var octetstring vl_helpJSON;
vl_helpTEXT := f_EPTF_DataSource_getHelpTEXT(pl_source, pl_element);
action("Help for "&pl_source&": ", vl_helpTEXT);
if (pl_expectedPattern!="") {
// check if the TEXT help contains the pattern:
if(not match(vl_helpTEXT,pattern pl_expectedPattern)) {
setverdict(fail,"The TEXT help does not match the expected pattern: ", match(vl_helpTEXT,pattern pl_expectedPattern));
f_EPTF_Base_stop(none);
}
}
vl_helpJSON := f_EPTF_DataSource_getHelpJSON(pl_source,pl_element);
action("HelpJSON for "&pl_source&": ", vl_helpJSON);
}
testcase tc_EPTF_StatManager_Test_help() runs on StatManager_HelpTest_CT {
f_EPTF_DataSource_init_CT("MTC");
v_StatManager_ready := false;
f_EPTF_DataSource_registerReadyCallback(refers(f_EPTF_StatManager_Test_checkStatManagerReady));
f_EPTF_StatManager_init_CT("StatManager_Test_help"/*, pl_dataSource_compRef := self*/);
timer T_guard, T_alt;
T_guard.start( 100.0 );
T_alt.start( 0.0 );
alt{
[] T_guard.timeout{
setverdict(fail,"Timeout during config");
f_EPTF_Base_stopAll();
}
[v_StatManager_ready] T_alt.timeout{}
};
//StatManager
f_EPTF_StatManager_Test_helpCheck(pl_source := c_StatManager_DataSource_sourceId,pl_expectedPattern := "*Source: \""&c_StatManager_DataSource_sourceId&"\"\n\n*DataElement: \"help\"*")
setverdict(pass);
f_EPTF_Base_stop(none);
}
} //group Help
control {
execute(tc_EPTF_StatManager_Test_FloatSourceFloatRef());
execute(tc_EPTF_StatManager_Test_FloatSourceIntRef());
execute(tc_EPTF_StatManager_Test_IntSourceIntRef());
execute(tc_EPTF_StatManager_Test_IntSourceFloatRef());
execute(tc_EPTF_StatManager_Test_NoRef());
execute(tc_EPTF_StatManager_Test_NoLimitList());
execute(tc_EPTF_StatManager_Test_IllegalFloatInLimitList());
execute(tc_EPTF_StatManager_Test_UnknownInLimitList());
execute(tc_EPTF_StatManager_Test_NoLedText());
execute(tc_EPTF_StatManager_Test_WrongParValue4LedText());
execute(tc_EPTF_StatManager_Test_help());
}
} // end of module