telephonyserverplugins/simtsy/test/Te_Sim/Te_SimPacketGPRSNotifyConfigChangeTest.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 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 // Te_SimPacketGPRSNotifyConfigChangeChangeTest.cpp
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 /**
       
    20  @file
       
    21 */
       
    22 
       
    23 #include "Te_SimPacketGPRSNotifyConfigChangeTest.h"
       
    24 
       
    25 CSimPacketGPRSNotifyConfigChangeTest::CSimPacketGPRSNotifyConfigChangeTest()
       
    26 	{ 
       
    27 	SetTestStepName(_L("GPRSNotifyConfigChangeTest"));
       
    28 	}
       
    29 
       
    30 TVerdict CSimPacketGPRSNotifyConfigChangeTest::doTestStepL()
       
    31 	{
       
    32 	INFO_PRINTF1(_L("BeginPacketGPRSNotifyConfigChangeTest"));
       
    33 
       
    34  	CreateConfigFileL(_L("c:\\config3.txt"));
       
    35  	SetTestNumberL(6);
       
    36 
       
    37 	TRequestStatus gprsReqStatus;
       
    38 	TRequestStatus gprsNotifyStatus;
       
    39 	
       
    40 	TRequestStatus gprsNotifyStatus2;
       
    41 
       
    42 	// Open phone
       
    43 	TInt ret = iPhone.Open(iTelServer,KPhoneName); 
       
    44 	INFO_PRINTF2(_L("Result: %d"),ret);
       
    45 	TESTL(ret == KErrNone); 
       
    46 	INFO_PRINTF1(_L("Opened phone object"));
       
    47 
       
    48 	// Open GPRS packet service
       
    49 	TESTL(iGPRSPacketService.Open(iPhone)==KErrNone);
       
    50 	INFO_PRINTF1(_L("Opened Packet object"));
       
    51 
       
    52 	// Open GPRS context
       
    53 	TName gprsContextName;
       
    54 	TName gprsContextNameCompare;
       
    55 	TESTL(iGPRSPacketContext.OpenNewContext(iGPRSPacketService, gprsContextName)==KErrNone);
       
    56 	gprsContextNameCompare.Append(KSimPrimaryPacketContextName);
       
    57 	gprsContextNameCompare.AppendNum(1);
       
    58 	TESTL(gprsContextName.Compare(gprsContextNameCompare)==KErrNone);
       
    59 	INFO_PRINTF1(_L("Opened GPRS Context object"));
       
    60 
       
    61 	//Opena second context from the first
       
    62 	RPacketContext GPRSPacketContext2;
       
    63 	TESTL(GPRSPacketContext2.OpenExistingContext(iGPRSPacketService, gprsContextName) == KErrNone);
       
    64 	
       
    65 	// Configure GPRS context.
       
    66 	RPacketContext::TContextConfigGPRS gprsContextConfig;
       
    67 	TESTL(gprsContextConfig.ExtensionId()==TPacketDataConfigBase::KConfigGPRS);
       
    68 	TPckg<RPacketContext::TContextConfigGPRS> contextConfigPckgGPRS(gprsContextConfig);
       
    69 	gprsContextConfig.iAccessPointName = DPCKTTSY_ACCESS_POINT1;
       
    70 	gprsContextConfig.iAnonymousAccessReqd = DPCKTTSY_ANONYMOUS_ACCESS1;
       
    71 	gprsContextConfig.iPdpAddress = DPCKTTSY_PDP_ADDRESS1;
       
    72 	gprsContextConfig.iPdpCompression = DPCKTTSY_COMPRESSION1;
       
    73 	gprsContextConfig.iPdpType = DPCKTTSY_PDP_TYPE1;
       
    74 	gprsContextConfig.iUseEdge = ETrue;
       
    75 	gprsContextConfig.iProtocolConfigOption.iAuthInfo.iProtocol = SIM_PACKET_CONTEXT_PROTOCOL1;
       
    76 	gprsContextConfig.iProtocolConfigOption.iAuthInfo.iUsername = SIM_PACKET_CONTEXT_USERNAME1;
       
    77 	gprsContextConfig.iProtocolConfigOption.iAuthInfo.iPassword = SIM_PACKET_CONTEXT_PASSWORD1;
       
    78 	gprsContextConfig.iProtocolConfigOption.iChallenge = SIM_PACKET_CONTEXT_CHALLENGE1;
       
    79 	gprsContextConfig.iProtocolConfigOption.iResponse = SIM_PACKET_CONTEXT_RESPONSE1;
       
    80 	gprsContextConfig.iProtocolConfigOption.iDnsAddresses.iPrimaryDns = SIM_PACKET_CONTEXT_PRIMARYSERVER1;
       
    81 	gprsContextConfig.iProtocolConfigOption.iDnsAddresses.iSecondaryDns = SIM_PACKET_CONTEXT_SECONDARYSERVER1;
       
    82 	gprsContextConfig.iProtocolConfigOption.iId = SIM_PACKET_CONTEXT_ID1;
       
    83 
       
    84 		//set up notification package objects (only on heap to avoid chkstk problems)
       
    85 
       
    86 	//first gprs notify object
       
    87 	RPacketContext::TContextConfigGPRS* gprsContextNotify = new(ELeave) RPacketContext::TContextConfigGPRS;
       
    88 	CleanupStack::PushL(gprsContextNotify);
       
    89 	TESTL(gprsContextNotify->ExtensionId()==TPacketDataConfigBase::KConfigGPRS);
       
    90 	TPckg<RPacketContext::TContextConfigGPRS> contextNotifyPckgGPRS(*gprsContextNotify);
       
    91 	//second gprs notify object 
       
    92 	RPacketContext::TContextConfigGPRS* gprsContextNotify2 = new(ELeave) RPacketContext::TContextConfigGPRS;
       
    93 	CleanupStack::PushL(gprsContextNotify2);
       
    94 	TESTL(gprsContextNotify2->ExtensionId()==TPacketDataConfigBase::KConfigGPRS);
       
    95 	TPckg<RPacketContext::TContextConfigGPRS> contextNotifyPckgGPRS2(*gprsContextNotify2);
       
    96 	
       
    97 	// Test
       
    98 
       
    99 	iGPRSPacketContext.NotifyConfigChanged(gprsNotifyStatus, contextNotifyPckgGPRS);
       
   100 	GPRSPacketContext2.NotifyConfigChanged(gprsNotifyStatus2, contextNotifyPckgGPRS2);
       
   101 	iGPRSPacketContext.SetConfig(gprsReqStatus, contextConfigPckgGPRS);
       
   102 	
       
   103 
       
   104 	User::WaitForRequest(gprsNotifyStatus);
       
   105 	User::WaitForRequest(gprsNotifyStatus2);
       
   106 	
       
   107 
       
   108 	User::WaitForRequest(gprsReqStatus);
       
   109 	
       
   110 
       
   111 	//Check notify packages have correct parameters
       
   112 
       
   113 	
       
   114 	//1st gprs object
       
   115 	TESTL(gprsContextNotify->iAccessPointName==DPCKTTSY_ACCESS_POINT1);
       
   116 	TESTL(gprsContextNotify->iAnonymousAccessReqd==DPCKTTSY_ANONYMOUS_ACCESS1);
       
   117 	TESTL(gprsContextNotify->iPdpAddress==DPCKTTSY_PDP_ADDRESS1);
       
   118 	TESTL(gprsContextNotify->iPdpCompression==DPCKTTSY_COMPRESSION1);
       
   119 	TESTL(gprsContextNotify->iPdpType==DPCKTTSY_PDP_TYPE1);
       
   120 
       
   121 	//2nd gprs object
       
   122 	TESTL(gprsContextNotify2->iAccessPointName==DPCKTTSY_ACCESS_POINT1);
       
   123 	TESTL(gprsContextNotify2->iAnonymousAccessReqd==DPCKTTSY_ANONYMOUS_ACCESS1);
       
   124 	TESTL(gprsContextNotify2->iPdpAddress==DPCKTTSY_PDP_ADDRESS1);
       
   125 	TESTL(gprsContextNotify2->iPdpCompression==DPCKTTSY_COMPRESSION1);
       
   126 	TESTL(gprsContextNotify2->iPdpType==DPCKTTSY_PDP_TYPE1);
       
   127 
       
   128 	CleanupStack::PopAndDestroy(2); 
       
   129 	
       
   130 	// Close
       
   131 	GPRSPacketContext2.Close();
       
   132 	iGPRSPacketContext.Close();
       
   133 	iGPRSPacketService.Close();
       
   134 	iPhone.Close();
       
   135 	ASSERT(RThread().RequestCount()==0);
       
   136 
       
   137 	return TestStepResult();
       
   138 	}
       
   139