telephonyutils/telephonywatchers/Test/TE_TelWatchers/TE_TelWatchersUnitServer.cpp
changeset 0 3553901f7fa8
child 24 6638e7f4bd8f
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 2004-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 // Telephony Watchers Unit Test server test code.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20 */
       
    21 
       
    22 #include "TE_TelWatchersUnitServer.h"
       
    23 #include "TE_TelWatchersUnitTest.h"
       
    24 
       
    25 
       
    26 _LIT(KServerName,"TE_TelWatchersUnit");
       
    27 
       
    28 
       
    29 /**
       
    30  *  Called inside the MainL() function to create and start the CTestServer
       
    31  *  derived server.
       
    32  *
       
    33  *  @return Instance of the test server
       
    34  */
       
    35 CTelWatchersUnitTestServer* CTelWatchersUnitTestServer::NewL()
       
    36 	{
       
    37 	CTelWatchersUnitTestServer*  server = new(ELeave) CTelWatchersUnitTestServer();
       
    38 	CleanupStack::PushL(server);
       
    39 	// CServer base class call
       
    40 	server->StartL(KServerName);
       
    41 	CleanupStack::Pop(server);
       
    42 	return server;
       
    43 	} // CTelWatchersUnitTestServer::NewL
       
    44 
       
    45 
       
    46 /**
       
    47  *  Much simpler, uses the new Rendezvous() call to sync with the client.
       
    48  */
       
    49 LOCAL_C void MainL()
       
    50 	{
       
    51 	//
       
    52 	// Start an active scheduler...
       
    53 	//
       
    54 	CActiveScheduler* scheduler = new(ELeave) CActiveScheduler;
       
    55 	CleanupStack::PushL(scheduler);
       
    56 	CActiveScheduler::Install(scheduler);
       
    57 
       
    58 	//
       
    59 	// Create the CTestServer derived server...
       
    60 	//
       
    61 	CTelWatchersUnitTestServer* server = NULL;
       
    62 
       
    63 	TRAPD(err, server = CTelWatchersUnitTestServer::NewL());
       
    64 	if (err == KErrNone)
       
    65 		{
       
    66 		//
       
    67 		// Sync with the client and enter the active scheduler
       
    68 		//
       
    69 		RProcess::Rendezvous(KErrNone);
       
    70 		scheduler->Start();
       
    71 		}
       
    72 
       
    73 	//
       
    74 	// Clean up...
       
    75 	//
       
    76 	CleanupStack::Pop(scheduler);
       
    77 	delete server;
       
    78 	delete scheduler;
       
    79 	} // MainL
       
    80 /**
       
    81  *  @return Standard Epoc error code on exit.
       
    82  */
       
    83 GLDEF_C TInt E32Main()
       
    84 	{
       
    85 	CTrapCleanup*  cleanup = CTrapCleanup::New();
       
    86 
       
    87 	if (cleanup == NULL)
       
    88 		{
       
    89 		return KErrNoMemory;
       
    90 		}
       
    91 
       
    92 	TRAP_IGNORE(MainL());
       
    93 
       
    94 	delete cleanup;
       
    95 
       
    96 	return KErrNone;
       
    97 	} // E32Main
       
    98 
       
    99 
       
   100 /**
       
   101  *  Implementation of CTestServer pure virtual.
       
   102  *
       
   103  *  @return A CTestStep derived instance.
       
   104  */
       
   105 CTestStep* CTelWatchersUnitTestServer::CreateTestStep(const TDesC& aStepName)
       
   106 	{
       
   107 	CTestStep*  testStep = NULL;
       
   108 
       
   109     //
       
   110 	// Create the required test step...
       
   111 	//		
       
   112 	if (aStepName == _L("TestSimulteCommDBModemChangeWithPublishSubscribe"))
       
   113 		{
       
   114 		testStep = new(ELeave) CTelWatchersUnitTestSimulteCommDBModemChangeWithPublishSubscribe();
       
   115 		}
       
   116 		
       
   117 	if (aStepName == _L("TestCommDBChangeWhenWatcherDisabledWithPublishSubscribe"))
       
   118 		{
       
   119 		testStep = new(ELeave) CTelWatchersUnitTestCommDBChangeWhenWatcherDisabledWithPublishSubscribe();
       
   120 		}
       
   121 		
       
   122 	if (aStepName == _L("TestCallStateChangesWithPublishSubscribe"))
       
   123 		{
       
   124 		testStep = new(ELeave) CTelWatchersUnitTestCallStateChangesWithPublishSubscribe();
       
   125 		}
       
   126 		
       
   127 	if (aStepName == _L("TestBatteryChargerChangesWithPublishSubscribe"))
       
   128 		{
       
   129 		testStep = new(ELeave) CTelWatchersUnitTestBatteryChargerChangesWithPublishSubscribe();
       
   130 		}
       
   131 		
       
   132 	if (aStepName == _L("TestNetworkAvailabilityChangesWithPublishSubscribe"))
       
   133 		{
       
   134 		testStep = new(ELeave) CTelWatchersUnitTestNetworkAvailabilityChangesWithPublishSubscribe();
       
   135 		}
       
   136 
       
   137 	return testStep;
       
   138 	} // CTelWatchersUnitTestServer::CreateTestStep