telephonyserverplugins/multimodetsy/test/gprs/tmain.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1999-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 // Main test file for the automated testing
       
    15 // usage:   t_gprs --keepgoing   for automated testing 
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21 */
       
    22 
       
    23 #include "tmain.h"
       
    24 
       
    25 #include <commsdattypesv1_1.h>
       
    26 
       
    27 #include <autotest.h>
       
    28 #include <plpsess.h>        // RRemoteLink
       
    29 
       
    30 GLDEF_D RTest gTest(_L("GPRS Test Code"));
       
    31 
       
    32 GLDEF_D     RPhone          gPhone;
       
    33 GLDEF_D     RTelServer      gServer;
       
    34 //GLREF_D     RConnection		conn;
       
    35 //GLDEF_D     RGenericAgent	gGenericAgent;
       
    36 GLDEF_D     RSocketServ		gSocketServer;
       
    37 GLDEF_D		RPacketService	gPacketService;
       
    38 GLDEF_D		RPacketContext	gPacketContext[20];
       
    39 // Inifile object.
       
    40 GLDEF_D		CConfigParams* testConfigParams;
       
    41 
       
    42 GLDEF_D		TPhoneBrand GPhoneBrand;
       
    43 
       
    44 LOCAL_C void InitGlobals()
       
    45 /**
       
    46  * Initialise global variables.
       
    47  */
       
    48     {
       
    49 #ifdef __WINS__
       
    50     User::After(5*KOneSecond);      // allow emulator time to start up
       
    51 #endif
       
    52     gTest.Start(_L("Load TSY"));
       
    53     gTest(gServer.Connect()==KErrNone);
       
    54     gTest(gServer.LoadPhoneModule(KtsyName)==KErrNone);
       
    55     gTest.Next(_L("Contact the Phone"));
       
    56     // Run the tests    
       
    57   //  gTest(gPhone .Open(gServer,KPhoneName)== KErrNone);
       
    58 	gTest(gPhone.Open(gServer, KPhoneName)==KErrNone);
       
    59 	gTest(gPhone .Initialise()==KErrNone);
       
    60 
       
    61 	gTest(gSocketServer.Connect() == KErrNone);
       
    62 //	gTest(gGenericAgent.Open() == KErrNone);
       
    63 	gTest(conn.Open(gSocketServer, KAfInet) == KErrNone);
       
    64 
       
    65 	// Open the ini file with the web settings.
       
    66 	TRAPD(err,testConfigParams = CConfigParams::NewL(KTGPRSConfigFile()));
       
    67 	gTest(err == KErrNone);
       
    68 	const TPtrC phoneBrand = testConfigParams->FindAlphaVar(KTestCfgPhoneMake,KNullDesC);
       
    69 	if(phoneBrand == KTestCfgPhoneMotorola)
       
    70 		GPhoneBrand = EMotorola;
       
    71 	else if(phoneBrand == KTestCfgPhoneEricsson)
       
    72 		GPhoneBrand = EEricsson;
       
    73 	else 
       
    74 		{
       
    75     gTest.Printf(_L("There is no phone specified in ini file or the phone is not supported"));
       
    76 		User::Panic(_L("There is no phone specified in ini file or the phone is not supported."), KErrNotSupported);
       
    77 		}
       
    78 	}
       
    79 
       
    80 
       
    81 LOCAL_C void DestroyGlobals()
       
    82 /**
       
    83  * Free global variables
       
    84  */
       
    85     {
       
    86     gPhone .Close();
       
    87     gServer.Close();
       
    88 	
       
    89 //	gGenericAgent.Close();
       
    90 	conn.Close();
       
    91 	gSocketServer.Close();
       
    92 	delete testConfigParams;
       
    93 	testConfigParams = NULL;
       
    94     }
       
    95 
       
    96 
       
    97 LOCAL_C void RunTestsL()
       
    98 /**
       
    99  * Run all the tests
       
   100  */
       
   101     {
       
   102     InitGlobals();
       
   103 	AutoTestExecute();
       
   104     DestroyGlobals();
       
   105     }
       
   106 
       
   107 
       
   108 #if defined (__WINS__)
       
   109 #define PDD_NAME _L("ECDRV")
       
   110 #define PDD_NAME2 _L("ECDRV")
       
   111 #define LDD_NAME _L("ECOMM")
       
   112 #else
       
   113 #define PDD_NAME _L("EUART1")
       
   114 #define LDD_NAME _L("ECOMM")
       
   115 #endif
       
   116 
       
   117 
       
   118 int CommInit()
       
   119 /**
       
   120  * This function does the actual loading of the drivers needed.
       
   121  */
       
   122     {
       
   123     RFs fs;
       
   124     TInt err=fs.Connect();  // make sure the FileServer is alive (only needed for WINS test code)
       
   125     fs.Close();
       
   126 
       
   127     gTest.Printf(_L("CommInit: Loading PDD ") );
       
   128     gTest.Printf(PDD_NAME);
       
   129     gTest.Printf(_L("\n"));
       
   130     err=User::LoadPhysicalDevice(PDD_NAME);
       
   131     if (err!=KErrNone && err!=KErrAlreadyExists)
       
   132         return(err);
       
   133 
       
   134     gTest.Printf(_L("CommInit: Loading LDD ") );
       
   135     gTest.Printf(LDD_NAME);
       
   136     gTest.Printf(_L("\n"));
       
   137     err=User::LoadLogicalDevice(LDD_NAME );
       
   138     if (err!=KErrNone && err!=KErrAlreadyExists)
       
   139         return(err);
       
   140 
       
   141     gTest.Printf(_L("CommInit: Starting C32 \n") );
       
   142  	// When bootstrapping C32 we have to avoid the PhBkSyncServer being started, since
       
   143  	// it needs a different CommDB
       
   144  	_LIT(KPhbkSyncCMI, "phbsync.cmi");
       
   145 	err = StartC32WithCMISuppressions(KPhbkSyncCMI);
       
   146     return (err == KErrNone || err == KErrAlreadyExists) ? KErrNone : err;
       
   147     }
       
   148 
       
   149 
       
   150 TInt E32Main()
       
   151 /**
       
   152  * @test Main program tsmsmsg
       
   153  */
       
   154     {
       
   155 
       
   156     CTrapCleanup* cleanup = CTrapCleanup::New();
       
   157     CActiveScheduler* theActiveScheduler = new CActiveScheduler();
       
   158     CActiveScheduler::Install(theActiveScheduler);
       
   159 
       
   160     __UHEAP_MARK;
       
   161 
       
   162     gTest.SetLogged(EFalse);    // to avoid garbage on Com port
       
   163     gTest.Title();
       
   164     TInt ret = CommInit();
       
   165     if(ret != KErrNone)
       
   166         {
       
   167         gTest.Printf(_L("ERROR: Leave %d\n"), ret);
       
   168         }
       
   169     else
       
   170         {
       
   171         gTest.Start(_L("Starting tests..."));
       
   172         TRAPD(err,RunTestsL());
       
   173         if (err!=KErrNone)
       
   174             gTest.Printf(_L("ERROR: Leave %d\n"),err);
       
   175          
       
   176 
       
   177         }
       
   178 
       
   179     gTest.End();
       
   180     gTest.Close();
       
   181 
       
   182     __UHEAP_MARKEND;
       
   183 
       
   184     delete cleanup;
       
   185     delete theActiveScheduler;
       
   186     return KErrNone;
       
   187     }
       
   188 
       
   189 
       
   190 
       
   191 /**
       
   192  * for the EXEDLL targettype
       
   193  */
       
   194 
       
   195 EXPORT_C TInt WinsMain()
       
   196     {
       
   197 #if defined(__WINS__)
       
   198     E32Main();
       
   199 #endif
       
   200     return KErrNone;
       
   201     }
       
   202 
       
   203 
       
   204 
       
   205 // EOF - TSMMAIN.CPP
       
   206 
       
   207 
       
   208