telephonyserverplugins/multimodetsy/test/Te_LoopBack/Te_LoopBackCUnsolicited.cpp
changeset 0 3553901f7fa8
equal deleted inserted replaced
-1:000000000000 0:3553901f7fa8
       
     1 // Copyright (c) 1997-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 file initiates the "Unsolicited Message" test
       
    15 // The client (application) side must start the emulator and drive the ETel API.
       
    16 // The emulator side runs the designated script.
       
    17 // 
       
    18 //
       
    19 
       
    20 /**
       
    21  @file
       
    22  @note  There are mulitple classes implemented in this file.
       
    23  @note  These classes are CTestDriveUnsolicited and CTestUnsolicited.
       
    24 */
       
    25 
       
    26 
       
    27 #include <e32test.h>
       
    28 #include "Te_LoopBackSLOGGER.H"
       
    29 #include "Te_LoopBackCUnsolicited.h"
       
    30 #include "../../hayes/TSYCONFG.H" // for KInternetAccessPoint
       
    31 
       
    32 _LIT(KMmPhoneName,"GsmPhone1");
       
    33  
       
    34 
       
    35 //
       
    36 // Test-side class
       
    37 // With the assistance of the base class, this class must start the emulator
       
    38 // and drive the ETel API.
       
    39 //
       
    40 CTestDriveUnsolicited* CTestDriveUnsolicited::NewL(const TScriptList aScriptListEntry,
       
    41 															 TInt aVarDelay)
       
    42 /**
       
    43  * 2 Phase Constructor
       
    44  *
       
    45  * This method creates an instance of CTestDriveUnsolicited.  The ConstructL for
       
    46  * for CTestDriveUnsolicited is inherited from and implemented in CTestBase. The
       
    47  * ConstructL uses the CTestDriveUnsolicited object to load ond open the two iPhone
       
    48  * objects, one from each server.
       
    49  *
       
    50  * @param aScriptListEntry: enum indicating which script to use for this test.
       
    51  * @param aVarDelay: integer indicating variable delay value, in seconds, to be used with an EWait script
       
    52  * @leave Leaves if a failure occurs during connect or open of the iPhone by ConstructL.
       
    53  * @return pointer to the instance of CTestDriveUnsolicited.
       
    54  */
       
    55 	{
       
    56 	CTestDriveUnsolicited* aA=new(ELeave) CTestDriveUnsolicited(aScriptListEntry, aVarDelay);
       
    57 	CleanupStack::PushL(aA);
       
    58 	aA->ConstructL();
       
    59 	CleanupStack::Pop();
       
    60 	return aA;
       
    61 	}
       
    62 
       
    63 
       
    64 CTestDriveUnsolicited::CTestDriveUnsolicited(const TScriptList aScriptListEntry,
       
    65 													   TInt aVarDelay
       
    66 													  ) : iScriptListEntry(aScriptListEntry),
       
    67 													      iVarDelay(aVarDelay)
       
    68 /**
       
    69  * This method is the constructor for CTestDriveUnsolicited.
       
    70  *
       
    71  * @param aScriptListEntry: enum indicating which script to use for this test.
       
    72  * @param aVarDelay: integer indicating variable delay value, in seconds, to be used with an EWait script
       
    73  * @note Initializes private data "aScriptListEntry" to received parameter.
       
    74  * @note Initializes private data "aVarDelay" to received parameter.
       
    75  */
       
    76 	{}
       
    77 
       
    78 TInt CTestDriveUnsolicited::RunTestL()
       
    79 /**
       
    80  * This method is invoked to start a "Data Call answer and remote hang-up closely followed by
       
    81  * a dial" test.  This method sets the CTestBase current script to run and the CTestBase variable
       
    82  * delay value to use for an EWait
       
    83  * script and then starts the modem emulator side of the test.
       
    84  *
       
    85  * @return KErrNone when no error exists.
       
    86  * @return KErrAlreadyExists is returned if modem emulator exists and retry limit expires.
       
    87  * @return Variable depending on return value from test's DriveETelApi method and thread monitoring.
       
    88  */
       
    89 	{
       
    90 	iCurrentScript=iScriptListEntry;
       
    91 	iVariableDelay=iVarDelay;
       
    92 	return StartEmulatorL();
       
    93 	}
       
    94 
       
    95 TInt CTestDriveUnsolicited::DriveETelApiL()
       
    96 /**
       
    97  * This method contains the real meat of the 
       
    98  *
       
    99  * @return KErrNone.
       
   100  */
       
   101 	{
       
   102 	INFO_PRINTF1(_L("Bludgeoning Initialisation with Unsolicited Messages\n"));
       
   103 	TRAP_IGNORE(DriveTestL()) ; 
       
   104 	return KErrNone;
       
   105 	}
       
   106 
       
   107 void CTestDriveUnsolicited::DriveTestL()
       
   108 	{
       
   109 	// Open iPhone
       
   110 	TESTL(iPhone3.Open(iServer,KMmPhoneName) == KErrNone);
       
   111 
       
   112 	TRequestStatus reqStatus;
       
   113 	RMobilePhone::TMMTableSettings tableSettings;
       
   114 	tableSettings.iLocId=KInternetAccessPoint;
       
   115 	RMobilePhone::TMMTableSettingsPckg tableSettingsPckg(tableSettings);
       
   116 	iPhone3.InitialiseMM(reqStatus, tableSettingsPckg); 	
       
   117 	User::WaitForRequest(reqStatus);
       
   118 	TESTL(reqStatus == KErrNone);
       
   119 
       
   120 //	test.Printf(_L("Attempting to force TSY into EPhoneNotInitialised state\n"));
       
   121 //	TRequestStatus status(KErrNone);
       
   122 //	RMobilePhone::TMobilePhoneNetworkInfoV1 networkInfo;
       
   123 //	TPckg<RMobilePhone::TMobilePhoneNetworkInfoV1> networkInfoPckg(networkInfo);
       
   124 //	RMobilePhone::TMobilePhoneLocationAreaV1 area;
       
   125 //	iPhone3.GetCurrentNetwork(status,networkInfoPckg,area);
       
   126 //	User::WaitForRequest(status);
       
   127 //	test(status==KErrTimedOut);
       
   128 	// Close iPhone
       
   129 	iPhone3.Close();		
       
   130 	}
       
   131 
       
   132 
       
   133 //
       
   134 // Emulator-side class
       
   135 // With the assistance of the base class, this class must run the designated script
       
   136 //
       
   137 CTestUnsolicited* CTestUnsolicited::NewL(const TScript* aScript)
       
   138 /**
       
   139  * 2 Phase Constructor
       
   140  *
       
   141  * This method creates an instance of CTestUnsolicited.
       
   142  *
       
   143  * @param aScript: pointer to the specifics of the script to run.
       
   144  * @leave Leaves if out of memory when attempting to create.
       
   145  * @return pointer to the instance of CTestUnsolicited.
       
   146  */
       
   147 	{
       
   148 	CTestUnsolicited* aA=new(ELeave) CTestUnsolicited(aScript);
       
   149 	CleanupStack::PushL(aA);
       
   150 	aA->ConstructL();
       
   151 	CleanupStack::Pop();
       
   152 	return aA;
       
   153 	}
       
   154 
       
   155 CTestUnsolicited* CTestUnsolicited::NewL(const TScript* aScript, const TInt aVarDelay)
       
   156 /**
       
   157  * 2 Phase Constructor
       
   158  *
       
   159  * This method creates an instance of CTestUnsolicited.
       
   160  *
       
   161  * @param aScript: pointer to the specifics of the script to run.
       
   162  * @param aVarDelay: time delay
       
   163  * @leave Leaves if out of memory when attempting to create.
       
   164  * @return pointer to the instance of CTestUnsolicited.
       
   165  */
       
   166 	{
       
   167 	CTestUnsolicited* aA=new(ELeave) CTestUnsolicited(aScript, aVarDelay);
       
   168 	CleanupStack::PushL(aA);
       
   169 	aA->ConstructL();
       
   170 	CleanupStack::Pop();
       
   171 	return aA;
       
   172 	}
       
   173 
       
   174 CTestUnsolicited::CTestUnsolicited(const TScript* aScript) : iScript(aScript)
       
   175 /**
       
   176  * This method is the constructor for CTestUnsolicited.
       
   177  *
       
   178  * @param aScript: pointer to the specifics of the script to run.
       
   179  * @note Initializes private data "aScript" to received parameter.
       
   180  */
       
   181 	{}
       
   182 
       
   183 CTestUnsolicited::CTestUnsolicited(const TScript* aScript, const TInt aVarDelay) : CATScriptEng(aVarDelay), iScript(aScript)
       
   184 /**
       
   185  * This method is the constructor for CTestUnsolicited.
       
   186  *
       
   187  * @param aScript: pointer to the specifics of the script to run.
       
   188  * @param aVarDelay: user specified time delay
       
   189  * @note Initializes private data "aScript" to received parameter.
       
   190  */
       
   191 	{}
       
   192 
       
   193 void CTestUnsolicited::ConstructL()
       
   194 /**
       
   195  * This method is used to implement the 2 Phase Constructor for CTestUnsolicited.
       
   196  * This method uses the CATBase ConstructL to configure the port to be used.
       
   197  *
       
   198  * @leave  Leaves if CATBase leaves.
       
   199  */
       
   200 	{
       
   201 	CATScriptEng::ConstructL();
       
   202 	}
       
   203 
       
   204 TInt CTestUnsolicited::Start()
       
   205 /**
       
   206  * This method is defined as a pure virtual function that must be implemented.
       
   207  * This method is currently not used by the Etel regression test harness.
       
   208  * Instead of using this method to start the scripts, the CTestTxMess::Start()
       
   209  * method is used to start the scripts.  The CTestTxMess::Start() is called by
       
   210  * the responder thread of the scripting engine to start the execution of the script.
       
   211  *
       
   212  * @return KErrNone.
       
   213  */
       
   214 	{
       
   215 	StartScript(iScript);
       
   216 	return KErrNone;
       
   217 	}
       
   218 
       
   219 void CTestUnsolicited::SpecificAlgorithmL(TInt /* aParam */)
       
   220 /**
       
   221  * This method is defined as a pure virtual function that must be implemented.
       
   222  * This method is currently not used by the Etel regression test harness.
       
   223  * Instead of using this method to perform an algorithm specific to this test,
       
   224  * the CTestTxMess::SpecificAlgorithm() method is used.  The CTestTxMess::SpecificAlgorithm()
       
   225  * is called by the scripting engine to perform the test specific algorithm.
       
   226  */
       
   227 	{
       
   228 	}
       
   229 
       
   230 void CTestUnsolicited::Complete(TInt aError)
       
   231 /**
       
   232  * This method is defined as a pure virtual function that must be implemented.
       
   233  * This method is currently not used by the Etel regression test harness.
       
   234  * Instead of using this method to end the scripts, the CTestTxMess::Complete()
       
   235  * method is used to end the scripts.  The CTestTxMess::Complete() is called by
       
   236  * the scripting engine to end the execution of the script.
       
   237  */
       
   238 	{
       
   239 	iReturnValue=aError;
       
   240 	CActiveScheduler::Stop();
       
   241 	}
       
   242