Detailed Description
The QtopiaSystemTestModem class provides functionality for simulating modem events from within a system test.
The QtopiaSystemTestModem class encapsulates a simulated AT modem. This allows phone events to be simulated, such as an incoming call or network handover.
Note that creating or destroying a QtopiaSystemTestModem causes Qt Extended to restart, as this is the only way to change the modem used by Qtopia.
An instance of this class can be obtained using the QtopiaSystemTest::testModem() function. It is recommended to call this function in initTestCase to prevent Qt Extended restarting during a test.
See also QSystemTest.
Member Function Documentation
Boolean QtopiaSystemTestModem::activateWillFail () const
Returns the activate request failure setting from the phone simulator.
Example:
testModem().setActivateWillFail(true);
QVERIFY( testModem().activateWillFail() );
See also setActivateWillFail().
void QtopiaSystemTestModem::destroy ()
Deletes the test modem and restarts Qtopia.
void QtopiaSystemTestModem::expectCommand ( String key, String command )
Adds an expected AT command to the list. Set before the action prompting the command takes place. key is a reference to the command item, can be an arbitrary string. command is the expected command text.
Example:
testModem().expectCommand("enable_voice", "AT+CCWA=1,1,1");
keyClick( Qt.Key_Select );
QVERIFY( testModem().waitCommand("enable_voice", 5000) );
See also waitCommand(), expectResponse(), and waitResponse().
void QtopiaSystemTestModem::expectResponse ( String key, String response )
Adds an expected AT response to the list. Set before the action prompting the response takes place. key is a reference to the response, can be an arbitrary string. response is the expected response text.
Example:
testModem().expectResponse("enable_voice", "+CCWA=1,1");
keyClick( Qt.Key_Select );
QVERIFY( testModem().waitResponse("enable_voice", 5000) );
See also waitResponse(), expectCommand(), and waitCommand().
String QtopiaSystemTestModem::getVariable ( String name ) const
Returns the value of a specified phone simulator variable. name is the name of the variable to obtain the value from.
Example:
testModem().setVariable("OP", "Qt Extended Comms");
var op = testModem().getVariable("OP");
See also send() and setVariable().
void QtopiaSystemTestModem::hangupAll ()
Prompts the modem to 'remotely' end all calls, simulating a hang up event from all callers.
Example:
testModem().startIncomingCall(12345);
keyClick( Qt.Key_Call );
testModem().startIncomingCall(67890);
keyClick( Qt.Key_Call );
testModem().hangupAll();
See also hangupConnected(), hangupHeld(), hangupConnectedAndHeld(), and hangupCall().
void QtopiaSystemTestModem::hangupCall ( Number id )
Prompts the modem to 'remotely' end a specified call, simulating a hang up event from the specified caller. id is the 'call id' of the target call item, where activated calls in a call manager begin at '1' and are incremented on each activated call. Example:
testModem().startIncomingCall(12345);
keyClick( Qt.Key_Call );
testModem().startIncomingCall(67890);
keyClick( Qt.Key_Call );
testModem().hangupCall(1);
See also hangupAll(), hangupConnected(), hangupHeld(), and hangupConnectedAndHeld().
void QtopiaSystemTestModem::hangupConnected ()
Prompts the modem to 'remotely' end all active calls, simulating a hang up event from the active callers.
Example:
testModem().startIncomingCall(12345);
keyClick( Qt.Key_Call );
testModem().startIncomingCall(67890);
testModem().hangupConnected();
See also hangupAll(), hangupHeld(), hangupConnectedAndHeld(), and hangupCall().
void QtopiaSystemTestModem::hangupConnectedAndHeld ()
Prompts the modem to 'remotely' end all active and held calls, simulating a hang up event from all callers active and on hold.
Example:
testModem().startIncomingCall(12345);
keyClick( Qt.Key_Call );
testModem().startIncomingCall(67890);
keyClick( Qt.Key_Call );
testModem().startIncomingCall(54321);
testModem().hangupConnectedAndHeld();
See also hangupAll(), hangupConnected(), hangupHeld(), and hangupCall().
void QtopiaSystemTestModem::hangupHeld ()
Prompts the modem to 'remotely' end all held calls, simulating a hang up event from all callers on hold.
Example:
testModem().startIncomingCall(12345);
keyClick( Qt.Key_Call );
testModem().startIncomingCall(67890);
keyClick( Qt.Key_Call );
testModem().hangupHeld();
See also hangupAll(), hangupConnected(), hangupConnectedAndHeld(), and hangupCall().
Boolean QtopiaSystemTestModem::holdWillFail () const
Returns the hold request failure setting from the phone simulator.
Example:
testModem().setHoldWillFail(true);
QVERIFY( testModem().holdWillFail() );
See also setHoldWillFail().
void QtopiaSystemTestModem::incomingSMS ( const Number type, String sender, String serviceCenter, String text )
Initiates an incoming short message. type indicates the message class (0 - 3) sender is the phone number of the sending party serviceCenter is the SMS forwarding service text is the short message text.
Example:
expectMessageBox( "New Message", "Do you wish to view", "Yes", 5000 ){
testModem().incomingSMS( "12345", "67090", "Hello" );
}
void QtopiaSystemTestModem::installToolkitApp ( SimApplication app )
Installs app as the SIM toolkit application in the simulated modem. If app is null, return to the default SIM toolkit application.
The previous SIM toolkit application will be deleted if it is not the default.
Boolean QtopiaSystemTestModem::joinWillFail () const
Returns the join request failure setting from the phone simulator.
Example:
testModem().setJoinWillFail(true);
QVERIFY( testModem().joinWillFail() );
See also setJoinWillFail().
Number QtopiaSystemTestModem::multipartyLimit () const
Returns the maximum number of concurrent parties currently allowed in the test modem.
Example:
testModem().setMultipartyLimit(5);
var lim = testModem().multipartyLimit();
See also setMultipartyLimit().
void QtopiaSystemTestModem::resetPersistentVariables ()
Forget all persistent values set through setVariable(). The next time Qt Extended is restarted, all variables which were previously persistent will be set to their default values.
void QtopiaSystemTestModem::send ( String string )
Make the simulated modem emit arbitrary unsolicited data. string is the string emitted by the modem.
Example:
testModem().setVariable("OP", "Qt Extended Comms");
testModem().send("+CREG: 5");
void QtopiaSystemTestModem::setActivateWillFail ( Boolean value )
Enables a simulated failure response on ACTIVATE requests eg. alternate between an active and held call. value is the desired setting.
Example:
testModem().setActivateWillFail(true);
testModem().startIncomingCall(12345);
keyClick( Qt.Key_Call );
testModem().startIncomingCall(67890);
keyClick( Qt.Key_Call ) );
selectContext( "Swap" );
See also activateWillFail().
void QtopiaSystemTestModem::setHoldWillFail ( Boolean value )
Enables a simulated failure response on HOLD requests. value is the desired setting.
Example:
testModem().setHoldWillFail(true);
testModem().startIncomingCall(12345);
keyClick( Qt.Key_Call );
selectContext("Hold");
See also holdWillFail().
void QtopiaSystemTestModem::setJoinWillFail ( Boolean value )
Enables a simulated failure response on JOIN requests ie. creating a multiparty call. value is the desired setting.
Example:
testModem().setJoinWillFail(true);
testModem().startIncomingCall(12345);
keyClick( Qt::Key_Call );
testModem().startIncomingCall(67890);
keyClick( Qt::Key_Call );
selectContext( "Join" );
See also joinWillFail().
void QtopiaSystemTestModem::setMultipartyLimit ( Number value )
Sets the maximum number of concurrent parties in the test modem. value is the target maximum number of parties.
Example:
testModem().setMultipartyLimit(2);
testModem().startIncomingCall(12345);
keyClick( Qt.Key_Call );
testModem().startIncomingCall(67890);
keyClick( Qt.Key_Call );
selectContext( "Join" );
testModem().startIncomingCall(54321);
keyClick( Qt.Key_Call );
selectContext( "Join" );
See also multipartyLimit().
void QtopiaSystemTestModem::setVariable ( String name, String value, Boolean persistent = false )
Change the value of a specified phone simulator variable. name is the name of the variable to change, value is the new value of the variable. If persistent is true, the value of the variable will be retained when Qt Extended is restarted. Otherwise the variable will be reset to its default value.
Example:
testModem().setVariable("OP", "Qt Extended Comms");
testModem().send("+CREG: 5");
See also send() and getVariable().
void QtopiaSystemTestModem::startIncomingCall ( String number )
Initiates an incoming call. number is the phone number of the calling party (can be empty).
Example:
testModem().startIncomingCall(12345);
keyClick( Qt.Key_Call );
Boolean QtopiaSystemTestModem::waitCommand ( String key, Number timeout = 10000 )
Verifies an expected command has been sent. Will fail if not set with expectedCommand(). key is a reference to the command item as set in expectCommand(). timeout indicates time to verification failure.
Returns true if the specified command occurs within the given timeout.
Example:
testModem().expectCommand("enable_voice", "AT+CCWA=1,1,1");
keyClick( Qt.Key_Select );
QVERIFY( testModem().waitCommand("enable_voice", 5000) );
See also expectCommand(), expectResponse(), and waitResponse().
Boolean QtopiaSystemTestModem::waitResponse ( String key, Number timeout = 10000 )
Verifies an expected response has been received. Will fail if not set with expectedResponse(). key is a reference to the response item as set in expectResponse(). timeout indicates time to verification failure.
Returns true if the specified response is received within the given timeout.
Example:
testModem().expectResponse("enable_voice", "+CCWA=1,1");
keyClick( Qt.Key_Select );
QVERIFY( testModem().waitResponse("enable_voice", 5000) );
See also expectResponse(), expectCommand(), and waitCommand().