telephonyserver/etelpacketdata/Te_EtelPacket/Te_EtelPacketTestContextConnectionInfo.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2008-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 is the cpp file for Packet Data Context test Connection Information
       
    15 // 
       
    16 //
       
    17 
       
    18 // Symbian OS includes
       
    19 #include <e32base.h>
       
    20 #include <etelpckt.h>
       
    21 #include <pcktcs.h>
       
    22 
       
    23 // Test includes
       
    24 #include "Te_EtelPacketTestStepBase.h"
       
    25 #include "testdef.h"
       
    26 #include "Te_EtelPacketTestContextConnectionInfo.h"
       
    27 #include "Te_etelpckt_defs.h"
       
    28 
       
    29 // Constants
       
    30 const TInt KThousand = 1000;
       
    31 
       
    32 //Constructor
       
    33 CEtelPacketTestContextConnectionInfo::CEtelPacketTestContextConnectionInfo()
       
    34     {
       
    35 	//Store the name of this test case
       
    36 	SetTestStepName(KContextConnectionInfo);
       
    37     }
       
    38 
       
    39 //Destructor
       
    40 CEtelPacketTestContextConnectionInfo::~CEtelPacketTestContextConnectionInfo()
       
    41     {
       
    42     //None
       
    43     }
       
    44 
       
    45 
       
    46 enum TVerdict CEtelPacketTestContextConnectionInfo::doTestStepL( void )
       
    47 /**
       
    48  * Test step tests getting context connection information
       
    49  */
       
    50     {
       
    51 	RPhone phone;
       
    52 	TInt ret=phone.Open(iTelServer,DPCKTTSY_PHONE_NAME);
       
    53 	CHECKPOINT(ret,KErrNone,CHP_OPEN_PHONE);
       
    54 	CleanupClosePushL(phone);
       
    55 
       
    56 	RPacketService packetService;
       
    57 	ret=packetService.Open(phone);
       
    58 	CHECKPOINT(ret,KErrNone,_L("Failed to open packet service"));
       
    59 	CleanupClosePushL(packetService);
       
    60 
       
    61 	RPacketContext packetContext;
       
    62 	TName contextName;
       
    63 	ret=packetContext.OpenNewContext(packetService, contextName);
       
    64 	CHECKPOINT(ret,KErrNone,_L("Failed to open packet context"));
       
    65 	CleanupClosePushL(packetContext);
       
    66 
       
    67 	TRequestStatus reqStatus; 
       
    68 	TUint32 validData = RPacketContext::KHSDPACategory | RPacketContext::KHSUPACategory;
       
    69     RPacketContext::TConnectionInfoV1 connectionInfoV1;
       
    70     
       
    71     //Initialize connectionInfoV1
       
    72     connectionInfoV1.iValid = 0;
       
    73     connectionInfoV1.iHSDPACategory = 0;
       
    74     connectionInfoV1.iHSUPACategory = 0;
       
    75     
       
    76     TPckg<RPacketContext::TConnectionInfoV1> pckgConnectionInfoV1(connectionInfoV1); 
       
    77 
       
    78 	//Test GetConnectionInfo
       
    79 	packetContext.GetConnectionInfo(reqStatus, pckgConnectionInfoV1);
       
    80 	User::WaitForRequest(reqStatus);
       
    81 	TEST(reqStatus.Int()                        ==KErrNone);
       
    82 	TEST(TConnectionInfoBase::KConnectionInfoV1 ==connectionInfoV1.ExtensionId());
       
    83 	TEST(validData                              ==connectionInfoV1.iValid);	
       
    84 	TEST(DPCKTTSY_HSDPA_CATEGORY                ==connectionInfoV1.iHSDPACategory);
       
    85 	TEST(DPCKTTSY_HSUPA_CATEGORY                ==connectionInfoV1.iHSUPACategory);
       
    86 	INFO_PRINTF1(_L("GetConnectionInfo Test Passed"));
       
    87 
       
    88     //Test cancel GetConnectionInfo
       
    89 	packetContext.GetConnectionInfo(reqStatus, pckgConnectionInfoV1);
       
    90 	User::After(KThousand);
       
    91 	packetContext.CancelAsyncRequest(EPacketContextGetConnectionInfo);	
       
    92 	User::WaitForRequest(reqStatus);
       
    93 	TEST(reqStatus.Int()==KErrCancel);
       
    94 	INFO_PRINTF1(_L("GetConnectionInfo Cancel Test Passed"));
       
    95 
       
    96     //Reset connectionInfoV1 data before continue testing
       
    97     connectionInfoV1.iValid = 0;
       
    98     connectionInfoV1.iHSDPACategory = 0;
       
    99     connectionInfoV1.iHSUPACategory = 0;
       
   100 
       
   101 	//Test NotifyConnectionInfoChange
       
   102 	packetContext.NotifyConnectionInfoChange(reqStatus, pckgConnectionInfoV1);
       
   103 	User::WaitForRequest(reqStatus);
       
   104 	TEST(reqStatus.Int()                        ==KErrNone);
       
   105 	TEST(TConnectionInfoBase::KConnectionInfoV1 ==connectionInfoV1.ExtensionId());
       
   106 	TEST(validData                              ==connectionInfoV1.iValid);	
       
   107 	TEST(DPCKTTSY_HSDPA_CATEGORY                ==connectionInfoV1.iHSDPACategory);
       
   108 	TEST(DPCKTTSY_HSUPA_CATEGORY                ==connectionInfoV1.iHSUPACategory);
       
   109 	INFO_PRINTF1(_L("NotifyConnectionInfoChange Test Passed"));
       
   110 
       
   111     //Test cancel NotifyConnectionInfoChange
       
   112 	packetContext.NotifyConnectionInfoChange(reqStatus, pckgConnectionInfoV1);
       
   113 	User::After(KThousand);
       
   114 	packetContext.CancelAsyncRequest(EPacketContextNotifyConnectionInfoChange);	
       
   115 	User::WaitForRequest(reqStatus);
       
   116 	TEST(reqStatus.Int()==KErrCancel);
       
   117 	INFO_PRINTF1(_L("NotifyConnectionInfoChange Cancel Test Passed"));
       
   118 
       
   119     //Close handles    
       
   120 	CleanupStack::PopAndDestroy(3); //packetContext, packetService, phone
       
   121 
       
   122 	return TestStepResult();
       
   123     }
       
   124