telephonyserverplugins/multimodetsy/test/Te_LoopBack/Te_LoopBackt_tsylb.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This file contains the entry point for the Multimode TSY Regression Test Harness.  It includes
       
    15 // the main entry point for the test harness (E32Main) and the user interface processing.  The
       
    16 // environment is initialized by methods in this file as well.  The Communications Database that
       
    17 // is created here is specific to the ETel Regression Test Harness.
       
    18 // 
       
    19 //
       
    20 
       
    21 /**
       
    22  @file
       
    23 */
       
    24 
       
    25 #include <commsdattypesv1_1.h>
       
    26 
       
    27 #include <e32base.h>
       
    28 #include <e32test.h>
       
    29 #include <c32comm.h>
       
    30 #include <f32file.h>
       
    31 #include <etelmm.h>
       
    32 
       
    33 #include "Te_LoopbackCRxMess.h"
       
    34 #include "Te_LoopbackCNoPduRxMess.H"
       
    35 #include "Te_LoopbackCSca.H"
       
    36 #include "Te_LoopbackCTxMess.H"
       
    37 #include "Te_LoopbackCDataCall.H"
       
    38 #include "Te_LoopbackCOddInits.H"
       
    39 #include "Te_LoopbackCMessStor.H"
       
    40 #include "Te_LoopbackCFailInits.H"
       
    41 #include "Te_LoopbackCInCall.H"
       
    42 #include "Te_LoopbackCSmsCancel.H"
       
    43 #include "Te_LoopbackCShutdown.H"
       
    44 #include "Te_LoopbackCSmsDelete.h"
       
    45 #include "Te_LoopbackCSsFax.H"
       
    46 #include "Te_LoopbackCDataCallCancel.H"
       
    47 #include "Te_LoopbackCFaxPremClose.H"
       
    48 #include "Te_LoopbackCTwoFaxRx.H"
       
    49 #include "Te_LoopbackCVoiceCall.H"
       
    50 #include "Te_LoopbackCDataCallCallBack.H"
       
    51 #include "Te_LoopbackCDataCallRemoteHangupDial.H"
       
    52 #include "Te_LoopbackCDataCallRemoteTerm.H"
       
    53 #include "Te_LoopbackCPhoneBook.H"
       
    54 #include "Te_LoopbackCNetwork.H"
       
    55 #include "Te_LoopbackCPhoneLine.H"
       
    56 #include "Te_LoopbackCCalls.H"
       
    57 #include "Te_LoopbackCNoCnmi.H"
       
    58 #include "Te_LoopbackCNoCmgf.H"
       
    59 #include "Te_LoopbackCOOMVoiceCall.H"
       
    60 #include "Te_LoopbackCDataCallDiffParam.H"
       
    61 #include "Te_LoopbackCCbstParse.H"
       
    62 #include "Te_LoopbackCCGQREQ_Responses.h"
       
    63 #include "Te_LoopbackCUnsolicited.h"
       
    64 
       
    65 #if defined (__WINS__)
       
    66 #define PDD_NAME _L("ECDRV")
       
    67 #define LDD_NAME _L("ECOMM")
       
    68 #else
       
    69 #define PDD_NAME _L("EUART1")
       
    70 #define PDD2_NAME _L("EUART2")
       
    71 #define LDD_NAME _L("ECOMM")
       
    72 #endif
       
    73 
       
    74 #define SIMPLETESTMACRO(TEXT,CLASSNAME,SCRIPTNUMBER) \
       
    75 		_LIT8(KTestLit_##CLASSNAME_##SCRIPTNUMBER,TEXT); \
       
    76 		StartTest(KTestLit_##CLASSNAME_##SCRIPTNUMBER); \
       
    77 		CLASSNAME* test_##CLASSNAME_##SCRIPTNUMBER=CLASSNAME::NewL(SCRIPTNUMBER); \
       
    78 		CleanupStack::PushL(test_##CLASSNAME_##SCRIPTNUMBER); \
       
    79 		User::LeaveIfError(test_##CLASSNAME_##SCRIPTNUMBER->RunTestL()); \
       
    80 		CleanupStack::PopAndDestroy(); \
       
    81 		EndTest(KTestLit_##CLASSNAME_##SCRIPTNUMBER); \
       
    82 		User::After(1000000L);
       
    83 
       
    84 
       
    85 // KMaxVariableDelay is Maximum Variable Delay value that can be input by the user as the timeout by script
       
    86 // processing when the iParam value is set -1 in a TScript script whose iCommand is an EWait.
       
    87 const TInt KInputWaitOnDelaySecs=5;
       
    88 
       
    89 GLDEF_D RTest TESTL(_L("T_TsyLb"));
       
    90 GLDEF_D RTelServer server;
       
    91 GLDEF_D RTelServer server2;
       
    92 GLDEF_D RMobilePhone iPhone;
       
    93 GLDEF_D RMobilePhone phone2;
       
    94 GLDEF_C TInt ReturnValue;
       
    95 GLDEF_D CCommsDatabase* TheDb;
       
    96 GLDEF_D RFs TheFs;
       
    97 GLDEF_D RFile TestRpt;
       
    98 
       
    99 _LIT(KTestReportFile,"C:\\T_TsyLb.TestReport.TXT");
       
   100 //
       
   101 // Create dummy ISP Table
       
   102 //
       
   103 TUint32 CreateISPTableL()
       
   104 /**
       
   105  *
       
   106  * This method creates an ISP table entry in the communications database for an NT RAS
       
   107  * connection (no password allowed on the connection).
       
   108  *
       
   109  * @leave	This method leaves via operations failing while accessing the database.
       
   110  * @return	A dial out id
       
   111  *
       
   112  */
       
   113 //
       
   114 // NT RAS Connection without Database Stored Password
       
   115 //
       
   116 	{
       
   117 	TUint32 dialOutId;
       
   118 	CCommsDbTableView* table=TheDb->OpenTableLC(TPtrC(DIAL_OUT_ISP));
       
   119 
       
   120 	TESTL(table->InsertRecord(dialOutId)==KErrNone);
       
   121 	table->WriteTextL(TPtrC(COMMDB_NAME),_L("NT RAS"));
       
   122 	table->WriteUintL(TPtrC(ISP_TYPE),(TUint32)EIspTypeInternetOnly);
       
   123 	table->WriteBoolL(TPtrC(ISP_DIAL_RESOLUTION),ETrue);
       
   124 	table->WriteTextL(TPtrC(ISP_DEFAULT_TEL_NUM),KNullDesC);
       
   125 	table->WriteBoolL(TPtrC(ISP_PROMPT_FOR_LOGIN),EFalse);
       
   126 	table->WriteBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT),ETrue);
       
   127 	table->WriteLongTextL(TPtrC(ISP_LOGIN_SCRIPT),_L("CHARMAP [CODE PAGE 1252]\nLOOP 10\n{\nSEND \"CLIENT\"+<0x0d>\nWAIT 3\n{\n\"SERVER\" OK\n}\n}\nEXIT KErrNoAnswer$\n\nOK:\nEXIT\n"));
       
   128 	table->WriteBoolL(TPtrC(ISP_DISPLAY_PCT),EFalse);
       
   129 	table->WriteTextL(TPtrC(ISP_IF_NAME),_L("ppp"));
       
   130 	table->WriteTextL(TPtrC(ISP_IF_NETWORKS),_L("ip"));
       
   131 	table->WriteBoolL(TPtrC(ISP_IF_PROMPT_FOR_AUTH),ETrue);
       
   132 	table->WriteTextL(TPtrC(ISP_IF_AUTH_NAME),_L("RasUser"));
       
   133 	table->WriteTextL(TPtrC(ISP_IF_AUTH_PASS),_L("O`rr"));
       
   134 	table->WriteBoolL(TPtrC(ISP_IF_CALLBACK_ENABLED),EFalse);
       
   135 	table->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER),ETrue);
       
   136 	table->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER),ETrue);
       
   137 	table->WriteBoolL(TPtrC(ISP_ENABLE_IP_HEADER_COMP),EFalse);
       
   138 	table->WriteBoolL(TPtrC(ISP_ENABLE_LCP_EXTENSIONS),EFalse);
       
   139 	table->WriteBoolL(TPtrC(ISP_DISABLE_PLAIN_TEXT_AUTH),EFalse);
       
   140 	table->WriteBoolL(TPtrC(ISP_ENABLE_SW_COMP),EFalse);
       
   141 	TESTL(table->PutRecordChanges()==KErrNone);
       
   142 
       
   143 	CleanupStack::PopAndDestroy();
       
   144 	return dialOutId;
       
   145 	}
       
   146 
       
   147 //
       
   148 // Create Modem Table (This is the one that will actually be used)
       
   149 //
       
   150 void CreateModemTablesL()
       
   151 /**
       
   152  * This method creates a modem table entry in the communications database.  Note that the
       
   153  * Port and CSY Name are "Loopback".  This is specific to the Regression Test Harness.  The
       
   154  * use of the "Infrared Mobile Phone" communications database name is for convience.
       
   155  *
       
   156  * This is the Modem table that will actually be used by the test harness.
       
   157  *
       
   158  * @leave	This method leaves if operations on the database fail.
       
   159  * @return	A modem id
       
   160  */
       
   161 	{
       
   162 	CCommsDbTableView* table2=TheDb->OpenTableLC(TPtrC(MODEM));
       
   163 	TUint32 dataModemId, smsModemId;
       
   164 
       
   165 // IR mobile iPhone
       
   166 	TESTL(table2->InsertRecord(dataModemId)==KErrNone);
       
   167 	table2->WriteTextL(TPtrC(COMMDB_NAME),_L("Infrared Mobile Phone"));
       
   168 	table2->WriteTextL(TPtrC(MODEM_PORT_NAME),_L("LOOPBACK::0"));
       
   169 	table2->WriteTextL(TPtrC(MODEM_CSY_NAME),_L("LOOPBACK"));
       
   170 	table2->WriteTextL(TPtrC(MODEM_TSY_NAME),_L("MM")); // MM TSY
       
   171 	table2->WriteUintL(TPtrC(MODEM_RATE),(TUint32)EBps115200);
       
   172 	table2->WriteUintL(TPtrC(MODEM_DATA_BITS),(TUint32)EData8);
       
   173 	table2->WriteUintL(TPtrC(MODEM_STOP_BITS),(TUint32)EStop1);
       
   174 	table2->WriteUintL(TPtrC(MODEM_PARITY),(TUint32)EParityNone);
       
   175 	table2->WriteUintL(TPtrC(MODEM_HANDSHAKING),(TUint32)0);
       
   176 	table2->WriteUintL(TPtrC(MODEM_SPECIAL_RATE),(TUint32)0);
       
   177 	table2->WriteUintL(TPtrC(MODEM_XON_CHAR),(TUint32)17);
       
   178 	table2->WriteUintL(TPtrC(MODEM_XOFF_CHAR),(TUint32)19);
       
   179 	table2->WriteTextL(TPtrC(MODEM_MODEM_INIT_STRING),_L8("ATZ"));
       
   180 	table2->WriteTextL(TPtrC(MODEM_DATA_INIT_STRING),_L8("AT345678901234567890123456789012345678901234567890"));
       
   181 	table2->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING),KNullDesC8);
       
   182 	table2->WriteUintL(TPtrC(MODEM_FAX_CLASS_PREF),(TUint32)EClassAuto);
       
   183 	table2->WriteUintL(TPtrC(MODEM_SPEAKER_PREF),(TUint32)EModemSpeakerSettingNever);
       
   184 	table2->WriteUintL(TPtrC(MODEM_SPEAKER_VOL_PREF),(TUint32)EModemSpeakerVolumeQuiet);
       
   185 	table2->WriteTextL(TPtrC(MODEM_MESSAGE_CENTRE_NUMBER),_L("+44 123456789"));
       
   186 	table2->WriteUintL(TPtrC(MODEM_MESSAGE_VALIDITY_PERIOD),1440ul);
       
   187 	table2->WriteBoolL(TPtrC(MODEM_MESSAGE_DELIVERY_REPORT),EFalse);
       
   188 	TESTL(table2->PutRecordChanges()==KErrNone);
       
   189 	CleanupStack::PopAndDestroy();
       
   190 
       
   191 // Cabled 9110, etc
       
   192 	table2=TheDb->OpenTableLC(TPtrC(MODEM));
       
   193 	TESTL(table2->InsertRecord(smsModemId)==KErrNone);
       
   194 	table2->WriteTextL(TPtrC(COMMDB_NAME),_L("GSM Mobile Phone via Serial"));
       
   195 	table2->WriteTextL(TPtrC(MODEM_PORT_NAME),_L("LOOPBACK::0"));
       
   196 	table2->WriteTextL(TPtrC(MODEM_CSY_NAME),_L("LOOPBACK"));
       
   197 	table2->WriteTextL(TPtrC(MODEM_TSY_NAME),_L("PHONETSY")); // Phone TSY - has to be different to GSMBSC
       
   198 	table2->WriteUintL(TPtrC(MODEM_RATE),(TUint32)EBps19200);
       
   199 	table2->WriteUintL(TPtrC(MODEM_DATA_BITS),(TUint32)EData8);
       
   200 	table2->WriteUintL(TPtrC(MODEM_STOP_BITS),(TUint32)EStop1);
       
   201 	table2->WriteUintL(TPtrC(MODEM_PARITY),(TUint32)EParityNone);
       
   202 	table2->WriteUintL(TPtrC(MODEM_HANDSHAKING),(TUint32)KConfigObeyCTS|KConfigObeyDCD|KConfigFailDCD);
       
   203 	table2->WriteUintL(TPtrC(MODEM_SPECIAL_RATE),(TUint32)0);
       
   204 	table2->WriteUintL(TPtrC(MODEM_XON_CHAR),(TUint32)17);
       
   205 	table2->WriteUintL(TPtrC(MODEM_XOFF_CHAR),(TUint32)19);
       
   206 	table2->WriteTextL(TPtrC(MODEM_MODEM_INIT_STRING),_L8("ATZ"));
       
   207 	table2->WriteTextL(TPtrC(MODEM_DATA_INIT_STRING),KNullDesC8);
       
   208 	table2->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING),KNullDesC8);
       
   209 	table2->WriteTextL(TPtrC(MODEM_ISP_INIT_STRING),KNullDesC8);
       
   210 	table2->WriteUintL(TPtrC(MODEM_FAX_CLASS_PREF),(TUint32)EClassAuto);
       
   211 	table2->WriteUintL(TPtrC(MODEM_SPEAKER_PREF),(TUint32)EModemSpeakerSettingNever);
       
   212 	table2->WriteUintL(TPtrC(MODEM_SPEAKER_VOL_PREF),(TUint32)EModemSpeakerVolumeQuiet);
       
   213 	table2->WriteTextL(TPtrC(MODEM_MESSAGE_CENTRE_NUMBER),_L("+441632960000"));
       
   214 	table2->WriteUintL(TPtrC(MODEM_MESSAGE_VALIDITY_PERIOD),1440ul);
       
   215 	table2->WriteBoolL(TPtrC(MODEM_MESSAGE_DELIVERY_REPORT),EFalse);
       
   216 	TESTL(table2->PutRecordChanges()==KErrNone);
       
   217 	CleanupStack::PopAndDestroy();
       
   218 
       
   219 // Setting default modem values for both fax-data and sms modems
       
   220 	TUint32 defaultModemDataId = 0ul;
       
   221 	TUint32 defaultModemSMSId = 0ul;
       
   222 
       
   223 // Set default modem to be used for fax-data
       
   224 	defaultModemDataId = dataModemId;
       
   225 
       
   226 	TheDb->SetGlobalSettingL(TPtrC(MODEM_DATA_FAX),defaultModemDataId);
       
   227 	table2 = TheDb->OpenViewMatchingUintLC(TPtrC(MODEM),TPtrC(COMMDB_ID),defaultModemDataId);
       
   228 	TESTL(table2->GotoFirstRecord()==KErrNone);
       
   229 	TESTL(table2->UpdateRecord()==KErrNone);
       
   230 	TESTL(table2->PutRecordChanges()==KErrNone);
       
   231 	CleanupStack::PopAndDestroy();
       
   232 
       
   233 // Set default modem for sms service
       
   234 	defaultModemSMSId = smsModemId;
       
   235 
       
   236 	TheDb->SetGlobalSettingL(TPtrC(MODEM_PHONE_SERVICES_SMS),defaultModemSMSId);
       
   237 	table2 = TheDb->OpenViewMatchingUintLC(TPtrC(MODEM),TPtrC(COMMDB_ID),defaultModemSMSId);
       
   238 	TESTL(table2->GotoFirstRecord()==KErrNone);
       
   239 	TESTL(table2->UpdateRecord()==KErrNone);
       
   240 	TESTL(table2->PutRecordChanges()==KErrNone);
       
   241 	CleanupStack::PopAndDestroy();
       
   242 	}
       
   243 
       
   244 void PopulateModemTemplateL()
       
   245 //
       
   246 // Populate the Modem Template table
       
   247 //
       
   248 /**
       
   249  * This method populates the Modem template table in the Communications Database.
       
   250  *
       
   251  * @leave	This method leaves if operations fail on the database.
       
   252  * @return	None
       
   253  *
       
   254  */
       
   255 	{
       
   256 	CCommsDbTemplateRecord* temp1=CCommsDbTemplateRecord::NewL(TheDb,TPtrC(MODEM));
       
   257 	CleanupStack::PushL(temp1);
       
   258 	temp1->Modify();
       
   259 
       
   260 	temp1->WriteTextL(TPtrC(COMMDB_NAME),_L("Default Modem"));
       
   261 	temp1->WriteTextL(TPtrC(MODEM_PORT_NAME),_L("COMM::0"));
       
   262 	temp1->WriteTextL(TPtrC(MODEM_CSY_NAME),_L("ECUART"));
       
   263 	temp1->WriteTextL(TPtrC(MODEM_TSY_NAME),_L("HAYES"));
       
   264 	temp1->WriteUintL(TPtrC(MODEM_DATA_BITS),(TUint32)EData8);
       
   265 	temp1->WriteUintL(TPtrC(MODEM_STOP_BITS),(TUint32)EStop1);
       
   266 	temp1->WriteUintL(TPtrC(MODEM_PARITY),(TUint32)EParityNone);
       
   267 	temp1->WriteUintL(TPtrC(MODEM_RATE),(TUint32)EBps115200);
       
   268 	temp1->WriteUintL(TPtrC(MODEM_HANDSHAKING),(TUint32)0);
       
   269 	temp1->WriteUintL(TPtrC(MODEM_SPECIAL_RATE),(TUint32)0);
       
   270 	temp1->WriteUintL(TPtrC(MODEM_XON_CHAR),(TUint32)0);
       
   271 	temp1->WriteUintL(TPtrC(MODEM_XOFF_CHAR),(TUint32)0);
       
   272 	//
       
   273 	temp1->WriteTextL(TPtrC(MODEM_MODEM_INIT_STRING),_L8("AT"));
       
   274 	temp1->WriteTextL(TPtrC(MODEM_DATA_INIT_STRING),_L8("AT"));
       
   275 	temp1->WriteTextL(TPtrC(MODEM_FAX_INIT_STRING),_L8("AT"));
       
   276 	temp1->WriteTextL(TPtrC(MODEM_SPEAKER_VOL_CONTROL_LOW),_L8("L0"));
       
   277 	temp1->WriteTextL(TPtrC(MODEM_SPEAKER_VOL_CONTROL_MEDIUM),_L8("L1"));
       
   278 	temp1->WriteTextL(TPtrC(MODEM_SPEAKER_VOL_CONTROL_HIGH),_L8("L2"));
       
   279 	temp1->WriteTextL(TPtrC(MODEM_SPEAKER_ALWAYS_OFF),_L8("M0"));
       
   280 	temp1->WriteTextL(TPtrC(MODEM_SPEAKER_ON_UNTIL_CARRIER),_L8("M1"));
       
   281 	temp1->WriteTextL(TPtrC(MODEM_SPEAKER_ALWAYS_ON),_L8("M2"));
       
   282 	temp1->WriteTextL(TPtrC(MODEM_SPEAKER_ON_AFTER_DIAL_UNTIL_CARRIER),_L8("M3"));
       
   283 	temp1->WriteTextL(TPtrC(MODEM_DIAL_TONE_WAIT_MODIFIER),_L8("W"));
       
   284 	temp1->WriteTextL(TPtrC(MODEM_DIAL_PAUSE_LENGTH),_L8("S8="));
       
   285 	temp1->WriteTextL(TPtrC(MODEM_CALL_PROGRESS_1),_L8("X1"));
       
   286 	temp1->WriteTextL(TPtrC(MODEM_CALL_PROGRESS_2),_L8("X2"));
       
   287 	temp1->WriteTextL(TPtrC(MODEM_CALL_PROGRESS_3),_L8("X3"));
       
   288 	temp1->WriteTextL(TPtrC(MODEM_CALL_PROGRESS_4),_L8("X4"));
       
   289 	temp1->WriteTextL(TPtrC(MODEM_ECHO_OFF),_L8("E0"));
       
   290 	temp1->WriteTextL(TPtrC(MODEM_VERBOSE_TEXT),_L8("V1"));
       
   291 	temp1->WriteTextL(TPtrC(MODEM_QUIET_ON),_L8("Q1"));
       
   292 	temp1->WriteTextL(TPtrC(MODEM_QUIET_OFF),_L8("Q0"));
       
   293 	temp1->WriteTextL(TPtrC(MODEM_DIAL_COMMAND_STATE_MODIFIER),_L8(";"));
       
   294 	temp1->WriteTextL(TPtrC(MODEM_ON_LINE),_L8("O"));
       
   295 	temp1->WriteTextL(TPtrC(MODEM_RESET_CONFIGURATION),_L8("Z"));
       
   296 	temp1->WriteTextL(TPtrC(MODEM_RETURN_TO_FACTORY_DEFS),_L8("&F"));
       
   297 	temp1->WriteTextL(TPtrC(MODEM_DCD_ON_DURING_LINK),_L8("&C1"));
       
   298 	temp1->WriteTextL(TPtrC(MODEM_DTR_HANG_UP),_L8("&D2"));
       
   299 	temp1->WriteTextL(TPtrC(MODEM_DSR_ALWAYS_ON),_L8("&S0"));
       
   300 	temp1->WriteTextL(TPtrC(MODEM_RTS_CTS_HANDSHAKE),_L8("&K3"));
       
   301 	temp1->WriteTextL(TPtrC(MODEM_XON_XOFF_HANDSHAKE),_L8("&K4"));
       
   302 	temp1->WriteTextL(TPtrC(MODEM_ESCAPE_CHARACTER),_L8("+"));
       
   303 	temp1->WriteTextL(TPtrC(MODEM_ESCAPE_GUARD_PERIOD),_L8("S12"));
       
   304 	//
       
   305 	temp1->WriteTextL(TPtrC(MODEM_NO_DIAL_TONE),_L8("NO DIAL TONE"));
       
   306 	temp1->WriteTextL(TPtrC(MODEM_BUSY),_L8("BUSY"));
       
   307 	temp1->WriteTextL(TPtrC(MODEM_NO_ANSWER),_L8("NO ANSWER"));
       
   308 	temp1->WriteTextL(TPtrC(MODEM_CARRIER),_L8("CARRIER"));
       
   309 	temp1->WriteTextL(TPtrC(MODEM_CONNECT),_L8("CONNECT"));
       
   310 	temp1->WriteTextL(TPtrC(MODEM_COMPRESSION_CLASS_5),_L8("COMPRESSION:CLASS 5"));
       
   311 	temp1->WriteTextL(TPtrC(MODEM_COMPRESSION_V42BIS),_L8("COMPRESSION:V.42 bis"));
       
   312 	temp1->WriteTextL(TPtrC(MODEM_COMPRESSION_NONE),_L8("COMPRESSION:NONE"));
       
   313 	temp1->WriteTextL(TPtrC(MODEM_PROTOCOL_LAPD),_L8("PROTOCOL:LAPD"));
       
   314 	temp1->WriteTextL(TPtrC(MODEM_PROTOCOL_ALT),_L8("PROTOCOL:ALT"));
       
   315 	temp1->WriteTextL(TPtrC(MODEM_PROTOCOL_ALTCELLULAR),_L8("PROTOCOL:ALT-CELLULAR"));
       
   316 	temp1->WriteTextL(TPtrC(MODEM_PROTOCOL_NONE),_L8("PROTOCOL:NONE"));
       
   317 	//
       
   318 	temp1->WriteUintL(TPtrC(MODEM_FAX_CLASS_PREF),(TUint32)EClassAuto);
       
   319 	temp1->WriteUintL(TPtrC(MODEM_SPEAKER_PREF),(TUint32)EModemSpeakerSettingAfterDialUntilAnswer);
       
   320 	temp1->WriteUintL(TPtrC(MODEM_SPEAKER_VOL_PREF),(TUint32)EModemSpeakerVolumeQuiet);
       
   321 
       
   322 	User::LeaveIfError(temp1->StoreModifications());
       
   323 	CleanupStack::PopAndDestroy();
       
   324 
       
   325 // Added location defaults for the modem table
       
   326 	CCommsDbTemplateRecord* temp2=CCommsDbTemplateRecord::NewL(TheDb,TPtrC(LOCATION));
       
   327 	CleanupStack::PushL(temp2);
       
   328 	temp2->Modify();
       
   329 
       
   330 	temp2->WriteTextL(TPtrC(COMMDB_NAME),_L("Default Location"));
       
   331 	temp2->WriteTextL(TPtrC(LOCATION_INTL_PREFIX_CODE),_L("+"));
       
   332 	temp2->WriteTextL(TPtrC(LOCATION_NAT_PREFIX_CODE),_L("0"));
       
   333 	temp2->WriteTextL(TPtrC(LOCATION_NAT_CODE),_L("44"));
       
   334 	temp2->WriteTextL(TPtrC(LOCATION_AREA_CODE),KNullDesC);
       
   335 	temp2->WriteBoolL(TPtrC(LOCATION_MOBILE),ETrue);
       
   336 	temp2->WriteBoolL(TPtrC(LOCATION_USE_PULSE_DIAL),EFalse);
       
   337 	temp2->WriteBoolL(TPtrC(LOCATION_WAIT_FOR_DIAL_TONE),EFalse);
       
   338 	temp2->WriteUintL(TPtrC(LOCATION_PAUSE_AFTER_DIAL_OUT),(TUint32)0);
       
   339 
       
   340 	TESTL(temp2->StoreModifications()==KErrNone);
       
   341 	CleanupStack::PopAndDestroy();
       
   342 	}
       
   343 
       
   344 void CreateLocationTablesL()
       
   345 /**
       
   346  * This method creates a modem table entry in the communications database.
       
   347  * This table contains dummy information.  It is essential to have a location table for
       
   348  * the correct running of the GSM TSY, but the contents are unimportant.
       
   349  *
       
   350  * @leave	This method leaves if operations on the database fail.
       
   351  * @return	A location table id.
       
   352  */
       
   353 {
       
   354 	CCommsDbTableView* table4;
       
   355 	TUint32 id1, id2;
       
   356 
       
   357 // Office Location
       
   358 	table4 = TheDb->OpenTableLC(TPtrC(LOCATION));
       
   359 	TESTL(table4->InsertRecord(id1)==KErrNone);
       
   360 	table4->WriteTextL(TPtrC(COMMDB_NAME),_L("Office"));
       
   361 	table4->WriteTextL(TPtrC(LOCATION_INTL_PREFIX_CODE),_L("00"));
       
   362 	table4->WriteTextL(TPtrC(LOCATION_NAT_PREFIX_CODE),_L("0"));
       
   363 	table4->WriteTextL(TPtrC(LOCATION_NAT_CODE),_L("44"));
       
   364 	table4->WriteTextL(TPtrC(LOCATION_AREA_CODE),_L("171"));
       
   365 	table4->WriteTextL(TPtrC(LOCATION_DIAL_OUT_CODE),_L("9,"));
       
   366 	table4->WriteTextL(TPtrC(LOCATION_DISABLE_CALL_WAITING_CODE),KNullDesC);
       
   367 	table4->WriteBoolL(TPtrC(LOCATION_MOBILE),EFalse);
       
   368 	table4->WriteBoolL(TPtrC(LOCATION_USE_PULSE_DIAL),EFalse);
       
   369 	table4->WriteBoolL(TPtrC(LOCATION_WAIT_FOR_DIAL_TONE),EFalse);
       
   370 	table4->WriteUintL(TPtrC(LOCATION_PAUSE_AFTER_DIAL_OUT),(TUint32)0);
       
   371 	TESTL(table4->PutRecordChanges()==KErrNone);
       
   372 	CleanupStack::PopAndDestroy();
       
   373 	table4 = NULL;
       
   374 
       
   375 // Office (without dial out code) Location
       
   376 	table4 = TheDb->OpenTableLC(TPtrC(LOCATION));
       
   377 	TESTL(table4->InsertRecord(id2)==KErrNone);
       
   378 	table4->WriteTextL(TPtrC(COMMDB_NAME),_L("Office Direct Dial"));
       
   379 	table4->WriteTextL(TPtrC(LOCATION_INTL_PREFIX_CODE),_L("00"));
       
   380 	table4->WriteTextL(TPtrC(LOCATION_NAT_PREFIX_CODE),_L("0"));
       
   381 	table4->WriteTextL(TPtrC(LOCATION_NAT_CODE),_L("44"));
       
   382 	table4->WriteTextL(TPtrC(LOCATION_AREA_CODE),_L("171"));
       
   383 	table4->WriteTextL(TPtrC(LOCATION_DIAL_OUT_CODE),KNullDesC);
       
   384 	table4->WriteTextL(TPtrC(LOCATION_DISABLE_CALL_WAITING_CODE),KNullDesC);
       
   385 	table4->WriteBoolL(TPtrC(LOCATION_MOBILE),EFalse);
       
   386 	table4->WriteBoolL(TPtrC(LOCATION_USE_PULSE_DIAL),EFalse);
       
   387 	table4->WriteBoolL(TPtrC(LOCATION_WAIT_FOR_DIAL_TONE),EFalse);
       
   388 	table4->WriteUintL(TPtrC(LOCATION_PAUSE_AFTER_DIAL_OUT),(TUint32)0);
       
   389 	TESTL(table4->PutRecordChanges()==KErrNone);
       
   390 	CleanupStack::PopAndDestroy();
       
   391 	table4 = NULL;
       
   392 
       
   393 // Set default location from which you are dialling for data modem
       
   394 	TheDb->SetGlobalSettingL(TPtrC(LOCATION_DATA_FAX),id1);
       
   395 
       
   396 // Set default location from which you are dialling for modem for sms service
       
   397 	TheDb->SetGlobalSettingL(TPtrC(LOCATION_PHONE_SERVICES_SMS),id2);
       
   398 //	return locationId;
       
   399 	}
       
   400 
       
   401 LOCAL_C TKeyCode ShortWaitForKey(TInt aDelay, TBool& aKeyPressed)
       
   402 	{
       
   403 	TRequestStatus stat1,stat2;
       
   404 	RTimer timer;
       
   405 	aKeyPressed=EFalse;
       
   406 	timer.CreateLocal();
       
   407 	for(TInt i=0;i<aDelay;i++)
       
   408 		{
       
   409 		test.Console()->Read(stat1);
       
   410 		timer.After(stat2,1000000L);
       
   411 		User::WaitForRequest(stat1,stat2);
       
   412 		if(stat1==KErrNone)
       
   413 			{
       
   414 			timer.Cancel();
       
   415 			User::WaitForRequest(stat2);
       
   416 			aKeyPressed=ETrue;
       
   417 			break;
       
   418 			}
       
   419 		else
       
   420 			{
       
   421 			test.Console()->ReadCancel();
       
   422 			User::WaitForRequest(stat1);
       
   423 			INFO_PRINTF1(_L("."));
       
   424 			}
       
   425 		}
       
   426 	INFO_PRINTF1(_L("\n"));
       
   427 	return test.Console()->KeyCode();
       
   428 	}
       
   429 
       
   430 //
       
   431 // Set the Default CommDb Combination
       
   432 //
       
   433 void CreateCommDbL()
       
   434 /**
       
   435  * This method creates a special Communications Database to be used with the regression test
       
   436  * harness.  The user is given a chance to cancel this operation.  This method uses the file
       
   437  * server and timer services.  It also calls other methods to actually populate the
       
   438  * special communications database.  Note that the communications database created is tailored
       
   439  * to the needs of the ETel Regression Test harness.
       
   440  *
       
   441  * @leave	This method leaves if the user cancels the overwrite of the communications
       
   442  *			database or if the NewL method called in this method fails.  Also, the database
       
   443  *			functions can also leave.
       
   444  */
       
   445 	{
       
   446 	RFs fs;
       
   447 	_LIT(KSvDbFileName,"C:\\System\\Data\\Cdbv3.dat");
       
   448 
       
   449 	TESTL(fs.Connect()==KErrNone);
       
   450 
       
   451 	RTimer timer;
       
   452 	timer.CreateLocal();
       
   453 	TUint dummy;
       
   454 	if(fs.Att(KSvDbFileName,dummy)==KErrNone)
       
   455 		{
       
   456 		INFO_PRINTF1(_L("\nThis test requires a special CommDb Database.\nExisting Database File detected\nPress any key to STOP Overwrite\n\n"));
       
   457 
       
   458 		TBool keyPressed=ETrue;
       
   459 		ShortWaitForKey(5,keyPressed);
       
   460 		if(keyPressed)
       
   461 		User::Leave(KErrAlreadyExists);
       
   462 
       
   463 		INFO_PRINTF1(_L("\n"));
       
   464 		TESTL(fs.Delete(KSvDbFileName)==KErrNone);
       
   465 		}
       
   466 	fs.Close();
       
   467 
       
   468 	TheDb=CCommsDatabase::NewL(EDatabaseTypeIAP);
       
   469 	CleanupStack::PushL(TheDb);
       
   470 	TESTL(TheDb->BeginTransaction()==KErrNone);
       
   471 
       
   472 //
       
   473 // Write the database tables
       
   474 //
       
   475 	TUint32 ispId=CreateISPTableL();
       
   476 	CreateModemTablesL();
       
   477 	CreateLocationTablesL();
       
   478 	PopulateModemTemplateL();
       
   479 
       
   480 	CCommsDbTableView* table=TheDb->OpenTableLC(TPtrC(IAP));
       
   481 
       
   482 	TUint32 id;
       
   483 	TESTL(table->InsertRecord(id)==KErrNone);
       
   484 	table->WriteTextL(TPtrC(COMMDB_NAME),_L("Test Configuration: MM Loopback"));
       
   485 	table->WriteUintL(TPtrC(IAP_SERVICE),ispId);
       
   486 	table->WriteTextL(TPtrC(IAP_SERVICE_TYPE),TPtrC(DIAL_OUT_ISP));
       
   487 	TESTL(table->PutRecordChanges()==KErrNone);
       
   488 //
       
   489 // Set the Default
       
   490 //
       
   491 	CCommsDbConnectionPrefTableView* cpTable=TheDb->OpenConnectionPrefTableViewOnRankLC(ECommDbConnectionDirectionOutgoing,1);
       
   492 	cpTable->GotoFirstRecord();
       
   493 	CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
       
   494 	cpTable->ReadConnectionPreferenceL(pref);
       
   495 	pref.iBearer.iIapId=id;
       
   496 	pref.iBearer.iBearerSet = KCommDbBearerCSD;
       
   497 	cpTable->UpdateBearerL(pref.iBearer);
       
   498 
       
   499 	CleanupStack::PopAndDestroy();
       
   500 	TESTL(TheDb->CommitTransaction()==KErrNone);
       
   501 	CleanupStack::PopAndDestroy();
       
   502 	CleanupStack::PopAndDestroy();
       
   503 	}
       
   504 
       
   505 TInt GetNumberEntry
       
   506 (
       
   507 	const TInt aMaxDigits,	// max numbers of digits
       
   508 	const TInt aMin,		// min value allowed
       
   509 	const TInt aMax,		// max value allowed
       
   510 	const TInt aInputWait,	// (s) how long to wait for each user key entry
       
   511 	const TInt aDefaultVal,	// default value if timed out
       
   512 	const TDesC &aPrompt	// string prompt
       
   513 )
       
   514 /**
       
   515  * This method gets numeric user entry from the console. It checks that the key entered
       
   516  * is between 0 to 9 inclusive. This method exits by user hitting the
       
   517  * Enter key or timing out.
       
   518  *
       
   519  * @param aMaxNumbers integer for max numbers of digits
       
   520  * @param aMin integer for min value allowed
       
   521  * @param aMax integer for max value allowed
       
   522  * @param aInputWait integer for number of seconds to wait for each user key entry
       
   523  * @param aDefaultVal integer for default value if time-out occurs without
       
   524  * @param aPrompt string prompt
       
   525  * @return KErrNone.
       
   526  */
       
   527 {
       
   528 TInt keyFolded;				 // actual digit entered, not TKeyCode
       
   529 TRequestStatus stat1,stat2;
       
   530 RTimer timer;
       
   531 TBool bCorrectEntry = EFalse;
       
   532 TInt userNum = -1;
       
   533 TInt limit;
       
   534 TKeyCode key;
       
   535 
       
   536 	TTimeIntervalMicroSeconds32 anInterval = aInputWait * 1000000;
       
   537 	CConsoleBase *pConsole = test.Console();
       
   538 	timer.CreateLocal();
       
   539 
       
   540 	while (!bCorrectEntry)
       
   541 		{
       
   542 		userNum = -1;
       
   543 		limit = aMaxDigits;
       
   544 		key = EKeyNull;
       
   545 
       
   546 		INFO_PRINTF1(aPrompt); // print prompt
       
   547 		INFO_PRINTF1(_L(" (range %d-%d) or <CR> for default of %d: "), aMin, aMax, aDefaultVal);
       
   548 		// exits loop when Enter keyed or limit reached (by decrement to 0)
       
   549 		while ((key != EKeyEnter) && limit)
       
   550 			{
       
   551 			pConsole->Read(stat1);				// set read
       
   552 			timer.After(stat2, anInterval);		// set wait for this period
       
   553 			User::WaitForRequest(stat1,stat2);  // whatever comes first
       
   554 
       
   555 			if(stat1 == KErrNone)					// user entered key
       
   556 				{
       
   557 				timer.Cancel();
       
   558 				User::WaitForRequest(stat2);
       
   559 
       
   560 				key = pConsole->KeyCode();
       
   561 				if((key >= '0') && (key <= '9'))
       
   562 					{
       
   563 					// valid digit
       
   564 					keyFolded = (TKeyCode)(key - '0');  // convert to digit
       
   565 					INFO_PRINTF1(_L("%d"), keyFolded);	// echo
       
   566 					limit--;			// tracks number of digits
       
   567 
       
   568 					// "append" to number
       
   569 					if (-1 == userNum)	   // ie first char entered
       
   570 						{
       
   571 						userNum = keyFolded;
       
   572 						}
       
   573 					else					//  next char entered
       
   574 						{
       
   575 						userNum = userNum * 10 + keyFolded;  // shift
       
   576 						}
       
   577 					}
       
   578 				}
       
   579 			else	// timer went off, use default unless valid key entered before timer expired
       
   580 				{
       
   581 				pConsole->ReadCancel();
       
   582 				User::WaitForRequest(stat1);
       
   583 				if (-1 == userNum)
       
   584 					{
       
   585 					// no value entered before timer went off
       
   586 					userNum = aDefaultVal;
       
   587 					}
       
   588 				break;
       
   589 				}
       
   590 			} // endwhile
       
   591 
       
   592 		test.Printf (_L("\n"));
       
   593 		if ((userNum >= aMin) && (userNum <= aMax))
       
   594 			{
       
   595 			bCorrectEntry = ETrue;  // exit loop
       
   596 			}
       
   597 		else						// return to loop
       
   598 			{
       
   599 			if (userNum == -1)
       
   600 				{
       
   601 				// <CR> was entered before any numbers, so use default
       
   602 				userNum = aDefaultVal;
       
   603 				break;
       
   604 				}
       
   605 			INFO_PRINTF1(_L("Try again, Entry out of limit. Must be between %d and %d inclusive.\n\n"), aMin, aMax);
       
   606 			}
       
   607 		} // endwhile
       
   608 
       
   609 	return (userNum);
       
   610 }
       
   611 
       
   612 LOCAL_C void CreateTestReportFileL()
       
   613 	{
       
   614 	TInt ret=TheFs.Connect();
       
   615 	User::LeaveIfError(ret);
       
   616 	TheFs.Delete(KTestReportFile);
       
   617 
       
   618 	ret=TestRpt.Create(TheFs,KTestReportFile,EFileWrite|EFileShareAny);
       
   619 	User::LeaveIfError(ret);
       
   620 	}
       
   621 
       
   622 LOCAL_C void CloseTestReportFile()
       
   623 	{
       
   624 	TestRpt.Close();
       
   625 	TheFs.Close();
       
   626 	}
       
   627 
       
   628 LOCAL_C void TestReportLog(const TDesC8& aText)
       
   629 	{
       
   630 	TBuf8<200> buf;
       
   631 
       
   632 	TTime now;
       
   633 	now.UniversalTime();
       
   634 	TDateTime dateTime;
       
   635 	dateTime = now.DateTime();
       
   636 	buf.Format(_L8 ("%02d.%02d:%02d:%06d "),dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond());
       
   637 	buf.AppendFormat(_L8("%S\015\012"),&aText);
       
   638 	TestRpt.Write(buf);
       
   639 	TestRpt.Flush();
       
   640 	}
       
   641 
       
   642 LOCAL_C void StartTest(const TDesC8& aTestName)
       
   643 	{
       
   644 	TBuf8<200> buf8;
       
   645 	buf8.AppendFormat(_L8("Starting %S Test"),&aTestName);
       
   646 	TestReportLog(buf8);
       
   647 	TBuf<200> buf;
       
   648 	buf.Copy(aTestName);
       
   649 	INFO_PRINTF1(_L("\nStarting %S Test\n"),&buf);
       
   650 	}
       
   651 
       
   652 LOCAL_C void EndTest(const TDesC8& aTestName)
       
   653 	{
       
   654 	TBuf8<200> buf8;
       
   655 	buf8.AppendFormat(_L8("%S Test Completed Successfully"),&aTestName);
       
   656 	TestReportLog(buf8);
       
   657 	TBuf<200> buf;
       
   658 	buf.Copy(aTestName);
       
   659 	INFO_PRINTF1(_L("Completed %S Test\n"),&buf);
       
   660 	}
       
   661 
       
   662 //
       
   663 // Perform the Test
       
   664 //
       
   665 LOCAL_C void PerformTestL()
       
   666 /**
       
   667  *
       
   668  * The PerformTestL method is the main user interface routine for the GSM TSY Regression
       
   669  * Test Harness.  It loads the appropriate serial drivers and unloads them at completion.
       
   670  * This method presents the user with the list of tests to run and then
       
   671  * responds to the user's input.  If the user does not select any specific test, it runs all
       
   672  * tests as the default.
       
   673  *
       
   674  * @leave	This method leaves if it can not connect to the communications server or load
       
   675  *			the CSY.  Additionally, this method leaves if the test script can not be created.
       
   676  *			If the test fails with an error, User::Leave will be invoked.
       
   677  */
       
   678 	{
       
   679 	RCommServ commServer;
       
   680 	TESTL(commServer.Connect()==KErrNone);
       
   681 	TInt res=commServer.LoadCommModule(_L("ECUART.CSY"));
       
   682 	INFO_PRINTF1(TRefByValue<const TDesC>(_L("LoadCommModuleError = %d\n")), res);
       
   683 	TESTL(res==KErrNone || res==KErrAlreadyExists);
       
   684 
       
   685 //  This block of prints is for all tests to be listed in one column
       
   686 //  Note: by displaying menu selectons in a single column, all selections will not be visible
       
   687 	INFO_PRINTF1(_L("Which test?  Leave to run all tests\n"));
       
   688 	INFO_PRINTF1(_L("a) Receive SMS Test\n"));
       
   689 	INFO_PRINTF1(_L("b) SMS Notification Test\n"));
       
   690 	INFO_PRINTF1(_L("c) SMS PDU Capability Test\n"));
       
   691 	INFO_PRINTF1(_L("d) Default SCA Test\n"));
       
   692 	INFO_PRINTF1(_L("e) SMS Transmission Test\n"));
       
   693 	INFO_PRINTF1(_L("f) Data Call Test\n"));
       
   694 	INFO_PRINTF1(_L("g) Errored Data Call Test\n"));
       
   695 	INFO_PRINTF1(_L("h) Odd Initialisation Tests\n"));
       
   696 	INFO_PRINTF1(_L("i) SMS Storage Tests\n"));
       
   697 	INFO_PRINTF1(_L("j) Failure Initialisation Tests\n"));
       
   698 	INFO_PRINTF1(_L("k) Incoming Call Tests\n"));
       
   699 	INFO_PRINTF1(_L("l) SMS Cancel Scenarios\n"));
       
   700 	INFO_PRINTF1(_L("m) Shutdown Scenarios\n"));
       
   701 	INFO_PRINTF1(_L("n) SMS Storage Delete Test\n"));
       
   702 	INFO_PRINTF1(_L("o) Simultaneous Fax Reception and Signal Strength Retrieval Scenario\n"));
       
   703 	INFO_PRINTF1(_L("p) Data Call Cancel Scenarios\n"));
       
   704 	INFO_PRINTF1(_L("q) Fax Call Premature Close Scenario\n"));
       
   705 	INFO_PRINTF1(_L("r) Two Fax Reception Scenario\n"));
       
   706 	INFO_PRINTF1(_L("s) Voice Call Scenarios\n"));
       
   707 	INFO_PRINTF1(_L("t) Data Call Set-up, Data Transfer and Remote Termination Test\n"));
       
   708 	INFO_PRINTF1(_L("u) Data Call Dial-up Networking Call-back Test\n"));
       
   709 	INFO_PRINTF1(_L("v) Data Call Answer and Remote Hang-up Closely Followed by a Dial Test\n"));
       
   710 	INFO_PRINTF1(_L("w) Phonebook tests\n"));
       
   711 	INFO_PRINTF1(_L("x) Network and Registration tests\n"));
       
   712 	INFO_PRINTF1(_L("y) Phone and Line tests\n"));
       
   713 	INFO_PRINTF1(_L("z) Voice and Data calls tests\n"));
       
   714 	INFO_PRINTF1(_L("1) No CNMI info and Modem Detection tests\n"));
       
   715 	INFO_PRINTF1(_L("2) No CMGF info tests\n"));
       
   716 	INFO_PRINTF1(_L("3) AT+CBST  tests\n"));
       
   717 	INFO_PRINTF1(_L("4) CBST & CNMI string parsing test\n")) ;
       
   718 	INFO_PRINTF1(_L("5) CGQREQ responses during initialise\n"));
       
   719 	INFO_PRINTF1(_L("6) Unsolicited messages injected during initialisation\n"));
       
   720 	INFO_PRINTF1(_L("9) Voice Call OOM tests (NOT RUN AS PART OF 'ALL TESTS')\n"));
       
   721 
       
   722 	TBool keyPressed=ETrue;
       
   723 	TKeyCode key=ShortWaitForKey(10, keyPressed);
       
   724 
       
   725 	TBool allTests=!keyPressed;
       
   726 	if(keyPressed)
       
   727 		{
       
   728 		if((key>='A')&&(key<='Z'))	// A simple fold
       
   729 			key=(TKeyCode)(key-'A'+'a');
       
   730 		}
       
   731 
       
   732 //
       
   733 // Run the tests...
       
   734 //
       
   735 
       
   736 
       
   737 // Test Rx SMS messages
       
   738 	if((key=='a')||(allTests))
       
   739 		{
       
   740 		SIMPLETESTMACRO("Simple SMS Receive",CTestDriveRxMess,ERxMessScript);
       
   741 		SIMPLETESTMACRO("CMT SMS Receive",CTestDriveRxMessCmt,ERxMessCmtAndCmtiScript);
       
   742 		SIMPLETESTMACRO("CMTI SMS Receive emulating an Ericsson T28",CTestDriveRxMess,ERxMessEricssonT28Script);
       
   743 		}
       
   744 
       
   745 // Test Notification of SMS messages
       
   746 	if((key=='b')||(allTests))
       
   747 		{
       
   748 		SIMPLETESTMACRO("SMS CMTI Notification and Receive",CTestDriveNotMess,ERxMessScript);
       
   749 		SIMPLETESTMACRO("SMS CMT Notification and Receive",CTestDriveNotMessCmt,ERxMessCmtScript);
       
   750 		}
       
   751 
       
   752 // Test behaviour when a modem claims not to support SMS PDU mode
       
   753 	if((key=='c')||(allTests))
       
   754 		{
       
   755 		SIMPLETESTMACRO("No SMS PDU capability",CTestDriveNoPduRxMess,ENoPduRxMessScript);
       
   756 		}
       
   757 
       
   758 
       
   759 // Test retrieval and setting of default service centre
       
   760 
       
   761 	if ((key=='d')||(allTests))
       
   762 		{
       
   763 		SIMPLETESTMACRO("Simple SCA retrieval & setting",CTestDriveSca,EScaSimpleScript);
       
   764 		SIMPLETESTMACRO("8210-style SCA retrieval & setting",CTestDriveSca,ESca8210StyleScript);
       
   765 		}
       
   766 
       
   767 
       
   768 // Test a simple SMS Tx
       
   769 	if((key=='e')||(allTests))
       
   770 		{
       
   771 		SIMPLETESTMACRO("A simple SMS Tx",CTestDriveTxMess,ETxMessScript);
       
   772 		SIMPLETESTMACRO("New Standard SMS Tx",CTestDriveTxNewStdMess,ETxMessNewStdScript);
       
   773 		SIMPLETESTMACRO("New Standard SMS Tx Test emulating an Ericsson T28",CTestDriveTxNewStdMess,ETxMessT28NewStdScript);
       
   774 
       
   775 	// Test no prefix on pdu, don't set default sca, new ETSI format
       
   776 		_LIT8(KTxA,"Tx: no PDU prefix, no default SCA set, new standard");
       
   777 		StartTest(KTxA);
       
   778 		CTestDriveTxWithScaCombo* test4c=CTestDriveTxWithScaCombo::NewL(ETxMessScriptNoprefixNodefscaNew,EFalse,EFalse,ETrue);
       
   779 		CleanupStack::PushL(test4c);
       
   780 		User::LeaveIfError(test4c->RunTestL());
       
   781 		CleanupStack::PopAndDestroy();
       
   782 		EndTest(KTxA);
       
   783 		User::After(1000000L);
       
   784 
       
   785 	// Test prefix on pdu, don't set default sca, new ETSI format
       
   786 		_LIT8(KTxB,"Tx: PDU prefix, no default SCA set, new standard");
       
   787 		StartTest(KTxB);
       
   788 		test4c=CTestDriveTxWithScaCombo::NewL(ETxMessScriptPrefixNodefscaNew,ETrue,EFalse,ETrue);
       
   789 		CleanupStack::PushL(test4c);
       
   790 		User::LeaveIfError(test4c->RunTestL());
       
   791 		CleanupStack::PopAndDestroy();
       
   792 		EndTest(KTxB);
       
   793 		User::After(1000000L);
       
   794 
       
   795 	// Test no prefix on pdu, set default sca, new ETSI format
       
   796 		_LIT8(KTxC,"Tx: no PDU prefix, default SCA set, new standard");
       
   797 		StartTest(KTxC);
       
   798 		test4c=CTestDriveTxWithScaCombo::NewL(ETxMessScriptNoprefixDefscaNew,EFalse,ETrue,ETrue);
       
   799 		CleanupStack::PushL(test4c);
       
   800 		User::LeaveIfError(test4c->RunTestL());
       
   801 		CleanupStack::PopAndDestroy();
       
   802 		EndTest(KTxC);
       
   803 		User::After(1000000L);
       
   804 
       
   805 	// Test prefix on pdu, set default sca, new ETSI format
       
   806 		_LIT8(KTxD,"Tx: PDU prefix, default SCA set, new standard");
       
   807 		StartTest(KTxD);
       
   808 		test4c=CTestDriveTxWithScaCombo::NewL(ETxMessScriptPrefixDefscaNew,ETrue,ETrue,ETrue);
       
   809 		CleanupStack::PushL(test4c);
       
   810 		User::LeaveIfError(test4c->RunTestL());
       
   811 		CleanupStack::PopAndDestroy();
       
   812 		EndTest(KTxD);
       
   813 		User::After(1000000L);
       
   814 
       
   815 	// Test no prefix on pdu, don't set default sca, old ETSI format
       
   816 		_LIT8(KTxE,"Tx: No PDU prefix, no default SCA set, old standard");
       
   817 		StartTest(KTxE);
       
   818 		test4c=CTestDriveTxWithScaCombo::NewL(ETxMessScriptNoprefixNodefscaOld,EFalse,EFalse,EFalse);
       
   819 		CleanupStack::PushL(test4c);
       
   820 		User::LeaveIfError(test4c->RunTestL());
       
   821 		CleanupStack::PopAndDestroy();
       
   822 		EndTest(KTxE);
       
   823 		User::After(1000000L);
       
   824 
       
   825 	// Test prefix on pdu, don't set default sca, old ETSI format
       
   826 		_LIT8(KTxF,"Tx: PDU prefix, no default SCA set, old standard");
       
   827 		StartTest(KTxF);
       
   828 		test4c=CTestDriveTxWithScaCombo::NewL(ETxMessScriptPrefixNodefscaOld,ETrue,EFalse,EFalse);
       
   829 		CleanupStack::PushL(test4c);
       
   830 		User::LeaveIfError(test4c->RunTestL());
       
   831 		CleanupStack::PopAndDestroy();
       
   832 		EndTest(KTxF);
       
   833 		User::After(1000000L);
       
   834 
       
   835 	// Test no prefix on pdu, set default sca, old ETSI format
       
   836 		_LIT8(KTxG,"Tx: no PDU prefix, default SCA set, old standard");
       
   837 		StartTest(KTxG);
       
   838 		test4c=CTestDriveTxWithScaCombo::NewL(ETxMessScriptNoprefixDefscaOld,EFalse,ETrue,EFalse);
       
   839 		CleanupStack::PushL(test4c);
       
   840 		User::LeaveIfError(test4c->RunTestL());
       
   841 		CleanupStack::PopAndDestroy();
       
   842 		EndTest(KTxG);
       
   843 		User::After(1000000L);
       
   844 
       
   845 	// Test prefix on pdu, set default sca, old ETSI format
       
   846 		_LIT8(KTxH,"Tx: PDU prefix, default SCA set, old standard");
       
   847 		StartTest(KTxH);
       
   848 		test4c=CTestDriveTxWithScaCombo::NewL(ETxMessScriptPrefixDefscaOld,ETrue,ETrue,EFalse);
       
   849 		CleanupStack::PushL(test4c);
       
   850 		User::LeaveIfError(test4c->RunTestL());
       
   851 		CleanupStack::PopAndDestroy();
       
   852 		EndTest(KTxH);
       
   853 		User::After(1000000L);
       
   854 
       
   855 	// Test a "+CMS ERROR 321" from a Read (observed on an Ericsson 888)
       
   856 		SIMPLETESTMACRO("Invalid Read Test",CTestDriveTxRx,ETxMessRxTxScriptA);
       
   857 		}
       
   858 
       
   859 // Test Dialing a Data Call
       
   860 	if((key=='f')||(allTests))
       
   861 		{
       
   862 		SIMPLETESTMACRO("Dialing a simple Data Call",CTestDriveDataCall,EDataCallScript);
       
   863 		}
       
   864 
       
   865 // Test an Error Dialing a Data Call
       
   866 	if((key=='g')||(allTests))
       
   867 		{
       
   868 		SIMPLETESTMACRO("Dialing a simple Data Call, with the modem ERRORing some commands",CTestDriveDataCall,EDataCallErrorAScript);
       
   869 		}
       
   870 
       
   871 // Test some odd initialisation sequences
       
   872 	if((key=='h')||(allTests))
       
   873 		{
       
   874 		SIMPLETESTMACRO("Odd Initialisation Sequence A",CTestDriveOddInit,EOddInitAScript);
       
   875 		SIMPLETESTMACRO("Odd Initialisation Sequence B",CTestDriveOddInit,EOddInitBScript);
       
   876 		SIMPLETESTMACRO("Odd Initialisation Sequence C",CTestDriveOddInit,EOddInitCScript);
       
   877 		SIMPLETESTMACRO("Odd Initialisation Sequence D",CTestDriveOddInit,EOddInitDScript);
       
   878 		SIMPLETESTMACRO("Odd Initialisation Sequence E",CTestDriveOddInit,EOddInitEScript);
       
   879 		SIMPLETESTMACRO("Odd Initialisation Sequence F",CTestDriveOddInit,EOddInitFScript);
       
   880 		SIMPLETESTMACRO("Odd Initialisation Sequence G",CTestDriveOddInit,EOddInitGScript);
       
   881 		SIMPLETESTMACRO("Odd Initialisation Sequence H",CTestDriveOddInit,EOddInitHScript);
       
   882  		SIMPLETESTMACRO("Odd Initialisation Sequence I",CTestDriveOddInit,EOddInitIScript);
       
   883 		}
       
   884 
       
   885 // Test SMS Storage functions
       
   886 	if((key=='i')||(allTests))
       
   887 		{
       
   888 		SIMPLETESTMACRO("Message Storage Functions with old standard PDUs",CTestDriveMessStor,EMessStorOldSmsStdScript);
       
   889 		SIMPLETESTMACRO("Message Storage Functions with new standard PDUs",CTestDriveMessStor,EMessStorNewSmsStdScript);
       
   890 		}
       
   891 
       
   892 // Test Initialisation Failure Scenarios
       
   893 	if((key=='j')||(allTests))
       
   894 		{
       
   895 		SIMPLETESTMACRO("Initialisation Failure Scenarios",CTestDriveFailInit,EFailInitAScript);
       
   896 		}
       
   897 
       
   898 // Test Incoming Call Scenarios
       
   899 	if((key=='k')||(allTests))
       
   900 		{
       
   901 		SIMPLETESTMACRO("Incoming Call Scenarios",CTestDriveInCall,EInCallScriptA);
       
   902 		SIMPLETESTMACRO("Incoming Call Scenarios with a Nokia",CTestDriveInCall,EInCallScriptB);
       
   903 		}
       
   904 
       
   905 // Test SMS Cancel
       
   906 	if((key=='l')||(allTests))
       
   907 		{
       
   908 		SIMPLETESTMACRO("SMS Cancel CMT Scenarios",CTestDriveSmsCancel,ESmsCancelScript);
       
   909 		SIMPLETESTMACRO("SMS Cancel CMTI Scenarios",CTestDriveSmsCancel,ESmsCancelCmtiScript);
       
   910 		}
       
   911 
       
   912 // Test Shutdown Scenarios
       
   913 	if((key=='m')||(allTests))
       
   914 		{
       
   915  		SIMPLETESTMACRO("Shutdown Scenarios",CTestDriveShutdown,EShutdownScript);
       
   916 		SIMPLETESTMACRO("Shutdown Scenarios A",CTestDriveShutdownA,EShutdownScriptA);
       
   917 		}
       
   918 
       
   919 // Test SMS Delete
       
   920 	if((key=='n')||(allTests))
       
   921 		{
       
   922 		SIMPLETESTMACRO("A Simple SMS Storage Delete",CTestDriveSmsDelete,ESmsStorageDeleteScript);
       
   923 		}
       
   924 
       
   925 // Test simultaneous Fax Reception and Signal Strength Retrieval
       
   926 	if((key=='o')||(allTests))
       
   927 		{
       
   928 		SIMPLETESTMACRO("Simultaneous Fax Reception and Signal Strength Retrieval",CTestDriveSsFax,ESsFaxScriptA);
       
   929 		SIMPLETESTMACRO("Simultaneous Data Reception and Signal Strength Retrieval",CTestDriveSSData,ESsDataScriptA);
       
   930 		}
       
   931 
       
   932 // Test Data Call Cancel Scenarios
       
   933 	if((key=='p')||(allTests))
       
   934 		{
       
   935 		SIMPLETESTMACRO("Data Call Cancel Scenarios",CTestDriveDataCallCancel,EDataCallCancelScript);
       
   936 		}
       
   937 
       
   938 // Fax Call Premature Close Scenarios
       
   939 	if((key=='q')||(allTests))
       
   940 		{
       
   941 		SIMPLETESTMACRO("Fax Call Premature Close Scenarios",CTestDrivePremClose,EFaxPremCloseScriptA);
       
   942 //		SIMPLETESTMACRO("Fax Call Premature Close Scenarios Part B",CTestDrivePremCloseB,EFaxPremCloseScriptB);
       
   943 		}
       
   944 
       
   945 // Two Fax Reception Scenarios
       
   946 	if((key=='r')||(allTests))
       
   947 		{
       
   948 		SIMPLETESTMACRO("Two Fax Reception Scenarios",CTestDriveTwoFaxRx,ETwoFaxRxScriptA);
       
   949 		}
       
   950 
       
   951 // Voice Call Scenarios
       
   952 	if((key=='s')||(allTests))
       
   953 		{
       
   954 		SIMPLETESTMACRO("Voice Call Scenarios",CTestDriveVoiceCall,EVoiceCallScriptA);
       
   955 		}
       
   956 
       
   957 // Test Dialing a Set-up, Data Transfer and Remote Termination Data Call
       
   958 	if((key=='t')||(allTests))
       
   959 		{
       
   960 		SIMPLETESTMACRO("Dialing a Set-up, Data Transfer and Remote Termination Data Call",CTestDriveDataCallRemoteTerm,EDataCallRemoteTermScript);
       
   961 		}
       
   962 
       
   963 // Test Dialing a Dial-up Networking Call-back Data Call
       
   964 	if((key=='u')||(allTests))
       
   965 		{
       
   966 		TInt varDelay;  // Variable Delay for EWait script, for scoping purposes
       
   967 		varDelay = KCallBackDefVarDelay;
       
   968 		if(!allTests)
       
   969 			{
       
   970 			// This tests is valid for supporting variable delay for an EWait script
       
   971 			varDelay = GetNumberEntry(	KCallBackMaxDigits,	// max numbers of digits
       
   972 										KCallBackMinVarDelay,	// min value allowed
       
   973 										KCallBackMaxVarDelay,	// max value allowed
       
   974 										KInputWaitOnDelaySecs,	// secs to wait for a user key entry
       
   975 										KCallBackDefVarDelay,	// default value if timed out
       
   976 										_L("Enter delay value")
       
   977 									 );
       
   978 			}
       
   979 		_LIT8(KCallbackA,"Dialing a Dial-up Networking Call-back Data Call");
       
   980 		StartTest(KCallbackA);
       
   981 		CTestDriveDataCallCallBack* test23=CTestDriveDataCallCallBack::NewL(EDataCallCallBackScript, varDelay);
       
   982 		CleanupStack::PushL(test23);
       
   983 		User::LeaveIfError(test23->RunTestL());
       
   984 		CleanupStack::PopAndDestroy();
       
   985 		EndTest(KCallbackA);
       
   986 		User::After(1000000L);
       
   987 		}
       
   988 
       
   989 // Test an Answer and Remote Hang-up Closely Followed by a Dial Data Call
       
   990 	if((key=='v')||(allTests))
       
   991 		{
       
   992 		TInt varDelay;  // Variable Delay for EWait script, for scoping purposes
       
   993 		varDelay = KHangupDialDefVarDelay;
       
   994 		if(!allTests)
       
   995 			{
       
   996 			// This tests is valid for supporting variable delay for an EWait script
       
   997 			varDelay = GetNumberEntry(	KHangupDialMaxDigits,	// max numbers of digits
       
   998 										KHangupDialMinVarDelay,	// min value allowed
       
   999 										KHangupDialMaxVarDelay,	// max value allowed
       
  1000 										KInputWaitOnDelaySecs,	// secs to wait for a user key entry
       
  1001 										KHangupDialDefVarDelay,	// default value if timed out
       
  1002 										_L("Enter delay value")
       
  1003 									 );
       
  1004 			}
       
  1005 		_LIT8(KCallbackB,"Answer and Remote Hang-up Closely Followed by a Dial Data Call");
       
  1006 		StartTest(KCallbackB);
       
  1007 		CTestDriveRemoteHangupDial* test24=CTestDriveRemoteHangupDial::NewL(EDataCallRemoteHangDialScript, varDelay);
       
  1008 		CleanupStack::PushL(test24);
       
  1009 		User::LeaveIfError(test24->RunTestL());
       
  1010 		CleanupStack::PopAndDestroy();
       
  1011 		EndTest(KCallbackB);
       
  1012 		User::After(1000000L);
       
  1013 		}
       
  1014 
       
  1015 // Phone book tests
       
  1016 	if((key=='w')||(allTests))
       
  1017 		{
       
  1018 		SIMPLETESTMACRO("Phone book Scenarios",CTestDrivePhoneBook,EPhoneBookScript);
       
  1019 		}
       
  1020 
       
  1021 // Network and Registration tests
       
  1022 	if((key=='x')||(allTests))
       
  1023 		{
       
  1024 		SIMPLETESTMACRO("Testing Network and Registration",CTestDriveNetworkRegistration,ENetworkRegistrationScript);
       
  1025 		}
       
  1026 
       
  1027 // Phone and Line tests
       
  1028 	if((key=='y')||(allTests))
       
  1029 		{
       
  1030 		SIMPLETESTMACRO("Phone and Line Scenarios",CTestDrivePhoneLine,EPhoneLineScript);
       
  1031 		}
       
  1032 
       
  1033 // Voice and Data Call tests
       
  1034 	if((key=='z')||(allTests))
       
  1035 		{
       
  1036 		SIMPLETESTMACRO("Voice and Data Calls",CTestDriveAllCalls,EAllCallsScript);
       
  1037 		}
       
  1038 
       
  1039 // No CNMI information and Modem notification tests
       
  1040 	if((key=='1')||(allTests))
       
  1041 		{
       
  1042 		SIMPLETESTMACRO("No CNMI info and Modem notification request",CTestDriveNoCnmi,ENoCnmiScript);
       
  1043 		}
       
  1044 
       
  1045 // No CMGF information tests
       
  1046 	if((key=='2')||(allTests))
       
  1047 		{
       
  1048 		SIMPLETESTMACRO("No CMGF info request",CTestDriveNoCmgf,ENoCmgfScript);
       
  1049 		}
       
  1050 
       
  1051 // AT+CBST information tests
       
  1052 	if((key=='3')||(allTests))
       
  1053 		{
       
  1054 		SIMPLETESTMACRO("AT+CBST tests",CTestDriveDataCallDiffParam, ECallDiffParamScript);
       
  1055 		}
       
  1056 //CBST string parsing test
       
  1057 	if((key=='4')||(allTests))
       
  1058 		{
       
  1059 		SIMPLETESTMACRO("CBST & CNMI string parsing test",CTestDriveCbstParse, ECbstParseScript);
       
  1060 		}
       
  1061 
       
  1062 // CGQREQ responses during initialise (added to increase conditional code coverage)
       
  1063 	if((key=='5')||(allTests))
       
  1064 		{
       
  1065 		SIMPLETESTMACRO("CGQREQ responses during initialise",CTestDriveCGQREQResponses,ECGQREQResponsesScript);
       
  1066 		}
       
  1067 
       
  1068 // Unsolicited messages injected during initialisation
       
  1069 	if((key=='6')||(allTests))
       
  1070 		{
       
  1071 		SIMPLETESTMACRO("Unsolicited messages injected during initialisation",CTestDriveUnsolicited,EUnsolicitedScript);
       
  1072 		}
       
  1073 
       
  1074 // OOM Voice Call tests, not run as part of 'all tests'
       
  1075 	if(key=='9')
       
  1076 		{
       
  1077 		SIMPLETESTMACRO("OOM Voice Call",CTestDriveOOMVoiceCall,EOOMVoiceCall);
       
  1078 		}
       
  1079 
       
  1080 //
       
  1081 // Tidy up after the tests
       
  1082 //
       
  1083 	res = commServer.UnloadCommModule(_L("ECUART.CSY"));
       
  1084 	commServer.Close();
       
  1085 	}
       
  1086 
       
  1087 GLDEF_C TInt E32Main()
       
  1088 //
       
  1089 // Main entry point - make sure everything is going.
       
  1090 //
       
  1091 /**
       
  1092  * This method is the main entry point for the GSM TSY Regression Test Harness code.  This
       
  1093  * code first makes sure the file server is included.  It also loads the comm server if
       
  1094  * necessary.  After calling a method to create the necessary communications database,
       
  1095  * this method invokes the user interface for the test harness.
       
  1096  *
       
  1097  * @return	KErrNone on Success; Errors returned from either communications database
       
  1098  *			creation failure or individual tests on failures.
       
  1099  *
       
  1100  * @note	This method creates a new instance of the clean up stack.
       
  1101  *
       
  1102  */
       
  1103 	{
       
  1104 	// Make sure we're linked to the file server
       
  1105 	RFs s;
       
  1106 	s.Connect();
       
  1107 	s.Close();
       
  1108 	test.Title();
       
  1109 
       
  1110 	test.Start(_L("Loading Serial drivers"));
       
  1111 
       
  1112 	TInt r;
       
  1113 
       
  1114  	// When bootstrapping C32 we have to avoid the PhBkSyncServer being started, since
       
  1115  	// it needs a different CommDB
       
  1116  	_LIT(KPhbkSyncCMI, "phbsync.cmi");
       
  1117 	r = StartC32WithCMISuppressions(KPhbkSyncCMI);
       
  1118 	if((r!=KErrNone)&&(r!=KErrAlreadyExists))
       
  1119 		INFO_PRINTF1(_L("Failed to start C32 %d\n\r"),r);
       
  1120 
       
  1121 	CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack
       
  1122 	TRAP(r,CreateCommDbL());
       
  1123 	if(r==KErrNone)
       
  1124 		{
       
  1125 		TRAP(r,CreateTestReportFileL());
       
  1126 		if(r==KErrNone)
       
  1127 			{
       
  1128 			TRAP(r,PerformTestL());
       
  1129 			if(ReturnValue)
       
  1130 				r=ReturnValue;
       
  1131 			}
       
  1132 		}
       
  1133 
       
  1134 	CloseTestReportFile();
       
  1135 	if (r)
       
  1136 		INFO_PRINTF1(TRefByValue<const TDesC>(_L("\nError %d reported")),r);
       
  1137 	else
       
  1138 		INFO_PRINTF1(_L("\nTest Completed Sucessfully"));
       
  1139 
       
  1140 	INFO_PRINTF1(_L(", press any key to end"));
       
  1141 	TBool keyPressed=ETrue;
       
  1142 	ShortWaitForKey(10, keyPressed);
       
  1143 	test.End();
       
  1144 	delete cleanup;
       
  1145 //	delete testActiveScheduler;
       
  1146 	return KErrNone;
       
  1147 	}
       
  1148 
       
  1149 //
       
  1150 // Test Scenarios to be created:
       
  1151 //
       
  1152 //	Initialise synchronously and read
       
  1153 //	Initialise async, read before init completion, wait for both complete
       
  1154 //	Init async, read SMS revealing incorrect prefered SMS memory
       
  1155 //
       
  1156 //	Currently if the data initialisation string is ERRORed then the request is errored with
       
  1157 //	KErrGeneral.  Should this succeed?
       
  1158 //
       
  1159 //	SMS Store
       
  1160 //	Test some failure scenarios - try old, fail, try new, fail, fail...
       
  1161 //	Test write requiring prepended SCA with no SCA set in memory - check that an error ensures
       
  1162 //
       
  1163 //	Nokia's require "AT+CRES=1" before "AT+CSCA=?" actually returns the real SCA
       
  1164 //
       
  1165 //	SMS Tx
       
  1166 //	New Std does not require "AT+CSCA=xxx" before transmitting SMS
       
  1167 //
       
  1168 //	SMS Rx
       
  1169 //	What happens if an SMS comes in after the AT+CNMI command, but before the end of the initialisation?
       
  1170 //	What happens if an SMS comes in after the AT+CNMI command, but before the end of a failed initialisation?
       
  1171 //
       
  1172 //	SMS Rx
       
  1173 //	+CDS: incoming Delivery Status Reports
       
  1174 //	Test +CNMI caps and results
       
  1175 
       
  1176 
       
  1177