smsprotocols/smsstack/smsprot/Test/TE_SMSPRTSTRESS/TE_smsprtstress.cpp
changeset 20 244d7c5f118e
parent 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
19:1f776524b15c 20:244d7c5f118e
    11 // Contributors:
    11 // Contributors:
    12 //
    12 //
    13 // Description:
    13 // Description:
    14 //
    14 //
    15 
    15 
    16 #include "TE_smsprtstressbase.h"
       
    17 #include "TE_smsprtstress.h"
    16 #include "TE_smsprtstress.h"
       
    17 
       
    18 #include <e32property.h>
       
    19 //#include <connect/sbdefs.h>
       
    20 #include <sacls.h>
       
    21 
    18 #include "TE_smsprtstressutils.h"
    22 #include "TE_smsprtstressutils.h"
    19 
    23 
    20 #include <e32property.h>
    24 //using namespace conn;
    21 #include <connect/sbdefs.h>
       
    22 #include <sacls.h>
       
    23 
       
    24 using namespace conn;
       
    25 
       
    26 
       
    27 TVerdict CTestInit::doTestStepL()
       
    28 	{
       
    29 	InitGlobalsL();
       
    30 	return TestStepResult();
       
    31 	}
       
    32 
       
    33 
    25 
    34 TVerdict CTestRxAndRead::doTestStepL()
    26 TVerdict CTestRxAndRead::doTestStepL()
    35 	{
    27 	{
    36 	RSocketServ socketServer;
    28 //	CTestReceiveEnumerateMessages* globalAO = CTestReceiveEnumerateMessages::NewL(KActiveReceiverPriority, iSocketServer, *iSmsStackTestUtils);
    37 	PrepareRegTestLC(socketServer, 0);
    29 //    CleanupStack::PushL(globalAO);
    38 
    30 //
    39 	CTestReceiveEnumerateMessages* globalAO = CTestReceiveEnumerateMessages::NewL(KActiveReceiverPriority, socketServer, *iSmsStackTestUtils);
    31 //	globalAO->Start(2 /*aEnumExpected*/, 5 /*aRecvExpected*/, 3 /*aRecvInitial*/);
    40     CleanupStack::PushL(globalAO);
    32 //
    41 
    33 //	TEST(globalAO->iStatus.Int() == KErrNone);
    42 	globalAO->Start(2,5,3);
    34 //
    43 
    35 //   	CleanupStack::PopAndDestroy(globalAO);
    44 	TEST(globalAO->iStatus.Int() == KErrNone);
    36 	return TestStepResult();
    45 
    37 	}
    46    	//globalAO->Cancel();
       
    47 
       
    48    	CleanupStack::PopAndDestroy(globalAO);
       
    49 	CleanupStack::PopAndDestroy(&socketServer);
       
    50 
       
    51 	return TestStepResult();
       
    52 	}
       
    53 
       
    54 
    38 
    55 TVerdict CTestMultipleSimultaneousRequests::doTestStepL()
    39 TVerdict CTestMultipleSimultaneousRequests::doTestStepL()
    56 	{
    40 	{
    57 	INFO_PRINTF1(_L("Test multiple simultaneous requests handling"));
    41 //	INFO_PRINTF1(_L("Test multiple simultaneous requests handling"));
    58 
    42 //	TInt ret(KErrNone);
    59 	RSocketServ socketServer;
    43 //
    60 	PrepareRegTestLC(socketServer, 1);
    44 //	RPointerArray<CTestSmsActiveBase> testSmsActives;
    61 
    45 //	CleanupResetAndDestroyPushL(testSmsActives);
    62 	TInt ret(KErrNone);
    46 //
    63 
    47 //	//Create instance of CTestSmsActiveStop that stops testing activity when tests are completed.
    64 	RPointerArray<CTestSmsActiveBase> testSmsActives;
    48 //	CTestSmsActiveStop* testSmsActiveStop = new (ELeave) CTestSmsActiveStop(testSmsActives,ret);
    65 	CleanupResetAndDestroyPushL(testSmsActives);
    49 //	CleanupStack::PushL(testSmsActiveStop);
    66 
    50 //
    67 	//Create instance of CTestSmsActiveStop that stops testing activity when tests are completed.
    51 //	//Create instance of CTestSmsSendActive that makes send requests to the SMS Stack.
    68 	CTestSmsActiveStop* testSmsActiveStop = new (ELeave) CTestSmsActiveStop(testSmsActives,ret);
    52 //	CTestSmsSendActive* sendActive = CTestSmsSendActive::NewL(iSocketServer,*testSmsActiveStop, 16, iFs, iSmsStackTestUtils, this);
    69 	CleanupStack::PushL(testSmsActiveStop);
    53 //	CleanupStack::PushL(sendActive);
    70 
    54 //	User::LeaveIfError(testSmsActives.Append(sendActive));
    71 	//Create instance of CTestSmsSendActive that makes send requests to the SMS Stack.
    55 //	CleanupStack::Pop(sendActive);
    72 	CTestSmsSendActive* sendActive = CTestSmsSendActive::NewL(socketServer,*testSmsActiveStop, 16, iFs, iSmsStackTestUtils, this);
    56 //
    73 	CleanupStack::PushL(sendActive);
    57 //	//Create instance of CTestSmsParametersActive that makes retrieve and store parameters requests to the SMS Stack.
    74 	User::LeaveIfError(testSmsActives.Append(sendActive));
    58 //	CTestSmsParametersActive* parametersActive = CTestSmsParametersActive::NewL(iSocketServer,*testSmsActiveStop,70, iSmsStackTestUtils, this);
    75 	CleanupStack::Pop(sendActive);
    59 //	CleanupStack::PushL(parametersActive);
    76 
    60 //	User::LeaveIfError(testSmsActives.Append(parametersActive));
    77 	//Create instance of CTestSmsParametersActive that makes retrieve and store parameters requests to the SMS Stack.
    61 //	CleanupStack::Pop(parametersActive);
    78 	CTestSmsParametersActive* parametersActive = CTestSmsParametersActive::NewL(socketServer,*testSmsActiveStop,70, iSmsStackTestUtils, this);
    62 //
    79 	CleanupStack::PushL(parametersActive);
    63 //	//Create instance of CTestSmsStorageActive that makes enumerate, write and delete requests to the SMS Stack.
    80 	User::LeaveIfError(testSmsActives.Append(parametersActive));
    64 //	CTestSmsStorageActive* storageActive = CTestSmsStorageActive::NewL(iSocketServer,*testSmsActiveStop,70, iFs,iSmsStackTestUtils, this);
    81 	CleanupStack::Pop(parametersActive);
    65 //	CleanupStack::PushL(storageActive);
    82 
    66 //	User::LeaveIfError(testSmsActives.Append(storageActive));
    83 	//Create instance of CTestSmsStorageActive that makes enumerate, write and delete requests to the SMS Stack.
    67 //	CleanupStack::Pop(storageActive);
    84 	CTestSmsStorageActive* storageActive = CTestSmsStorageActive::NewL(socketServer,*testSmsActiveStop,70, iFs,iSmsStackTestUtils, this);
    68 //
    85 	CleanupStack::PushL(storageActive);
    69 //	//Create instance of CTestSmsReceiveActive that makes retrieve requests to the SMS Stack.
    86 	User::LeaveIfError(testSmsActives.Append(storageActive));
    70 //	CTestSmsReceiveActive* receiveActive = CTestSmsReceiveActive::NewL(iSocketServer,*testSmsActiveStop,16, iFs, iSmsStackTestUtils, this);
    87 	CleanupStack::Pop(storageActive);
    71 //	CleanupStack::PushL(receiveActive);
    88 
    72 //	User::LeaveIfError(testSmsActives.Append(receiveActive));
    89 	//Create instance of CTestSmsReceiveActive that makes retrieve requests to the SMS Stack.
    73 //	CleanupStack::Pop(receiveActive);
    90 	CTestSmsReceiveActive* receiveActive = CTestSmsReceiveActive::NewL(socketServer,*testSmsActiveStop,16, iFs, iSmsStackTestUtils, this);
    74 //
    91 	CleanupStack::PushL(receiveActive);
    75 //	sendActive->StartL();
    92 	User::LeaveIfError(testSmsActives.Append(receiveActive));
    76 //	parametersActive->StartL();
    93 	CleanupStack::Pop(receiveActive);
    77 //	storageActive->StartL();
    94 
    78 //	receiveActive->StartL();
    95 	sendActive->StartL();
    79 //
    96 	parametersActive->StartL();
    80 //	//Start active objects
    97 	storageActive->StartL();
    81 //	CActiveScheduler::Start();
    98 	receiveActive->StartL();
    82 //
    99 
    83 //	//Checkpoint is called when test are ran through
   100 	//Start active objects
    84 //	TEST(ret == KErrNone);
   101 	CActiveScheduler::Start();
    85 //
   102 
    86 //	CleanupStack::PopAndDestroy(testSmsActiveStop);	//stopper class
   103 	//Checkpoint is called when test are ran through
    87 //	CleanupStack::PopAndDestroy(&testSmsActives);	//active objects
   104 	TEST(ret == KErrNone);
    88 	return TestStepResult();
   105 
    89 	}
   106 	CleanupStack::PopAndDestroy(testSmsActiveStop);	//stopper class
    90 
   107 	CleanupStack::PopAndDestroy(&testSmsActives);	//active objects
    91 // TODO: replace with one from CSmsBaseTestStep
   108 
       
   109 	EndRegTest();
       
   110 
       
   111 	return TestStepResult();
       
   112 	}
       
   113 
       
   114 
       
   115 TInt CTestSmsPrtBackup::SendSmsL(RSocket& aSocket)
    92 TInt CTestSmsPrtBackup::SendSmsL(RSocket& aSocket)
   116 	{
    93 	{
   117 
       
   118 	INFO_PRINTF1(_L("Attempting to send an sms to +358405202000"));
    94 	INFO_PRINTF1(_L("Attempting to send an sms to +358405202000"));
   119 
       
   120 	TBuf<32> buf;
    95 	TBuf<32> buf;
   121 	buf.Append(_L("TestSmsPrtBackup message"));
    96 	buf.Append(_L("TestSmsPrtBackup message"));
   122 
    97 
   123 	CSmsMessage* message = iSmsStackTestUtils->CreateSmsMessageLC(CSmsPDU::ESmsSubmit, _L("+358405202000"), buf);
    98 	CSmsMessage* message = iSmsStackTestUtils->CreateSmsMessageLC(CSmsPDU::ESmsSubmit, _L("+358405202000"), buf);
   124 
    99 
   128 
   103 
   129  	//Send message
   104  	//Send message
   130 	TPckgBuf<TUint> sbuf;
   105 	TPckgBuf<TUint> sbuf;
   131 	TRequestStatus status;
   106 	TRequestStatus status;
   132 	aSocket.Ioctl(KIoctlSendSmsMessage,status,&sbuf, KSolSmsProv);
   107 	aSocket.Ioctl(KIoctlSendSmsMessage,status,&sbuf, KSolSmsProv);
   133 
       
   134 	//wait for message to be sent
       
   135 	User::WaitForRequest(status);
   108 	User::WaitForRequest(status);
   136 
   109     INFO_PRINTF2(_L("SendSmsL returning %d"), status.Int());
       
   110     
   137 	CleanupStack::PopAndDestroy(message);
   111 	CleanupStack::PopAndDestroy(message);
   138 
       
   139 	INFO_PRINTF2(_L("SendSmsL returning %d"), status.Int());
       
   140 	return (status.Int());
   112 	return (status.Int());
   141 	}
   113 	}
   142 
   114 
   143 /* Test sending sms messages under backup and restore situations
   115 /* Test sending sms messages under backup and restore situations
   144 	1 - Sending of an sms message under normal circumstances succeeds
   116 	1 - Sending of an sms message under normal circumstances succeeds
   152 	already has a socket open prior to a backup and restore commencing,
   124 	already has a socket open prior to a backup and restore commencing,
   153 	thus avoiding the errors that can be generated when opening the socket
   125 	thus avoiding the errors that can be generated when opening the socket
   154 	during backup and restore.*/
   126 	during backup and restore.*/
   155 TVerdict CTestSmsPrtBackup::doTestStepL()
   127 TVerdict CTestSmsPrtBackup::doTestStepL()
   156 	{
   128 	{
   157 	PrepareRegTestLC(iSocketServer, 2);
   129 //	RSocket socket;
   158 	RSocket socket;
   130 //	iSmsStackTestUtils->OpenSmsSocketLC(iSocketServer,socket,ESmsAddrSendOnly);
   159 	iSmsStackTestUtils->OpenSmsSocketLC(iSocketServer,socket,ESmsAddrSendOnly);
   131 //
   160 
   132 //	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrNone"));
   161 	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrNone"));
   133 //	TEST(SendSmsL(socket) == KErrNone);
   162 	TEST(SendSmsL(socket) == KErrNone);
   134 //
   163 
   135 //	// Notify the SMSPROT server that a backup is about to take place and
   164 	// Notify the SMSPROT server that a backup is about to take place and
   136 //	// that the server should powerdown
   165 	// that the server should powerdown
   137 //	INFO_PRINTF1(_L("Simulating a backup notification"));
   166 	INFO_PRINTF1(_L("Simulating a backup notification"));
   138 //	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   167 	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   139 //									 EBURBackupFull, EBackupBase);
   168 									 EBURBackupFull, EBackupBase);
   140 //
   169 
   141 //	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrDisconnected"));
   170 	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrDisconnected"));
   142 //	TEST(SendSmsL(socket) == KErrDisconnected);
   171 	TEST(SendSmsL(socket) == KErrDisconnected);
   143 //
   172 
   144 //
   173 
   145 //	// Notify the SMSPROT server that a backup has completed
   174 	// Notify the SMSPROT server that a backup has completed
   146 //	// that the server should powerup
   175 	// that the server should powerup
   147 //	INFO_PRINTF1(_L("Simulating a backup complete notification"));
   176 	INFO_PRINTF1(_L("Simulating a backup complete notification"));
   148 //	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   177 	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   149 //									 EBURNormal, ENoBackup);
   178 									 EBURNormal, ENoBackup);
   150 //
   179 
   151 //	// Required Pause to Allow SMSStack to hande notification and restart
   180 	// Required Pause to Allow SMSStack to hande notification and restart
   152 //	User::After(5*1000*1000);
   181 	User::After(5*1000*1000);
   153 //
   182 
   154 //	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrNone"));
   183 	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrNone"));
   155 //	TEST(SendSmsL(socket) == KErrNone);
   184 	TEST(SendSmsL(socket) == KErrNone);
   156 //
   185 
   157 //	// Notify the SMSPROT server that a restore is about to take place and
   186 	// Notify the SMSPROT server that a restore is about to take place and
   158 //	// that the server should powerdown
   187 	// that the server should powerdown
   159 //	INFO_PRINTF1(_L("Simulating a restore notification"));
   188 	INFO_PRINTF1(_L("Simulating a restore notification"));
   160 //	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   189 	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   161 //									 EBURRestorePartial, EBackupIncrement);
   190 									 EBURRestorePartial, EBackupIncrement);
   162 //
   191 
   163 //	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrDisconnected"));
   192 	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrDisconnected"));
   164 //	TEST(SendSmsL(socket) == KErrDisconnected);
   193 	TEST(SendSmsL(socket) == KErrDisconnected);
   165 //
   194 
   166 //	// Notify the SMSPROT server that a restore has completed
   195 	// Notify the SMSPROT server that a restore has completed
   167 //	// that the server should powerup
   196 	// that the server should powerup
   168 //	INFO_PRINTF1(_L("Simulating a restore complete notification"));
   197 	INFO_PRINTF1(_L("Simulating a restore complete notification"));
   169 //	
   198 	
   170 //	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   199 	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   171 //									 EBURNormal, ENoBackup);
   200 									 EBURNormal, ENoBackup);
   172 //
   201 
   173 //	// Required Pause to Allow SMSStack to hande notification and restart
   202 	// Required Pause to Allow SMSStack to hande notification and restart
   174 //	User::After(5*1000*1000);
   203 	User::After(5*1000*1000);
   175 //	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrNone"));
   204 	INFO_PRINTF1(_L("Expecting SendSmsL to return KErrNone"));
   176 //	TEST(SendSmsL(socket) == KErrNone);
   205 	TEST(SendSmsL(socket) == KErrNone);
   177 //
   206 
   178 //	INFO_PRINTF1(_L("Closing SocketServer ..."));
   207 	INFO_PRINTF1(_L("Closing SocketServer ..."));
   179 //	CleanupStack::PopAndDestroy(&socket);
   208 	CleanupStack::PopAndDestroy(&socket);
   180 	return TestStepResult();
   209 	CleanupStack::PopAndDestroy(&iSocketServer);
   181 	}
   210 	return TestStepResult();
       
   211 	}
       
   212 
       
   213 
   182 
   214 /**
   183 /**
   215  *  Tests the Backup and Restore operation when the phone is powered off.
   184  *  Tests the Backup and Restore operation when the phone is powered off.
   216  */
   185  */
   217 TVerdict CTestSmsPrtBackupWhenPhoneIsOff::doTestStepL()
   186 TVerdict CTestSmsPrtBackupWhenPhoneIsOff::doTestStepL()
   218 	{
   187 	{
   219 	PrepareRegTestLC(iSocketServer, 2);
   188 //	RSocket socket;
   220 	RSocket socket;
   189 //	iSmsStackTestUtils->OpenSmsSocketLC(iSocketServer,socket,ESmsAddrSendOnly);
   221 	iSmsStackTestUtils->OpenSmsSocketLC(iSocketServer,socket,ESmsAddrSendOnly);
   190 //
   222 
   191 //	//
   223 	//
   192 //	// Perform backup abnd restore when the phone is powered down...
   224 	// Perform backup abnd restore when the phone is powered down...
   193 //	//
   225 	//
   194 //	INFO_PRINTF1(_L("Simulating a backup and restore while the phone is off"));
   226 	INFO_PRINTF1(_L("Simulating a backup and restore while the phone is off"));
   195 //	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid,
   227 	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid,
   196 //									  ESAPhoneOff));
   228 									  ESAPhoneOff));
   197 //	
   229 	
   198 //	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   230 	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   199 //									 EBURBackupFull, EBackupBase);
   231 									 EBURBackupFull, EBackupBase);
   200 //
   232 
   201 //	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   233 	iSecureBackupEngine->SetBURModeL(TDriveList(_L8("C")),
   202 //									 EBURNormal, ENoBackup);
   234 									 EBURNormal, ENoBackup);
   203 //
   235 
   204 //	User::After(5*1000*1000);
   236 	User::After(5*1000*1000);
   205 //
   237 
   206 //	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid,
   238 	User::LeaveIfError(RProperty::Set(KUidSystemCategory, KUidPhonePwr.iUid,
   207 //									  ESAPhoneOn));
   239 									  ESAPhoneOn));
   208 //
   240 
   209 //	INFO_PRINTF1(_L("Closing SocketServer..."));
   241 	INFO_PRINTF1(_L("Closing SocketServer..."));
   210 //	CleanupStack::PopAndDestroy(&socket);
   242 	CleanupStack::PopAndDestroy(&socket);
   211 //	iSocketServer.Close();
   243 	CleanupStack::PopAndDestroy(&iSocketServer);
   212 //
   244 
   213 //	// TODO: check if this part is still valid
   245 	//
   214 //	//
   246 	// Ensure the SMS Stack has been reloaded, prior to performing the ESock
   215 //	// Ensure the SMS Stack has been reloaded, prior to performing the ESock
   247 	// memory leak check.
   216 //	// memory leak check.
   248 	//
   217 //	//
   249 	PrepareRegTestLC(iSocketServer, 2);
   218 //	ConnectSocketServerL(iSocketServer);
   250 	iSmsStackTestUtils->OpenSmsSocketLC(iSocketServer,socket,ESmsAddrSendOnly);
   219 //	iSmsStackTestUtils->OpenSmsSocketLC(iSocketServer,socket,ESmsAddrSendOnly);
   251 
   220 //
   252 	CleanupStack::PopAndDestroy(&socket);
   221 //	CleanupStack::PopAndDestroy(&socket);
   253 	CleanupStack::PopAndDestroy(&iSocketServer);
   222 	return TestStepResult();
   254 
   223 	}
   255 	return TestStepResult();
       
   256 	} // CTestSmsPrtBackupWhenPhoneIsOff::doTestStepL