os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-server/uloggerservertest4step.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 //
    15 
    16 /**
    17  @file UloggerServerTest4Step.cpp
    18  @internalTechnology
    19 */
    20 
    21 
    22 #include "uloggerservertest4step.h"
    23 #include "te_uloggerservertestsuitedefs.h"
    24 #include "uloggerwatcher.h"
    25 #include "uloggerdatatypes.h"
    26 
    27 namespace Ulogger
    28 {
    29 
    30 CUloggerServerTest4Step::~CUloggerServerTest4Step()
    31 /**
    32  * Destructor
    33  */
    34 	{
    35 	
    36 	}
    37 
    38 CUloggerServerTest4Step::CUloggerServerTest4Step()
    39 /**
    40  * Constructor
    41  */
    42 	{
    43 	SetTestStepName(KUloggerServerTest4Step);
    44 	}
    45 
    46 TVerdict CUloggerServerTest4Step::doTestStepPreambleL()
    47 /**
    48  * @return - TVerdict code
    49  * Override of base class virtual
    50  */
    51 	{
    52 	INFO_PRINTF1(_L("****This is unit test for CControlFramework class****"));	
    53 	iScheduler = new (ELeave) CActiveScheduler();
    54 	CActiveScheduler::Install(iScheduler);
    55 	
    56 	RPointerArray<TPluginConfiguration> controlPluginSettings;
    57 	INFO_PRINTF1(_L("INFO: building plugin allocator with input plugin..."));	
    58 	TRAPD(err, iPluginAllocator = CPluginAllocator::NewL(KFileTestPluginTest(), KUsbTestPluginTest()));
    59 	INFO_PRINTF1(_L("INFO: plugin allocator created"));	
    60 	if(err == KErrNone)
    61 		{
    62 		MInputPlugin* inputPlugin = iPluginAllocator->GetInputPlugin();
    63 		if(inputPlugin)
    64 			{
    65 			iCF = CInputFramework::NewL(inputPlugin, controlPluginSettings, this);
    66 			iMan = new CInputData();
    67 			}
    68 		else
    69 			{
    70 			INFO_PRINTF1(_L("INFO: input pluigin not avaiable."));	
    71 			iCF = NULL;
    72 			iMan = NULL;
    73 			}
    74 		}
    75 	else
    76 		{
    77 		INFO_PRINTF1(_L("plugin allocator not fully created - skiping step."));	
    78 		iCF = NULL;
    79 		iMan = NULL;
    80 		}
    81 	
    82 	
    83 	SetTestStepResult(EPass);
    84 	return TestStepResult();
    85 	}
    86 
    87 
    88 TVerdict CUloggerServerTest4Step::doTestStepL()
    89 /**
    90  * @return - TVerdict code
    91  * Override of base class pure virtual
    92  * Our implementation only gets called if the base class doTestStepPreambleL() did
    93  * not leave. That being the case, the current test result value will be EPass.
    94  */
    95 	{
    96 	  iErrors = 0;
    97 	  if (TestStepResult()==EPass)
    98 	  {
    99 	  if(iCF && iMan)
   100 		  {
   101 		  iErrors += Test1L(); //CControlFramework::StartReading + StopReading
   102 		  iErrors += Test2L(); //CControlFramework:: testing functionality of passing and translating commands
   103 		
   104 		  //display results
   105 		  TBuf<128> res;
   106 		  res.AppendFormat(_L("%d errors"), iErrors);
   107 		  INFO_PRINTF1(_L("****Results****"));
   108 		  INFO_PRINTF1(res);
   109 		  if(iErrors == 0)  
   110 			  SetTestStepResult(EPass);
   111 				else
   112 					SetTestStepResult(EFail);
   113 		  }
   114 	  else
   115 		  SetTestStepResult(EPass);
   116 	  }
   117 	  
   118 	  return TestStepResult();
   119 	}
   120 
   121 
   122 
   123 TVerdict CUloggerServerTest4Step::doTestStepPostambleL()
   124 /**
   125  * @return - TVerdict code
   126  * Override of base class virtual
   127  */
   128 	{
   129 	if(iCF)
   130 		{
   131 		iCF->StopReading();
   132 		delete iCF;
   133 		iCF = NULL;
   134 		}
   135 	delete iMan;
   136 	
   137 	delete iPluginAllocator;
   138 	iPluginAllocator = NULL;
   139 	
   140 	delete iScheduler;
   141 	iScheduler = NULL;
   142 	
   143 	return TestStepResult();
   144 	}
   145 
   146 
   147 ControlData* CUloggerServerTest4Step::ProcessCommandL(TCommand /*aOpCode*/, RArray<TPtrC8> &aArguments)
   148 	{
   149 	INFO_PRINTF1(_L("****Incominng parameters:****"));
   150 	for(TInt i=0; i<aArguments.Count(); i++)
   151 		{
   152 		TBuf<256> b;
   153 		b.Copy(aArguments[i]);
   154 		INFO_PRINTF1(b);
   155 		}
   156 	
   157 	return iMan->CreatePackage((void*)"-5",2);
   158 	}
   159 
   160 void CUloggerServerTest4Step::DoPostProcessing(TCommand /*aCmd*/)
   161 	{
   162 	
   163 	}
   164 
   165 TInt CUloggerServerTest4Step::Test1L()
   166 	{
   167 	TInt errors = 0;
   168 	
   169 	INFO_PRINTF1(_L("****Testing CControlFramework::StartReading****"));
   170 	TInt errCode = iCF->StartReading();
   171 	TBuf<32> buf;
   172 	buf.AppendFormat(_L("code returned from method: %d"), errCode);
   173 	INFO_PRINTF1(buf);
   174 	
   175 	INFO_PRINTF1(_L("****Testing CControlFramework::StopReading****"));
   176 	iCF->StopReading();
   177 	
   178 	return errors;
   179 	}
   180 
   181 
   182 void CUloggerServerTest4Step::TestFunctionalityL(const TDesC8& aCommand)
   183 	{
   184 	ControlData* cData = NULL;
   185 	cData = iMan->CreatePackage( (void*)aCommand.Ptr(), aCommand.Length());
   186 	iCF->iDataPtr.Zero();
   187 	iCF->iDataPtr.Copy((const TUint8*)cData, iMan->GetSize(cData));
   188 	iCF->iStatus = KErrNone;
   189 	iCF->RunL();
   190 	delete [] cData;
   191 	}
   192 
   193 
   194 TInt CUloggerServerTest4Step::Test2L()
   195 	{
   196 	TInt errors = 0;
   197 	INFO_PRINTF1(_L("****Testing CControlFramework functionality****"));
   198 	
   199 	INFO_PRINTF1(_L("start command:"));
   200 	TestFunctionalityL(_L8("-r"));
   201 	
   202 	INFO_PRINTF1(_L("stop command:"));
   203 	TestFunctionalityL(_L8("-q"));
   204 	
   205 	INFO_PRINTF1(_L("set f1 command:"));
   206 	TestFunctionalityL(_L8("-ef 4 5 6 7"));
   207 
   208 	INFO_PRINTF1(_L("set f2 command:"));
   209 	TestFunctionalityL(_L8("-es 114 115 1116 111117"));
   210 
   211 	INFO_PRINTF1(_L("set ps command:"));
   212 	TestFunctionalityL(_L8("-ec uloggerfileplugin output_path e:\\test.ulog"));
   213 
   214 	INFO_PRINTF1(_L("set ia command:"));
   215 	TestFunctionalityL(_L8("-ei uloggerusbplugin"));
   216 
   217 	
   218 	return errors;
   219 	}
   220 
   221 }