telephonyserverplugins/multimodetsy/test/Te_Gprs/Te_GprsTestStepBase.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2005-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 #include "Te_GprsTestStepBase.h"
       
    17 #include "Te_Gprscfgfile.h"
       
    18 
       
    19 TVerdict CGprsTestStep::doTestStepPreambleL()
       
    20 	{
       
    21 	__UHEAP_MARK;
       
    22 
       
    23 	iTestScheduler=new (ELeave) CActiveScheduler;
       
    24 	CActiveScheduler::Install(iTestScheduler);
       
    25 
       
    26 	TInt ret = iTelServer.Connect();
       
    27 	if (ret!=KErrNone)
       
    28 		{
       
    29 		INFO_PRINTF1(_L("Failed to connect to telephony server"));
       
    30 		delete iTestScheduler;
       
    31 		User::Leave(ret);
       
    32 		}
       
    33    	ret=iTelServer.LoadPhoneModule(KtsyName);
       
    34 	if (ret!=KErrNone)
       
    35 		{
       
    36 		INFO_PRINTF1(_L("Failed to load phone module"));
       
    37 		iTelServer.Close();
       
    38 		delete iTestScheduler;
       
    39 		User::Leave(ret);
       
    40 		}
       
    41 
       
    42 	ret=iPhone.Open(iTelServer,KPhoneName) ;
       
    43 	if (ret!=KErrNone)
       
    44 		{
       
    45 		INFO_PRINTF1(_L("Failed to open phone module"));
       
    46 		iTelServer.UnloadPhoneModule(KtsyName);
       
    47 		iTelServer.Close();
       
    48 		delete iTestScheduler;
       
    49 		User::Leave(ret);
       
    50 		}
       
    51 //
       
    52 //	This test requires a mobile phone to be connected to the serial port
       
    53 //      specified in the .cfg file for the initialise below to work
       
    54 //
       
    55 	ret=iPhone.Initialise();
       
    56 	if (ret!=KErrNone)
       
    57 		{
       
    58 		INFO_PRINTF2(_L("Failed to initialise the phone (%d)"), ret);
       
    59 		iPhone.Close();
       
    60 		iTelServer.UnloadPhoneModule(KtsyName);
       
    61 		iTelServer.Close();
       
    62 		delete iTestScheduler;
       
    63 		User::Leave(ret);
       
    64 		}
       
    65 
       
    66 	ret=iSocketServer.Connect();
       
    67 	if (ret!=KErrNone)
       
    68 		{
       
    69 		INFO_PRINTF2(_L("Failed to connect to socket server (%d)"), ret);
       
    70 		iPhone.Close();
       
    71 		iTelServer.UnloadPhoneModule(KtsyName);
       
    72 		iTelServer.Close();
       
    73 		delete iTestScheduler;
       
    74 		User::Leave(ret);
       
    75 		}
       
    76 	ret=iConnection.Open(iSocketServer,KAfInet);
       
    77 	if (ret!=KErrNone)
       
    78 		{
       
    79 		INFO_PRINTF2(_L("Failed to create connection (%d)"), ret);
       
    80 		iSocketServer.Close();
       
    81 		iPhone.Close();
       
    82 		iTelServer.UnloadPhoneModule(KtsyName);
       
    83 		iTelServer.Close();
       
    84 		delete iTestScheduler;
       
    85 		User::Leave(ret);
       
    86 		}
       
    87 
       
    88 	TRAP(ret,iTestConfigParam=CConfigParams::NewL(KTGPRSConfigFile()));
       
    89 	if (ret!=KErrNone)
       
    90 		{
       
    91 		INFO_PRINTF2(_L("Failed to create config parameters (%d)"), ret);
       
    92 		iConnection.Close();
       
    93 		iSocketServer.Close();
       
    94 		iPhone.Close();
       
    95 		iTelServer.UnloadPhoneModule(KtsyName);
       
    96 		iTelServer.Close();
       
    97 		delete iTestScheduler;
       
    98 		User::Leave(ret);
       
    99 		}
       
   100 	return TestStepResult();
       
   101 	}
       
   102 
       
   103 TVerdict CGprsTestStep::doTestStepPostambleL()
       
   104 	{
       
   105 	delete iTestConfigParam;
       
   106 	iConnection.Close();
       
   107 	iSocketServer.Close();
       
   108 	iPhone.Close();
       
   109 	iTelServer.UnloadPhoneModule(KtsyName);
       
   110 	iTelServer.Close();
       
   111 	delete iTestScheduler;
       
   112 
       
   113 	__UHEAP_MARKEND;
       
   114 	return TestStepResult();
       
   115 	}
       
   116 
       
   117 void CGprsTestStep::TestConfigParams(RPacketContext::TContextConfigGPRS& aArg1, RPacketContext::TContextConfigGPRS& aArg2)
       
   118 	{
       
   119 	TEST(aArg1.iPdpType == aArg2.iPdpType);
       
   120     TEST(aArg1.iAccessPointName == aArg2.iAccessPointName );
       
   121     TEST(aArg1.iPdpCompression == aArg2.iPdpCompression);
       
   122 	TEST(aArg1.iPdpAddress == aArg2.iPdpAddress);
       
   123 	TEST(aArg1.iAnonymousAccessReqd == aArg2.iAnonymousAccessReqd);
       
   124 	}