kbLogger 2.0.b1
The automotive ready test and logging program.
ConfigItemTestObject Class Reference

This class defines the API for the TestObject (to).

#include <configitemtestobject.h>

Public Slots

Test related functions.
TestcreateInvisibleTest (QString strTestName, QString strTestFunction, quint32 uTimeout=0, quint32 uRepeatCount=1)
 Creates an invisible Test to be linked in a real test.
 
TestcreateTest (QString strTestName, QString strTestFunction, quint32 uTimeout=0, quint32 uRepeatCount=1)
 Creates a Test.
 
TestcreateTest (Test *pParent, QString strTestName, QString strTestFunction, quint32 uTimeout=0, quint32 uRepeatCount=1)
 Creates a Test.
 
TestgetRunningTest ()
 Gets the currently running test.
 
TestgetTest (int iIndex)
 Gets a visible test.
 
void start ()
 Starts the TestObject to run all configured tests.
 
void stop ()
 Stops the TestObject to cancel all running tests.
 
void pause ()
 Pauses the running test.
 
void resume ()
 Resumes the running test.
 
void prepareRestart ()
 Prepares a restart of the tests by clearing all results and test events.
 
void generateHtmlReport ()
 Generates a HTML TestReport.
 
quint32 getRepeatCount ()
 Retrieves the global repeat count.
 
quint32 getRemainingCount ()
 Retrieves the remaining global repeat count.
 
void setRepeatCount (quint32 uRepeatCount)
 Sets the global repeat count.
 
QString getProjectName ()
 Retrieves the name of the project for which we are testing for.
 
void setProjectName (QString strProjectName)
 Sets the name of the project for which we are testing for.
 
QString getProjectInfo ()
 Retrieves the additional info of the project for which we are testing for.
 
void setProjectInfo (QString strProjectInfo)
 Sets the additional info of the project for which we are testing for.
 
QString getTestName (int iTestIndex)
 Retrieves the name of the given test.
 
QString getTestName ()
 Retrieves the name of the test.
 
void setTestName (QString strTestName)
 Sets the name of the test.
 
QString getTestInfo ()
 Retrieves the additional info of the test.
 
void setTestInfo (QString strTestInfo)
 Sets the additional info of the test.
 
QString getTestVersion ()
 Retrieves the version of the test.
 
void setTestVersion (QString strTestVersion)
 Sets the version of the test.
 
QString getDutName ()
 Retrieves the name of the DUT.
 
void setDutName (QString strDutName)
 Sets the name of the DUT.
 
QString getDutInfo ()
 Retrieves the additional info of the DUT.
 
void setDutInfo (QString strDutInfo)
 Sets the additional info of the DUT.
 
QString getDutVersion ()
 Retrieves the version of the DUT.
 
void setDutVersion (QString strDutVersion)
 Sets the version of the DUT.
 
QString getTesterName ()
 Retrieves the name of the Tester.
 
void setTesterName (QString strTesterName)
 Sets the name of the Tester.
 
DialogTestDialog * createCustomDialog (Test *pTest, QString strHeader, QString strText="")
 Creates a custom TestDialog.
 
void trace (QString strText)
 Send the text to the connected TraceViewer.
 

Member Function Documentation

◆ createCustomDialog

DialogTestDialog * createCustomDialog ( Test * pTest,
QString strHeader,
QString strText = "" )
slot

Creates a custom TestDialog

Example:

var dialog = to.createCustomDialog(test, "Paper change",
"Please change the paper in the printer to another format.\nSelect in the list the correct paper format you choosed.");
dialog.addAnswer("A4");
dialog.addAnswer("Letter");
dialog.setPicture("c:/paper_picture.jpg");
dialog.show();
Parameters
strHeaderThe header text
strTextThe (main) text
Returns
The dialog

◆ createInvisibleTest

Test * createInvisibleTest ( QString strTestName,
QString strTestFunction,
quint32 uTimeout = 0,
quint32 uRepeatCount = 1 )
slot

Creates an invisible test. This test is not shown in the TreeWidget in the ChildWindowTest.

Example:

var invisibleTest1 = to.createInvisibleTest("invisibleTest1", "invisibleTest1", 1000);
trace("invisibleTest1=" + invisibleTest1);
void trace(QString strText)
Send the text to the connected TraceViewer.
Definition configitemtestobject.cpp:3673
Parameters
strTestNameThe name of the test. Must be unique.
strTestFunctionThe name of the function which implements the test. Must be programmed by the user.
uTimeoutThe timeout in ms. If the test is not set to passed nor failed, the test states changes automatically to failed when the timeout occurs.
uRepeatCountThe repeat count of this test. The maximum runtime is uRepeatCount * uTimeout. The test fails if one of the runs has failed.
Returns
A handle to the new created test. 0 if the creations has failed.

◆ createTest [1/2]

Test * createTest ( QString strTestName,
QString strTestFunction,
quint32 uTimeout = 0,
quint32 uRepeatCount = 1 )
slot

Creates a test without a parent (means this will be a top level test).

Example:

var test1 = to.createTest("test1", "test1Function", 1000);
var testCase1 = to.createTest(test1, "testCase1", "testCase1Function", 1000);
function test1Function(testIndex)
{
trace("test1 is running now");
}
function testCase1Function(testIndex)
{
trace("testCase1 is running now");
}
Parameters
strTestNameThe name of the test.
strTestFunctionThe name of the function to call.
uTimeoutThe timeout in ms. If the test is not set to passed nor failed, the test states changes automatically to failed when the timeout occurs.
uRepeatCountThe repeat count of this test. The maximum runtime is uRepeatCount * uTimeout. The test fails if one of the runs has failed.
Returns
Returns a handle to the created test, 0 case of an error.

◆ createTest [2/2]

Test * createTest ( Test * pParent,
QString strTestName,
QString strTestFunction,
quint32 uTimeout = 0,
quint32 uRepeatCount = 1 )
slot

Creates a test with a parent.

Example:

var test1 = to.createTest("test1", "test1Function", 1000);
var testCase1 = to.createTest(test1, "testCase1", "testCase1Function", 1000);
function test1Function(testIndex)
{
trace("test1 is running now");
}
function testCase1Function(testIndex)
{
trace("testCase1 is running now");
}
Parameters
pParentA handle to the parent knot of this test. If 0, this test is a top level test.
strTestNameThe name of the test.
strTestFunctionThe name of the function to call.
uTimeoutThe timeout in ms. If the test is not set to passed nor failed, the test states changes automatically to failed when the timeout occurs.
uRepeatCountThe repeat count of this test. The maximum runtime is uRepeatCount * uTimeout. The test fails if one of the runs has failed.
Returns
Returns a handle to the created test, 0 case of an error.

◆ generateHtmlReport

void generateHtmlReport ( )
slot

Generates a HTML TestReport.

Call this in the testsFinished callback function.

Example:

function testsFinished(totalRuns, failedRuns)
{
to.trace("totalRuns=" + totalRuns + ", failedRuns=" + failedRuns);
to.generateHtmlReport();
}

◆ getDutInfo

QString getDutInfo ( )
slot

Retrieves the additional info of the DUT.

Returns
The DUT info

◆ getDutName

QString getDutName ( )
slot

Retrieves the name of the DUT.

Returns
The name of the DUT.

◆ getDutVersion

QString getDutVersion ( )
slot

Retrieves the version of the DUT.

Returns
The DUT version

◆ getProjectInfo

QString getProjectInfo ( )
slot

Retrieves the additional info of the project for which we are testing for.

Returns
The project info

◆ getProjectName

QString getProjectName ( )
slot

Retrieves the name of the project for which we are testing for.

Returns
The project name

◆ getRemainingCount

quint32 getRemainingCount ( )
slot

Retrieves the remaining global repeat count.

Example:

var repeatCount = to.getRemainingCount(); // Get the remaining repeat count
Returns
The remaining global repeat count

◆ getRepeatCount

quint32 getRepeatCount ( )
slot

Retrieves the global repeat count.

Example:

to.setRepeatCount(100); // Set the global repeat count
var repeatCount = to.getRepeatCount(); // Get the global repeat count
Returns
The RepeatCount.

◆ getRunningTest

Test * getRunningTest ( )
slot

Gets the currently running test. This is useful if you need to decide passed or failed in the processMessage function.

Example:

function processMessage(strTimeStamp, strSender, strPayload, strMetadata)
{
// The actual test shall fail if any assertion is occurring
if(strPayload.search(/assert/i) >= 0)
{
var runningTest = to.getRunningTest();
if(runningTest)
{
runningTest.failed("Assertion found: " + strPayload);
trace("test " + runningTest.getTestName() + " failed: Assertion found: " + strPayload);
}
}
}
Returns
A reference to the Test. Check if 0 is returned (in case of no test is running).

◆ getTest

Test * getTest ( int testIndex)
slot

Gets a visible test Every created test is stored in a list in order of their creation. This testIndex is used as parameter if the ConfigItemTest is calling the test function. This is useful to distinguish the test if they sharing the same test function. This happens implicitly, if you using the addLink function.

Example:

function invisibleTest0Case1Function(testIndex)
{
trace("invisibleTest0Case1Function(" + testIndex + ")");
var t = to.getTest(testIndex);
trace("invisibleTest0Case1Function(" + t + ")");
t.passed("invisibleTest0Case1 successful");
}
Parameters
testIndex
Returns
A reference to the Test

◆ getTesterName

QString getTesterName ( )
slot

Retrieves the name of the tester.

Example:

var testerName = to.getTesterName(); // Get the name of the tester
Returns
The tester name

◆ getTestInfo

QString getTestInfo ( )
slot

Retrieves the additional info of the test.

Returns
The test info

◆ getTestName [1/2]

QString getTestName ( )
slot

Retrieves the name of the test.

Returns
The name of the test.

◆ getTestName [2/2]

QString getTestName ( int iTestIndex)
slot

Retrieves the name of the test.

var test0 = to.createTest("test0", "test0Function"); // Create a test
function test0Function(TestIndex)
{
trace("invisibleTest0Case1Function(" + TestIndex + ")");
var t = to.getTest(TestIndex);
var name = t.getTestName();
var name = to.getTestName(TestIndex);
}
Parameters
iTestIndexThe index of the test of interest
Returns
The name of the test.

◆ getTestVersion

QString getTestVersion ( )
slot

Retrieves the version of the test.

Returns
The test version

◆ pause

void pause ( )
slot

Pauses the TestObject to pause all running tests.

Pauses the TestObject to pause all running tests. The user can call that function from anywhere inside the script, triggered by any event.

Normally all test should run until they are finished or the user is using the tool bar buttons to pauses the tests.

Example:

function anyFunc()
{
trace("anyFunc");
to.pause();
}

◆ prepareRestart

void prepareRestart ( )
slot

Prepares a restart of all tests by clearing all results and all events.

Example:

function start()
{
trace("start");
to.prepareRestart();
to.start();
}
void start()
Starts the TestObject to run all configured tests.
Definition configitemtestobject.cpp:2980

◆ resume

void resume ( )
slot

Resumes the TestObject to resume all paused tests. The user can call that function from anywhere inside the script, triggered by any event.

Normally all test should run until they are finished or the user is using the tool bar buttons to pauses / resumes the tests.

Example:

function anyFunc()
{
trace("anyFunc");
to.resume();
}

◆ setDutInfo

void setDutInfo ( QString strDutInfo)
slot

Sets the additional info of the DUT.

Parameters
strDutInfoThe additional DUT info

◆ setDutName

void setDutName ( QString strDutName)
slot

Sets the name of the DUT.

Parameters
strDutNameThe name of the DUT

◆ setDutVersion

void setDutVersion ( QString strDutVersion)
slot

Sets the version of the DUT.

Parameters
strDutVersionThe version of the DUT

◆ setProjectInfo

void setProjectInfo ( QString strProjectInfo)
slot

Sets the additional info of the project for which we are testing for.

Parameters
strProjectInfoThe project info

◆ setProjectName

void setProjectName ( QString strProjectName)
slot

Sets the name of the project for which we are testing for.

Parameters
strProjectNameThe project name

◆ setRepeatCount

void setRepeatCount ( quint32 uRepeatCount)
slot

Sets the global repeat count. If the repeat count is set to 0, it will be changed to 2^32-1 automatically.

Example:

to.setRepeatCount(42); // Set the global repeat count
Parameters
uRepeatCount

◆ setTesterName

void setTesterName ( QString strTesterName)
slot

Sets the name of the tester.

Example:

to.setTesterName("myName"); // Set the name of the tester
Parameters
strTesterNameThe name of the tester

◆ setTestInfo

void setTestInfo ( QString strTestInfo)
slot

Sets the additional info of the test.

Parameters
strTestInfoThe test info

◆ setTestName

void setTestName ( QString strTestName)
slot

Sets the name of the test.

Parameters
strTestNameThe name of the test

◆ setTestVersion

void setTestVersion ( QString strTestVersion)
slot

Sets the version of the test.

Parameters
strTestVersionThe test version

◆ start

void start ( )
slot

Starts the TestObject to run all configured tests The user can call that function from anywhere inside the script, triggered by any event.

The easiest way to use it, is to place the call in the start() function.

Example:

function start()
{
trace("start");
to.start();
}

◆ stop

void stop ( )
slot

Stops the TestObject to cancel all running tests. The user can call that function from anywhere inside the script, triggered by any event.

The easiest way to use it, is to place the call in the stop() function.

But anyway, normally all test should run until they are finished or the user is using the tool bar buttons to stop the tests.

Example:

function stop()
{
trace("stop");
to.stop();
}
void stop()
Stops the TestObject to cancel all running tests.
Definition configitemtestobject.cpp:3084