sysstatemgmt/systemstatemgr/test/tsus/src/tsus_startadaptationserver.cpp
branchRCL_3
changeset 3 a811597961f0
equal deleted inserted replaced
0:4e1aa6a622a0 3:a811597961f0
       
     1 // Copyright (c) 2009-2010 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:Test Adaptation server 
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal test code 
       
    20 */
       
    21 
       
    22 #include <e32base.h>
       
    23 #include "tsus_startadaptationserver.h"
       
    24 #include "susadaptionserver.h"
       
    25 #include "ssmdebug.h"
       
    26 
       
    27 
       
    28 
       
    29 ////////////////////////////////////////////////////////////////////////////////
       
    30 // Test-Server startup code
       
    31 ////////////////////////////////////////////////////////////////////////////////
       
    32 
       
    33 void RunAdaptationTestSrvL()
       
    34 	{
       
    35 	__UHEAP_MARK;
       
    36 	CActiveScheduler* sched = new(ELeave) CActiveScheduler();
       
    37     CleanupStack::PushL( sched );
       
    38     CActiveScheduler::Install( sched );
       
    39 
       
    40     CSsmAdaptationServer* server = CSsmAdaptationServer::NewLC(KTestAdaptationServerName);
       
    41     RThread::Rendezvous( KErrNone );
       
    42     
       
    43     CActiveScheduler::Start();
       
    44 
       
    45     CleanupStack::PopAndDestroy( server );
       
    46     CleanupStack::PopAndDestroy( sched );
       
    47     __UHEAP_MARKEND;
       
    48 	} //lint !e1746 Suppress parameter 'aSid' could be made const reference
       
    49 
       
    50 /**
       
    51  This function is called when the TestServer's thread is resumed.
       
    52  */
       
    53 TInt TestAdaptationSrvInitFunction(TAny* /*aNothing*/)
       
    54 	{
       
    55     CTrapCleanup* cleanup=CTrapCleanup::New();
       
    56 	TInt err = KErrNoMemory;
       
    57 	if (cleanup)
       
    58 		{
       
    59 	    TRAP( err, RunAdaptationTestSrvL());
       
    60 	    delete cleanup;
       
    61 		}
       
    62     return err;
       
    63 	}
       
    64 
       
    65 /**
       
    66  */
       
    67 TInt StartAdaptationServer(RThread& aServer)
       
    68 	{
       
    69 	DEBUGPRINT2( _L("Starting test-server %S"), &KTestAdaptationServerName );
       
    70 	
       
    71 	const TInt KMinHeapSize =  0x1000; // 4kB
       
    72 	const TInt KMaxHeapSize = 0x100000;// 1MB
       
    73 	
       
    74 	
       
    75 	TInt err = aServer.Create( KTestAdaptationServerName, &TestAdaptationSrvInitFunction, 
       
    76 	                                 KDefaultStackSize, KMinHeapSize, KMaxHeapSize, 
       
    77 	                                 NULL);
       
    78 	if( KErrNone == err )
       
    79 		{
       
    80 		TRequestStatus trs;
       
    81 		aServer.Rendezvous( trs );
       
    82 		aServer.Resume();
       
    83 		
       
    84 		User::WaitForRequest( trs );	
       
    85 		
       
    86 		//We can't use the 'exit reason' if the server panicked as this is the 
       
    87 		//panic 'reason' and may be '0' which cannot be distinguished from KErrNone
       
    88 		err = (aServer.ExitType()==EExitPanic) ? KErrGeneral : trs.Int();
       
    89 		}
       
    90 
       
    91 	return err;
       
    92 	}