networkprotocolmodules/suplprotocolmodule/SuplProtocol/test/src/molr26Step.cpp
changeset 0 9cfd9a3ee49c
equal deleted inserted replaced
-1:000000000000 0:9cfd9a3ee49c
       
     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 // Example CTestStep derived implementation
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file molr26Step.cpp
       
    20  @internalTechnology
       
    21 */
       
    22 #include "molr26Step.h"
       
    23 #include "te_suplprotocolsuitedefs.h"
       
    24 #include <lbs/lbshostsettings.h>
       
    25 #include <centralrepository.h>
       
    26 
       
    27 Cmolr26Step::~Cmolr26Step()
       
    28 	{
       
    29 	}
       
    30 
       
    31 Cmolr26Step::Cmolr26Step()
       
    32 	{
       
    33 	SetTestStepName(Kmolr26Step);
       
    34 	}
       
    35 
       
    36 /**
       
    37  * @return - TVerdict code
       
    38  * Override of base class virtual
       
    39  */
       
    40 TVerdict Cmolr26Step::doTestStepPreambleL()
       
    41 
       
    42 	{
       
    43 	 
       
    44 	// Call base class method for pre test actions	
       
    45 	CTe_suplprotocolSuiteStepBase::doTestStepPreambleL();
       
    46  
       
    47 	TLbsNetProtocolModuleParams param(*iGatewayObserver);
       
    48 	iModule = CSuplGatewayInterface::NewL(reinterpret_cast<TAny*>(&param));
       
    49  
       
    50 	return TestStepResult();
       
    51 	}
       
    52 
       
    53 /** Perform CMoLrStep1 test step.
       
    54 This test verifies that the SUPL Protocol Module correctly handles 
       
    55 an Cell-Based MO-LR Self Locate sequence .
       
    56 
       
    57 @return TVerdict test result code
       
    58 */
       
    59 TVerdict Cmolr26Step::doTestStepL()
       
    60 	{
       
    61 	
       
    62 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    63 	INFO_PRINTF1(_L("\tMOLR host selection - preferred host selected"));
       
    64 	INFO_PRINTF1(_L("\t********************************************************************"));
       
    65 	INFO_PRINTF1(_L("- START -"));
       
    66 
       
    67  	//Clear the repository that keeps the host settings
       
    68 	CRepository* rep = CRepository::NewL(KLbsHostSettingsSuplStoreId);
       
    69 	CleanupStack::PushL(rep);
       
    70 	User::LeaveIfError(rep->Reset());
       
    71 	CleanupStack::PopAndDestroy(rep);
       
    72 
       
    73 	CLbsHostSettingsStore* slpSettingsStore = CLbsHostSettingsStore::NewL(KLbsHostSettingsSuplStoreId);
       
    74 	CleanupStack::PushL(slpSettingsStore);
       
    75 	
       
    76 	// Create a "network-provisioned" entry which is not the default host
       
    77 	INFO_PRINTF1(_L("[Network-provisioned host created]"));
       
    78 	TLbsHostSettingsSupl networkSettings;
       
    79 	TLbsHostNameAddress netHostAddr((TText8*)"supl.provider.com");
       
    80 	TLbsHostName netHostName((TText8*)"netSuplServer");
       
    81 	TLbsProviderId netHostProvider ((TText8*)"provider");
       
    82 	TLbsHostSettingsId netSettingsId;
       
    83 	networkSettings.SetHostNameAddress(netHostAddr);
       
    84 	networkSettings.SetName(netHostName);
       
    85 	networkSettings.SetProviderId(netHostProvider);
       
    86 	networkSettings.SetPortId(KLbsSuplUseDefaultPortId);
       
    87 	networkSettings.SetConnectionPoint(1,TLbsHostSettingsSupl::ELbsConnectionTypeNap);
       
    88 	networkSettings.SetAuthModesMOLR(TLbsHostSettingsSupl::EAuthTls);
       
    89 	networkSettings.SetAuthModesMTLR(TLbsHostSettingsSupl::EAuthTls);
       
    90 	
       
    91 	if (KErrNone != slpSettingsStore->CreateHostSettings(networkSettings, KLbsHostSettingsDevProvCreatorId, netSettingsId))
       
    92 		{
       
    93 		SetTestStepResult(EFail);
       
    94 		return TestStepResult();	
       
    95 		}
       
    96 	
       
    97 	// Create a "user-provisioned" entry which is the default host
       
    98 	INFO_PRINTF1(_L("[User-provisioned default host created]"));
       
    99 	TLbsHostSettingsSupl defaultSettings;
       
   100 	TLbsHostNameAddress defHostAddr((TText8*)"supl.thirdparty.com");
       
   101 	TLbsHostName defHostName((TText8*)"defSuplServer");
       
   102 	TLbsProviderId defHostProvider ((TText8*)"provider");
       
   103 	TLbsHostSettingsId defSettingsId; 
       
   104 	defaultSettings.SetHostNameAddress(defHostAddr);
       
   105 	defaultSettings.SetName(defHostName);
       
   106 	defaultSettings.SetProviderId(defHostProvider);
       
   107 	defaultSettings.SetPortId(KLbsSuplUseDefaultPortId);
       
   108 	TLbsHostCreatorId KTestMadeUpUid = {0x101010};
       
   109 	defaultSettings.SetConnectionPoint(1,TLbsHostSettingsSupl::ELbsConnectionTypeNap);
       
   110 	defaultSettings.SetAuthModesMOLR(TLbsHostSettingsSupl::EAuthTls);
       
   111 	defaultSettings.SetAuthModesMTLR(TLbsHostSettingsSupl::EAuthTls);
       
   112 
       
   113 	if (KErrNone != slpSettingsStore->CreateHostSettings(defaultSettings, KTestMadeUpUid, defSettingsId))
       
   114 		{
       
   115 		SetTestStepResult(EFail);
       
   116 		return TestStepResult();					
       
   117 		}
       
   118 		
       
   119 	if (KErrNone != slpSettingsStore->SetDefaultHostSettings(defSettingsId))
       
   120 		{
       
   121 		SetTestStepResult(EFail);
       
   122 		return TestStepResult();					
       
   123 		}
       
   124 	
       
   125 	
       
   126 	// Initiate MO-LR
       
   127 	INFO_PRINTF1(_L("\tLBS -> RequestNetworkLocation"));
       
   128 	TLbsNetSessionId sessionId1(TUid::Uid(0x12345678), 0x1111);
       
   129 	TLbsNetPosRequestOptions options1;
       
   130 	options1.SetNewClientConnected(ETrue);
       
   131 	TLbsNetPosRequestQuality quality1;
       
   132 	options1.SetRequestQuality(quality1);
       
   133 	iModule->RequestNetworkLocation(sessionId1, options1);
       
   134 
       
   135     // Check Connection Manager receives a request for connecting to the 
       
   136     // host whose settings Id is defSettingsId
       
   137 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EConnectReq) ||
       
   138 		defSettingsId != iNetworkObserver->HostSettingsId())
       
   139 		{
       
   140 		SetTestStepResult(EFail);
       
   141 		return TestStepResult();
       
   142 		}
       
   143 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t ConnectionRequest -> NET"));
       
   144 
       
   145 	// Simulate the connection is up (inject that event)
       
   146 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t Connected <- NET"));
       
   147     iNetworkObserver->InjectConnectedIndication(iNetworkObserver->SessionId());
       
   148 	
       
   149 	// Check Connection Manager receives a request to send a SUPL START
       
   150 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::ESuplStartSendReq))
       
   151 	{
       
   152 	SetTestStepResult(EFail);
       
   153 	return TestStepResult();
       
   154 	}
       
   155 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL START -> NET"));
       
   156 	
       
   157 	// Inject a SUPL END (with position)
       
   158 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t SUPL END <- NET"));
       
   159 	CSuplMessageBase* suplEnd = BuildSuplEndL(ETrue);
       
   160 	iNetworkObserver->InjectSuplMessage(iNetworkObserver->SessionId(), suplEnd);
       
   161 
       
   162 	// Check gateway receives Location Update
       
   163 	INFO_PRINTF1(_L("\tLBS <- ProcessLocationUpdate()"));
       
   164 	if (EFail == CheckGatewayCallbackL(
       
   165 				CSuplGatewayObserver::EProcessLocationUpdate))
       
   166 		{
       
   167 		SetTestStepResult(EFail);
       
   168 		return TestStepResult();
       
   169 		}
       
   170 
       
   171 	// Check gateway receives a session complete indication
       
   172 	if (EFail == CheckGatewayCallbackL(
       
   173 				CSuplGatewayObserver::EProcessSessionComplete))
       
   174 		{
       
   175 		SetTestStepResult(EFail);
       
   176 		return TestStepResult();
       
   177 		}
       
   178 	INFO_PRINTF1(_L("\tLBS <- ProcessSessionComplete"));
       
   179 
       
   180 	// Check Connection Manager receives a disconnection request
       
   181 	if (EFail == CheckNetworkCallbackL(CSuplNetworkTestObserver::EDisconnectReq))
       
   182 		{
       
   183 		SetTestStepResult(EFail);
       
   184 		return TestStepResult();
       
   185 		}
       
   186 	INFO_PRINTF1(_L("\t\t\t\t\t\t\t\t DisconnectRequest -> NET"));
       
   187 	
       
   188 	// Check if more observer activity takes place
       
   189 	if (iGatewayObserver->IsMoreObserverActivity() ||
       
   190 	iNetworkObserver->IsMoreObserverActivity())
       
   191 	{
       
   192 	SetTestStepResult(EFail);
       
   193 	return TestStepResult();
       
   194 	}
       
   195 	
       
   196 	// Delete the entries in the SUPL HostSettings store created by this test
       
   197 	slpSettingsStore->DeleteHostSettings(netSettingsId);
       
   198 	slpSettingsStore->DeleteHostSettings(defSettingsId);
       
   199 	
       
   200 	CleanupStack::PopAndDestroy(slpSettingsStore);
       
   201 	
       
   202 	INFO_PRINTF1(_L("- END -"));
       
   203 	
       
   204 	SetTestStepResult(EPass);
       
   205 	return TestStepResult();
       
   206 	}
       
   207 
       
   208 
       
   209 /**
       
   210  * @return - TVerdict code
       
   211  * Override of base class virtual
       
   212  */
       
   213 TVerdict Cmolr26Step::doTestStepPostambleL()
       
   214 	{
       
   215 	delete iModule;
       
   216 
       
   217 	// Call base class method for post test actions	
       
   218 	CTe_suplprotocolSuiteStepBase::doTestStepPostambleL();
       
   219 	return TestStepResult();
       
   220 	}