messagingfw/suplsmshandler/test/testserver/src/Te_LbsSuplSmsTriggerServer.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2007-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 test server for all LbsSuplSmsTrigger unit tests.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalComponent
       
    21  @prototype
       
    22 */
       
    23 #include <lbs/lbsadmin.h>
       
    24 
       
    25 #include "lbssystemcontroller.h"
       
    26 
       
    27 #include "Te_LbsSuplSmsTriggerServer.h"
       
    28 #include "Te_LbsSuplSmsTriggerIntegStep.h"
       
    29 
       
    30 /** The UID of the SUPL Sms Trigger unit test suite dll*/
       
    31 const TUid  KLbsSuplPushSuiteUid = {0x10283755};
       
    32 
       
    33 /** The string name of the test suite */
       
    34 _LIT(KServerName,"Te_LbsSuplSmsTriggerSuite");
       
    35 
       
    36 /**
       
    37 Static factory method for creating an instance of the CTe_LbsSuplSmsTriggerSuite class.
       
    38 
       
    39 @return An instance of the class. The calling application becomes the
       
    40 owner of the returned instance and is responsible its disposal.
       
    41 
       
    42 @leave If a error happens, it leaves with one of the system error codes.
       
    43 */
       
    44 CTe_LbsSuplSmsTriggerSuite* CTe_LbsSuplSmsTriggerSuite::NewL()
       
    45 	{
       
    46 	CTe_LbsSuplSmsTriggerSuite* server = new (ELeave) CTe_LbsSuplSmsTriggerSuite();
       
    47 	CleanupStack::PushL(server);
       
    48 	server->ConstructL();
       
    49 	CleanupStack::Pop(server);
       
    50 	return server;
       
    51 	}
       
    52 
       
    53 
       
    54 /**
       
    55 2nd phase constructor. Calls the base class method passing the name of the suite.
       
    56 
       
    57 @leave If a error happens, it leaves with one of the system error codes.
       
    58 */
       
    59 void CTe_LbsSuplSmsTriggerSuite::ConstructL()
       
    60 	{
       
    61 	//ConstructL of the base class
       
    62 	CTestServer::ConstructL(KServerName);
       
    63 	
       
    64 	CLbsAdmin* adminApi = CLbsAdmin::NewL();
       
    65 	CleanupStack::PushL(adminApi);
       
    66 	User::LeaveIfError(adminApi->Set(KLbsSettingLogger, CLbsAdmin::ELoggerOff));
       
    67 	CleanupStack::PopAndDestroy();
       
    68 	
       
    69 	//We start LBS system here to define the P&S properties  
       
    70 	RLbsSystemController lbsSysController;
       
    71 	lbsSysController.OpenL(KLbsSuplPushSuiteUid);
       
    72 	CleanupClosePushL(lbsSysController);
       
    73 		
       
    74 	//Start the LBS sub-system if it is not running
       
    75 	if(lbsSysController.RequestSystemStartup()!= ELbsStartupSuccess)
       
    76 		{
       
    77 		User::Leave(KErrNotReady);
       
    78 		}
       
    79 	//We do not need Lbs to be running - not to interfere with our tests
       
    80 	User::LeaveIfError(lbsSysController.RequestCompleteCloseDown());
       
    81 		
       
    82 	CleanupStack::PopAndDestroy(&lbsSysController);	
       
    83 	}
       
    84 
       
    85 
       
    86 /**
       
    87 Secure variant. Much simpler, uses the new Rendezvous() call to sync with the client.
       
    88 
       
    89 @leave If a error happens, it leaves with one of the system error codes.
       
    90 */
       
    91 LOCAL_C void MainL()
       
    92 	{
       
    93 	// Leave the hooks in for platform security
       
    94 #if (defined __DATA_CAGING__)
       
    95 	RProcess().DataCaging(RProcess::EDataCagingOn);
       
    96 	RProcess().DataCaging(RProcess::ESecureApiOn);
       
    97 #endif
       
    98 	CActiveScheduler* sched=NULL;
       
    99 	sched=new(ELeave) CActiveScheduler;
       
   100 	CActiveScheduler::Install(sched);
       
   101 	
       
   102 	CTe_LbsSuplSmsTriggerSuite* server = NULL;
       
   103 	// Create the CTestServer derived server
       
   104 	TRAPD(err,server = CTe_LbsSuplSmsTriggerSuite::NewL());
       
   105 	if(!err)
       
   106 		{
       
   107 		// Sync with the client and enter the active scheduler
       
   108 		RProcess::Rendezvous(KErrNone);
       
   109 		sched->Start();
       
   110 		}
       
   111 	
       
   112 	delete server;
       
   113 	delete sched;
       
   114 	}
       
   115 
       
   116 
       
   117 /**
       
   118 Secure variant only. Process entry point. Called by client using RProcess API.
       
   119  
       
   120 @return - Standard Epoc error code on process exit.
       
   121 */
       
   122 GLDEF_C TInt E32Main()
       
   123 	{
       
   124 	__UHEAP_MARK;
       
   125 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   126 	if(cleanup == NULL)
       
   127 		{
       
   128 		return KErrNoMemory;
       
   129 		}
       
   130 	TRAPD(err,MainL());
       
   131 	delete cleanup;
       
   132 	__UHEAP_MARKEND;
       
   133 	return err;
       
   134     }
       
   135 
       
   136 /**
       
   137 Overrides the pure virtual CTestServer::CreateTestStep. Creates a test step by its name.
       
   138 
       
   139 @return - A CTestStep derived instance or NULL if error or there is no a test step with the name
       
   140 specified.
       
   141 
       
   142 @see CTestServer::CreateTestStep
       
   143 */
       
   144 CTestStep* CTe_LbsSuplSmsTriggerSuite::CreateTestStep(const TDesC& aStepName)
       
   145 	{
       
   146 	CTestStep* step = NULL;
       
   147 	TRAPD(err, step = CreateTestStepL(aStepName));
       
   148 	if(err!=KErrNone)
       
   149 		{
       
   150 		return NULL;
       
   151 		}
       
   152 	return step;
       
   153 	}
       
   154 
       
   155 /**
       
   156 The leaving version of the CTe_LbsSuplSmsTriggerSuiteCreateTestStep. The leaving new operator is used 
       
   157 to initialize the test step object with zeroes.
       
   158 
       
   159 @return - A CTestStep derived instance or NULL if error or there is no a test step with the name
       
   160 specified.
       
   161 
       
   162 @leave KErrNoMemory if not enough memory to create the test step.
       
   163 
       
   164 @see CTe_LbsSuplSmsTriggerSuite::CreateTestStep
       
   165 */
       
   166 CTestStep* CTe_LbsSuplSmsTriggerSuite::CreateTestStepL(const TDesC& aStepName)
       
   167 	{
       
   168 	if(aStepName==KLbsSuplSmsTriggerIntegStep)
       
   169     	{
       
   170     	return new(ELeave) CTe_LbsSuplSmsTriggerIntegStep();
       
   171     	}
       
   172 	return NULL;
       
   173 	}