datacommsserver/esockserver/test/TE_EsockTestSteps/src/BearerMobility.TestSteps.cpp
changeset 0 dfb7c4ff071f
equal deleted inserted replaced
-1:000000000000 0:dfb7c4ff071f
       
     1 // Copyright (c) 2006-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 //
       
    15 
       
    16 /**
       
    17  @file BearerMobility.TestSteps.cpp
       
    18 */
       
    19 
       
    20 #include "Connections.TestSteps.h"
       
    21 #include "BearerMobility.TestSteps.h"
       
    22 
       
    23 
       
    24 using namespace ESock;
       
    25 
       
    26 // Accept
       
    27 //-------
       
    28 
       
    29 Cacceptcarrierrcommsmobilityapiext::Cacceptcarrierrcommsmobilityapiext(CCEsockTestBase*& aEsockTest)
       
    30 :   CTe_EsockStepBase(aEsockTest)
       
    31 	{
       
    32 	SetTestStepName(Kacceptcarrierrcommsmobilityapiext);
       
    33 	}
       
    34 
       
    35 TInt Cacceptcarrierrcommsmobilityapiext::ConfigureFromIni()
       
    36     {
       
    37 	//clean parameters from previous runs
       
    38 	iMobilityExtName.Set(KNullDesC);
       
    39 	iConnectionName.Set(KNullDesC);
       
    40 
       
    41     //try reading the name of the subconnection bundle
       
    42     if (GetStringFromConfig(iSection,KTe_MobilityAPIName,iMobilityExtName)!=1
       
    43         || iMobilityExtName.Length()==0)
       
    44             return KErrNotFound;
       
    45 
       
    46     return KErrNone;
       
    47     }
       
    48 
       
    49 
       
    50 TVerdict Cacceptcarrierrcommsmobilityapiext::doSingleTestStep()
       
    51 	{
       
    52 	RCommsMobilityApiExt* mob = iEsockTest->FindMobilityExtension(iMobilityExtName);
       
    53     if (mob==NULL)
       
    54         {
       
    55         INFO_PRINTF1(_L("Could not find mobility extension."));
       
    56         return EFail;
       
    57         }
       
    58     mob->NewCarrierAccepted();
       
    59     
       
    60 	return EPass;
       
    61 	}
       
    62 
       
    63 // Reject
       
    64 //-------
       
    65 Crejectcarrierrcommsmobilityapiext::Crejectcarrierrcommsmobilityapiext(CCEsockTestBase*& aEsockTest)
       
    66 :   CTe_EsockStepBase(aEsockTest)
       
    67 	{
       
    68 	SetTestStepName(Krejectcarrierrcommsmobilityapiext);
       
    69 	}
       
    70 
       
    71 TInt Crejectcarrierrcommsmobilityapiext::ConfigureFromIni()
       
    72     {
       
    73 	//clean parameters from previous runs
       
    74 	iMobilityExtName.Set(KNullDesC);
       
    75 	iConnectionName.Set(KNullDesC);
       
    76 
       
    77     //try reading the name of the subconnection bundle
       
    78     if (GetStringFromConfig(iSection,KTe_MobilityAPIName,iMobilityExtName)!=1
       
    79         || iMobilityExtName.Length()==0)
       
    80             return KErrNotFound;
       
    81 
       
    82     return KErrNone;
       
    83     }
       
    84 
       
    85 TVerdict Crejectcarrierrcommsmobilityapiext::doSingleTestStep()
       
    86 	{
       
    87     RCommsMobilityApiExt* mob = iEsockTest->FindMobilityExtension(iMobilityExtName);
       
    88     if (mob==NULL)
       
    89         {
       
    90         INFO_PRINTF1(_L("Could not find mobility extension."));
       
    91         return EFail;
       
    92         }   
       
    93    	mob->NewCarrierRejected();
       
    94 
       
    95 	return EPass;
       
    96 	}
       
    97 
       
    98 
       
    99 // Cancel notification
       
   100 //--------------------
       
   101 
       
   102 CCancelMobilityNotificationStep::CCancelMobilityNotificationStep(CCEsockTestBase*& aEsockTest)
       
   103 :   CTe_EsockStepBase(aEsockTest)
       
   104 	{
       
   105 	SetTestStepName(KCancelMobilityNotificationStep);
       
   106 	}
       
   107 
       
   108 TInt CCancelMobilityNotificationStep::ConfigureFromIni()
       
   109     {
       
   110 	//clean parameters from previous runs
       
   111 	iMobilityExtName.Set(KNullDesC);
       
   112 
       
   113     //try reading the name of the subconnection bundle
       
   114     if (GetStringFromConfig(iSection,KTe_MobilityAPIName,iMobilityExtName)!=1
       
   115         || iMobilityExtName.Length()==0)
       
   116             return KErrNotFound;
       
   117 
       
   118     return KErrNone;
       
   119     }
       
   120 
       
   121 
       
   122 TVerdict CCancelMobilityNotificationStep::doSingleTestStep()
       
   123 	{
       
   124 	SetTestStepResult(EFail);
       
   125 	RCommsMobilityApiExt* mob = iEsockTest->FindMobilityExtension(iMobilityExtName);
       
   126 	if (mob==NULL)
       
   127 		{
       
   128 		INFO_PRINTF1(_L("Could not find mobility extension."));
       
   129 		}
       
   130 	else
       
   131 		{
       
   132 		mob->CancelMobilityNotification();
       
   133 		SetTestStepResult(EPass);
       
   134 		}
       
   135 
       
   136 	return TestStepResult();
       
   137 	}
       
   138 
       
   139 
       
   140 // Migrate
       
   141 //--------
       
   142 
       
   143 Cmigratercommsmobilityapiext::Cmigratercommsmobilityapiext(CCEsockTestBase*& aEsockTest)
       
   144 :   CTe_EsockStepBase(aEsockTest)
       
   145 	{
       
   146 	SetTestStepName(Kmigratercommsmobilityapiext);
       
   147 	}
       
   148 
       
   149 TInt Cmigratercommsmobilityapiext::ConfigureFromIni()
       
   150     {
       
   151 	//clean parameters from previous runs
       
   152 	iMobilityExtName.Set(KNullDesC);
       
   153 	iConnectionName.Set(KNullDesC);
       
   154 
       
   155     //try reading the name of the subconnection bundle
       
   156     if (GetStringFromConfig(iSection,KTe_MobilityAPIName,iMobilityExtName)!=1
       
   157         || iMobilityExtName.Length()==0)
       
   158             return KErrNotFound;
       
   159 
       
   160     return KErrNone;
       
   161     }
       
   162 
       
   163 
       
   164 TVerdict Cmigratercommsmobilityapiext::doSingleTestStep()
       
   165 	{
       
   166     RCommsMobilityApiExt* mob = iEsockTest->FindMobilityExtension(iMobilityExtName);
       
   167     if (mob==NULL)
       
   168         {
       
   169         INFO_PRINTF1(_L("Could not find mobility extension."));
       
   170         return EFail;
       
   171         }
       
   172 
       
   173  	mob->MigrateToPreferredCarrier();
       
   174 
       
   175 	return EPass;
       
   176 	}
       
   177 
       
   178 
       
   179 // Ignore
       
   180 //-------
       
   181 
       
   182 Cignorercommsmobilityapiext::Cignorercommsmobilityapiext(CCEsockTestBase*& aEsockTest)
       
   183 :   CTe_EsockStepBase(aEsockTest)
       
   184 	{
       
   185 	SetTestStepName(Kignorercommsmobilityapiext);
       
   186 	}
       
   187 
       
   188 TInt Cignorercommsmobilityapiext::ConfigureFromIni()
       
   189     {
       
   190 	//clean parameters from previous runs
       
   191 	iMobilityExtName.Set(KNullDesC);
       
   192 
       
   193     //try reading the name of the subconnection bundle
       
   194     if (GetStringFromConfig(iSection,KTe_MobilityAPIName,iMobilityExtName)!=1
       
   195         || iMobilityExtName.Length()==0)
       
   196             return KErrNotFound;
       
   197 
       
   198     return KErrNone;
       
   199     }
       
   200 
       
   201 
       
   202 TVerdict Cignorercommsmobilityapiext::doSingleTestStep()
       
   203 	{
       
   204     RCommsMobilityApiExt* mob = iEsockTest->FindMobilityExtension(iMobilityExtName);
       
   205     if (mob==NULL)
       
   206         {
       
   207         INFO_PRINTF1(_L("Could not find mobility extension."));
       
   208         return EFail;
       
   209         }
       
   210 
       
   211 	mob->IgnorePreferredCarrier();
       
   212 
       
   213 	return EPass;
       
   214 	}
       
   215 
       
   216 
       
   217 // Check
       
   218 //------
       
   219 CCheckMobilityNotificationStep::CCheckMobilityNotificationStep(CCEsockTestBase*& aEsockTest)
       
   220 :   CTe_EsockStepBase(aEsockTest)
       
   221     {
       
   222 	SetTestStepName(KCheckMobilityNotificationStep);
       
   223 	}
       
   224 
       
   225 TInt CCheckMobilityNotificationStep::ConfigureFromIni()
       
   226 	{
       
   227 	iParams.Reset();
       
   228 	iOldAP = 0;
       
   229 	iNewAP = 0;
       
   230 	iExpectedError = KExpectedErrorNotUsed;
       
   231 	iExpectedError2 = KExpectedErrorNotUsed;
       
   232 
       
   233 	// Read in appropriate fields
       
   234 	if((GetStringFromConfig(iSection, KTe_MobilityAPIName, iParams.iMobilityExtName) != 1)
       
   235 		|| (iParams.iMobilityExtName.Length() == 0))
       
   236 		{
       
   237 		INFO_PRINTF1(_L("Couldn't find appropriate field in config file"));
       
   238 		return KErrNotFound;
       
   239 		}
       
   240 
       
   241 	//calculate name for the event container (it is not settable from the ini)
       
   242 	iEventName = iParams.iMobilityExtName;
       
   243 	iEventName.Append(_L("_EvContainer"));
       
   244 	iParams.iEventName.Set(iEventName);
       
   245 
       
   246 	// Get any timeout value and if we have one then we are not expecting any notification
       
   247 	if(!GetIntFromConfig(iSection, KTimeoutInMilliSeconds, iParams.iTimeoutMiliSecs))
       
   248 		{
       
   249 		// Default to 5 second timeout
       
   250 		iParams.iTimeoutMiliSecs = 7000; //Seven for luck :)) and really to be shorter than the idle timer (10)
       
   251 		}
       
   252 
       
   253 	//there may be more than one expected event kind, register all of them
       
   254 	TBool descriptionComplete = EFalse;
       
   255 
       
   256 	for (TInt idx = 0; !descriptionComplete; idx++)
       
   257 		{
       
   258 		TBuf<KMaxTestExecuteNameLength> fieldName(KTe_Expected);
       
   259 		fieldName.AppendNum(idx);
       
   260 
       
   261 		TPtrC eventName;
       
   262 		if (GetStringFromConfig(iSection,fieldName,eventName)==1)
       
   263 			{
       
   264 			TBuf<KMaxTestExecuteNameLength> fieldNameAp(fieldName);
       
   265 			fieldNameAp.Append(KTe_MobilityNotificationPreferredCarrierAvailable_NewAP);
       
   266 			if (eventName.Compare(KTe_MobilityNotificationPreferredCarrierAvailable)==0)
       
   267 				{
       
   268 				iParams.iEventMask |= ESock::EPreferredCarrierAvailable;
       
   269 				GetIntFromConfig(iSection,fieldNameAp,iNewAP);
       
   270 
       
   271 				fieldNameAp.Copy(fieldName);
       
   272 				fieldNameAp.Append(KTe_MobilityNotificationPreferredCarrierAvailable_OldAP);
       
   273 				GetIntFromConfig(iSection,fieldNameAp,iOldAP);
       
   274 				}
       
   275 			else if (eventName.Compare(KTe_MobilityNotificationNewCarrierActive)==0)
       
   276 				{
       
   277 				iParams.iEventMask |= ESock::ENewCarrierActive;
       
   278 				GetIntFromConfig(iSection,fieldNameAp,iNewAP);
       
   279 				}
       
   280 			else
       
   281 			   {
       
   282 			   INFO_PRINTF3(_L("%S: Event type (%S) not recognised."),&iParams.iMobilityExtName,&eventName);
       
   283 			   return KErrNotFound;
       
   284 			   }
       
   285 			}
       
   286 		else
       
   287 			{
       
   288 			descriptionComplete = ETrue;
       
   289 			}
       
   290 		}
       
   291 
       
   292 	// Log what events we are expecting if any
       
   293 	if(iParams.iEventMask)
       
   294 		{
       
   295 		INFO_PRINTF3(_L("%S: Events to be expected: 0x%x"),&iParams.iMobilityExtName,iParams.iEventMask);
       
   296 		}
       
   297 	else
       
   298 		{
       
   299 		INFO_PRINTF2(_L("%S: No events specified so expecting no notifications and to timeout instead."), &iParams.iMobilityExtName);
       
   300 		}
       
   301 
       
   302 	// What error are we expecting?
       
   303 	if (!GetIntFromConfig(iSection, KExpectedError,iExpectedError))  
       
   304 		{
       
   305 		iExpectedError = KExpectedErrorNotUsed;
       
   306 		}
       
   307 	else 
       
   308 		{
       
   309 		INFO_PRINTF2(_L("Error to be expected: %d"),iExpectedError);
       
   310 		}
       
   311 
       
   312 	// What error are we expecting?
       
   313 	if (!GetIntFromConfig(iSection, KExpectedError2,iExpectedError2))
       
   314 		{
       
   315 		iExpectedError2 = KExpectedErrorNotUsed;
       
   316 		}
       
   317 
       
   318     // All ok if we got this far
       
   319     return KErrNone;
       
   320 	}
       
   321 
       
   322 TVerdict CCheckMobilityNotificationStep::doSingleTestStep()
       
   323 	{
       
   324     SetTestStepResult(EFail);
       
   325     TDesC8* buffer = NULL;
       
   326 
       
   327 	// Wait for the outstanding mobility notifications
       
   328     TInt error = iEsockTest->ReceiveMobilityNotification(buffer, iParams);
       
   329 
       
   330 	if ((iExpectedError != KExpectedErrorNotUsed && error == iExpectedError)
       
   331 		|| (iExpectedError2 != KExpectedErrorNotUsed && error == iExpectedError2))
       
   332 		{
       
   333 		INFO_PRINTF2(_L("Error (%d) received as expected"),error);
       
   334 		SetTestStepResult(EPass);
       
   335 		return TestStepResult();
       
   336 		}
       
   337 
       
   338 	// If we weren't expecting any mobility events and timed out waiting then we passed
       
   339 	// But if we weren't expecting any and received one then we failed
       
   340     if (error == KErrCancel)
       
   341     	{
       
   342 		if(iParams.iEventMask == 0)
       
   343 			{
       
   344 			INFO_PRINTF1(_L("Timed out waiting for notifications when expecting to do so."));
       
   345 			SetTestStepResult(EPass);
       
   346 			}
       
   347 		else
       
   348 			{
       
   349 			INFO_PRINTF1(_L("Timed out when expecting an event."));
       
   350 			}
       
   351 		return TestStepResult();
       
   352 		}
       
   353 
       
   354 	if((error == KErrNone) && (buffer != NULL))
       
   355 		{
       
   356 		if(iParams.iEventMask != 0)
       
   357 			{
       
   358 			CCommsApiExtRespMsg * msg = NULL;
       
   359 			TRAP(error, msg = CCommsApiExtRespMsg::NewL(*buffer));
       
   360 
       
   361 			if(error != KErrNone || msg == NULL)
       
   362 				{
       
   363 				INFO_PRINTF2(_L("Could not demarshall incoming notification. error:%d."), error);
       
   364 				}
       
   365 			else
       
   366 				{
       
   367 				//check types
       
   368 				STypeId preferredCarrierAvailableTID = STypeId::CreateSTypeId(ESock::KMobilityMessagesImplementationUid, ESock::EPreferredCarrierAvailable);
       
   369 				STypeId newCarrierActiveTID = STypeId::CreateSTypeId(ESock::KMobilityMessagesImplementationUid, ESock::ENewCarrierActive);
       
   370 
       
   371 				if (msg->IsTypeOf(preferredCarrierAvailableTID))
       
   372 					{
       
   373 					CPreferredCarrierAvailable* pca = static_cast<CPreferredCarrierAvailable*>(msg);
       
   374 					if ((iParams.iEventMask & ESock::EPreferredCarrierAvailable)
       
   375 						&& (iNewAP==0 || iNewAP==pca->NewAPInfo().AccessPoint())
       
   376 						&& (iOldAP==0 || iOldAP==pca->OldAPInfo().AccessPoint()))
       
   377 						{
       
   378 						INFO_PRINTF4(_L("%S: Received PreferredCarrierAvailable notification from AP%d to AP%d as expected."),&iParams.iMobilityExtName, pca->OldAPInfo().AccessPoint(), pca->NewAPInfo().AccessPoint());
       
   379 						SetTestStepResult(EPass);
       
   380 						}
       
   381 					else
       
   382 						{
       
   383 						INFO_PRINTF4(_L("%S: Received PreferredCarrierAvailable notification from AP%d to AP%d which was unexpected."),&iParams.iMobilityExtName, pca->OldAPInfo().AccessPoint(), pca->NewAPInfo().AccessPoint());
       
   384 						}
       
   385 					}
       
   386 
       
   387 				else if (msg->IsTypeOf(newCarrierActiveTID))
       
   388 					{
       
   389 					CNewCarrierActive* nca = static_cast<CNewCarrierActive*>(msg);
       
   390 					if ((iParams.iEventMask & ESock::ENewCarrierActive)
       
   391 						&& (iNewAP==0 || iNewAP==nca->NewAPInfo().AccessPoint()))
       
   392 						{
       
   393 						INFO_PRINTF3(_L("%S: Received NewCarrierActive notification for AP%d as expected."),&iParams.iMobilityExtName, nca->NewAPInfo().AccessPoint());
       
   394 						SetTestStepResult(EPass);
       
   395 						}
       
   396 					else
       
   397 						{
       
   398 						INFO_PRINTF3(_L("%S: Received NewCarrierActive notification for AP%d which was unexpected."),&iParams.iMobilityExtName, nca->NewAPInfo().AccessPoint());
       
   399 						}
       
   400 					}
       
   401 				}
       
   402 
       
   403 			delete msg;
       
   404 			REComSession::FinalClose(); //Different thread to the main one, need to be closed here as well
       
   405 			}
       
   406 		else
       
   407 			{
       
   408 			// We were expecting a timeout and instead received a notification so we have failed
       
   409 			INFO_PRINTF1(_L("We were not expecting a notification expecting to timeout."));
       
   410 			}
       
   411 		}
       
   412     else if (error != KErrNone)
       
   413         {
       
   414         INFO_PRINTF3(_L("%S: The error code returned was %d."), &iParams.iMobilityExtName, error);
       
   415         SetTestStepError(error);
       
   416         }
       
   417     else if (buffer == NULL)
       
   418         {
       
   419         INFO_PRINTF2(_L("%S: Did not receive any notification"),&iParams.iMobilityExtName);
       
   420         }
       
   421 
       
   422 	return TestStepResult();
       
   423 	}
       
   424 
       
   425 
       
   426 // Close 
       
   427 //------
       
   428 
       
   429 CCloseRCommsMobilityAPIExtStep::CCloseRCommsMobilityAPIExtStep(CCEsockTestBase*& aEsockTest)
       
   430 :   CTe_EsockStepBase(aEsockTest)
       
   431 	{
       
   432 	SetTestStepName(KCloseRCommsMobilityAPIExtStep);
       
   433 	}
       
   434 
       
   435 TInt CCloseRCommsMobilityAPIExtStep::ConfigureFromIni()
       
   436 	{
       
   437 	iMobilityExtName.Set(KNullDesC);
       
   438 
       
   439 	// Read in appropriate fields
       
   440 	if((GetStringFromConfig(iSection, KTe_MobilityAPIName, iMobilityExtName) != 1)
       
   441 		|| (iMobilityExtName.Length() == 0))
       
   442 		{
       
   443 		INFO_PRINTF1(_L("Couldn't find appropriate field in config file"));
       
   444 		return KErrNotFound;
       
   445 		}
       
   446 
       
   447     // All ok if we got this far
       
   448     return KErrNone;
       
   449 	}
       
   450 
       
   451 TVerdict CCloseRCommsMobilityAPIExtStep::doSingleTestStep()
       
   452 	{
       
   453     RCommsMobilityApiExt* mob = iEsockTest->FindMobilityExtension(iMobilityExtName);
       
   454     if (mob==NULL)
       
   455         {
       
   456         INFO_PRINTF1(_L("Could not find mobility extension."));
       
   457         return EFail;
       
   458         }
       
   459     
       
   460     mob->Close();
       
   461 	return EPass;
       
   462 	}
       
   463 
       
   464 // Open
       
   465 //-----
       
   466 
       
   467 COpenRCommsMobilityAPIExtStep::COpenRCommsMobilityAPIExtStep(CCEsockTestBase*& aEsockTest)
       
   468 :   CTe_EsockStepBase(aEsockTest)
       
   469 	{
       
   470 	SetTestStepName(KOpenRCommsMobilityAPIExtStep);
       
   471 	}
       
   472 
       
   473 TInt COpenRCommsMobilityAPIExtStep::ConfigureFromIni()
       
   474     {
       
   475 	//clean parameters from previous runs
       
   476 	iMobilityExtName.Set(KNullDesC);
       
   477 	iConnectionName.Set(KNullDesC);
       
   478 
       
   479     //try reading the name of the subconnection bundle
       
   480     if (GetStringFromConfig(iSection, KTe_MobilityAPIName, iMobilityExtName)!=1
       
   481         || iMobilityExtName.Length()==0)
       
   482             return KErrNotFound;
       
   483 
       
   484     if (GetStringFromConfig(iSection,KTe_ConnectionName,iConnectionName)!=1)
       
   485         {
       
   486         INFO_PRINTF1(_L("Connection name missing."));
       
   487         return KErrNotFound;
       
   488         }
       
   489 
       
   490     return KErrNone;
       
   491     }
       
   492 
       
   493 TVerdict COpenRCommsMobilityAPIExtStep::doSingleTestStep()
       
   494 	{
       
   495 	SetTestStepResult(EFail);
       
   496 	RConnection* c = iEsockTest->FindConnection(iConnectionName);
       
   497 	if (c==NULL)
       
   498 		{
       
   499 		INFO_PRINTF2(_L("Could not find RConnection (%S)."),&iConnectionName);
       
   500 		return EFail;
       
   501 		}
       
   502 
       
   503 	TInt error = iEsockTest->CreateMobilityExtension(iMobilityExtName);
       
   504 	if (error!=KErrNone)
       
   505 		{
       
   506 		INFO_PRINTF2(_L("Could not create mobility extension (%d)."),error);
       
   507 		return EFail;
       
   508 		}
       
   509 
       
   510 	RCommsMobilityApiExt* mob = iEsockTest->FindMobilityExtension(iMobilityExtName);
       
   511 	if (mob==NULL)
       
   512 		{
       
   513 		INFO_PRINTF1(_L("Could not find mobility extension."));
       
   514 		return EFail;
       
   515 		}
       
   516 
       
   517 	error = mob->Open(*c);
       
   518 	if (error!=KErrNone)
       
   519 		{
       
   520 		INFO_PRINTF3(_L("Could not apply %S to %S."),&iMobilityExtName,&iConnectionName);
       
   521 		INFO_PRINTF2(_L("Error returned: %d."),error);
       
   522 		SetTestStepError(error);
       
   523 		return EFail;
       
   524 		}
       
   525 
       
   526 	return EPass;
       
   527 	}
       
   528 
       
   529 
       
   530 // Register for notifications
       
   531 //---------------------------
       
   532 
       
   533 CRegisterForMobilityNotificationStep::CRegisterForMobilityNotificationStep(CCEsockTestBase*& aEsockTest)
       
   534 :   CTe_EsockStepBase(aEsockTest)
       
   535     {
       
   536 	SetTestStepName(KRegisterForMobilityNotificationStep);
       
   537 	}
       
   538 
       
   539 TInt CRegisterForMobilityNotificationStep::ConfigureFromIni()
       
   540 	{
       
   541 	//clean parameters from previous runs
       
   542 	iParams.Reset();
       
   543 
       
   544     //try reading the next event container's name
       
   545     if (GetStringFromConfig(iSection, KTe_MobilityAPIName, iParams.iMobilityExtName)!=1
       
   546         || iParams.iMobilityExtName.Length()==0)
       
   547             return KErrNotFound;
       
   548 
       
   549 	//calculate name for the event container (it is not settable from the ini)
       
   550 	iEventName = iParams.iMobilityExtName;
       
   551 	iEventName.Append(_L("_EvContainer"));
       
   552 	iParams.iEventName.Set(iEventName);
       
   553 
       
   554     TPtrC eventName;
       
   555     if (GetStringFromConfig(iSection,KTe_Register,eventName)==1)
       
   556         {
       
   557         //first check, maybe someone wants to register for all events?
       
   558         if (eventName.Compare(KTe_All)==0)
       
   559             {
       
   560             iParams.iAllEvents = ETrue;
       
   561             INFO_PRINTF2(_L("%S: Events to be registered: All"),&iParams.iMobilityExtName);
       
   562             return KErrNone;
       
   563             }
       
   564         }
       
   565 
       
   566     //secondly..
       
   567     //go through the list of particular events to register.
       
   568     //there may be more than one expected event kind, register all of them
       
   569     TBool desciptionFound = ETrue;
       
   570     for (TInt idx = 0; desciptionFound; idx++)
       
   571         {
       
   572         TBuf<KMaxTestExecuteNameLength> fieldName(KTe_Register);
       
   573         fieldName.AppendNum(idx);
       
   574         if (GetStringFromConfig(iSection,fieldName,eventName)==1)
       
   575             {
       
   576             if (eventName.Compare(KTe_MobilityNotificationPreferredCarrierAvailable)==0)
       
   577         	    { iParams.iEventMask |= ESock::EPreferredCarrierAvailable; }
       
   578             else if (eventName.Compare(KTe_MobilityNotificationNewCarrierActive)==0)
       
   579         	    { iParams.iEventMask |= ESock::ENewCarrierActive; }
       
   580             else
       
   581                {
       
   582                INFO_PRINTF3(_L("%S: Mobility notification type (%S) not recognised."),&iParams.iMobilityExtName,&eventName);
       
   583                return KErrNotFound;
       
   584                }
       
   585             }
       
   586         else
       
   587             {
       
   588             //at least one event type must be present
       
   589             if (idx==0)
       
   590                 {
       
   591                 INFO_PRINTF2(_L("%S: Mobility notification type missing."),&iParams.iMobilityExtName);
       
   592                 return KErrNotFound;
       
   593                 }
       
   594             else
       
   595                 {
       
   596                 desciptionFound = KErrNotFound; //break the loop
       
   597                 }
       
   598             }
       
   599         }
       
   600 
       
   601     INFO_PRINTF3(_L("%S: Mobility notifications to be registered: 0x%x"),&iParams.iMobilityExtName,iParams.iEventMask);
       
   602     return KErrNone;
       
   603 	}
       
   604 
       
   605 TVerdict CRegisterForMobilityNotificationStep::doSingleTestStep()
       
   606 	{
       
   607    	TInt error = iEsockTest->RegisterForMobilityNotification(iParams);
       
   608     if (error!=KErrNone)
       
   609         {
       
   610         INFO_PRINTF2(_L("Could not register for mobility notifications (%S)."),&iParams.iMobilityExtName);
       
   611         INFO_PRINTF2(_L("Error: %d"),error);
       
   612         return EFail;
       
   613         }
       
   614 
       
   615 	return EPass;
       
   616 	}
       
   617 	
       
   618 // Mobility notification	
       
   619 //----------------------
       
   620 Cmobilitynotifyrcommsmobilityapiext::Cmobilitynotifyrcommsmobilityapiext(CCEsockTestBase*& aEsockTest)
       
   621 :   CTe_EsockStepBase(aEsockTest)
       
   622 	{
       
   623 	SetTestStepName(Kmobilitynotifyrcommsmobilityapiext);
       
   624 	}
       
   625 
       
   626 
       
   627 TVerdict Cmobilitynotifyrcommsmobilityapiext::doSingleTestStep()
       
   628 	{
       
   629     RCommsMobilityApiExt* mob = iEsockTest->FindMobilityExtension(iMobilityExtName);
       
   630     if (mob==NULL)
       
   631         {
       
   632         INFO_PRINTF1(_L("Could not find mobility extension."));
       
   633         return EFail;
       
   634         }
       
   635     
       
   636    	TRequestStatus tStatus;
       
   637    	TBuf8<20> tResponseEventBuf;
       
   638    	mob->RegisterForMobilityNotification(tResponseEventBuf, tStatus);
       
   639 
       
   640 	return EPass;
       
   641 	}
       
   642 	
       
   643 TInt Cmobilitynotifyrcommsmobilityapiext::ConfigureFromIni()
       
   644 	{
       
   645 	//clean parameters from previous runs
       
   646 	iMobilityExtName.Set(KNullDesC);
       
   647 	iConnectionName.Set(KNullDesC);
       
   648 
       
   649     //try reading the name of the subconnection bundle
       
   650     if (GetStringFromConfig(iSection,KTe_MobilityAPIName,iMobilityExtName)!=1
       
   651         || iMobilityExtName.Length()==0)
       
   652             return KErrNotFound;
       
   653 
       
   654     return KErrNone;
       
   655 	}
       
   656 
       
   657 // Cancel mobility notification
       
   658 //-----------------------------
       
   659 Ccancelnotifyrcommsmobilityapiext::Ccancelnotifyrcommsmobilityapiext(CCEsockTestBase*& aEsockTest)
       
   660 :   CTe_EsockStepBase(aEsockTest)
       
   661 	{
       
   662 	SetTestStepName(Kcancelnotifyrcommsmobilityapiext);
       
   663 	}
       
   664 
       
   665 TVerdict Ccancelnotifyrcommsmobilityapiext::doSingleTestStep()
       
   666 	{
       
   667     RCommsMobilityApiExt* mob = iEsockTest->FindMobilityExtension(iMobilityExtName);
       
   668     if (mob==NULL)
       
   669         {
       
   670         INFO_PRINTF1(_L("Could not find mobility extension."));
       
   671         return EFail;
       
   672         }
       
   673 
       
   674 	mob->CancelMobilityNotification();
       
   675 	
       
   676 	return EPass;
       
   677 	}
       
   678 	
       
   679 TInt Ccancelnotifyrcommsmobilityapiext::ConfigureFromIni()
       
   680 	{
       
   681 	//clean parameters from previous runs
       
   682 	iMobilityExtName.Set(KNullDesC);
       
   683 	iConnectionName.Set(KNullDesC);
       
   684 
       
   685     //try reading the name of the subconnection bundle
       
   686     if (GetStringFromConfig(iSection,KTe_MobilityAPIName,iMobilityExtName)!=1
       
   687         || iMobilityExtName.Length()==0)
       
   688             return KErrNotFound;
       
   689 
       
   690     return KErrNone;
       
   691 	}
       
   692