os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-server/uloggerservertest4step.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/traceservices/tracefw/ulogger/unit_test/te-server/uloggerservertest4step.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,221 @@
     1.4 +// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file UloggerServerTest4Step.cpp
    1.21 + @internalTechnology
    1.22 +*/
    1.23 +
    1.24 +
    1.25 +#include "uloggerservertest4step.h"
    1.26 +#include "te_uloggerservertestsuitedefs.h"
    1.27 +#include "uloggerwatcher.h"
    1.28 +#include "uloggerdatatypes.h"
    1.29 +
    1.30 +namespace Ulogger
    1.31 +{
    1.32 +
    1.33 +CUloggerServerTest4Step::~CUloggerServerTest4Step()
    1.34 +/**
    1.35 + * Destructor
    1.36 + */
    1.37 +	{
    1.38 +	
    1.39 +	}
    1.40 +
    1.41 +CUloggerServerTest4Step::CUloggerServerTest4Step()
    1.42 +/**
    1.43 + * Constructor
    1.44 + */
    1.45 +	{
    1.46 +	SetTestStepName(KUloggerServerTest4Step);
    1.47 +	}
    1.48 +
    1.49 +TVerdict CUloggerServerTest4Step::doTestStepPreambleL()
    1.50 +/**
    1.51 + * @return - TVerdict code
    1.52 + * Override of base class virtual
    1.53 + */
    1.54 +	{
    1.55 +	INFO_PRINTF1(_L("****This is unit test for CControlFramework class****"));	
    1.56 +	iScheduler = new (ELeave) CActiveScheduler();
    1.57 +	CActiveScheduler::Install(iScheduler);
    1.58 +	
    1.59 +	RPointerArray<TPluginConfiguration> controlPluginSettings;
    1.60 +	INFO_PRINTF1(_L("INFO: building plugin allocator with input plugin..."));	
    1.61 +	TRAPD(err, iPluginAllocator = CPluginAllocator::NewL(KFileTestPluginTest(), KUsbTestPluginTest()));
    1.62 +	INFO_PRINTF1(_L("INFO: plugin allocator created"));	
    1.63 +	if(err == KErrNone)
    1.64 +		{
    1.65 +		MInputPlugin* inputPlugin = iPluginAllocator->GetInputPlugin();
    1.66 +		if(inputPlugin)
    1.67 +			{
    1.68 +			iCF = CInputFramework::NewL(inputPlugin, controlPluginSettings, this);
    1.69 +			iMan = new CInputData();
    1.70 +			}
    1.71 +		else
    1.72 +			{
    1.73 +			INFO_PRINTF1(_L("INFO: input pluigin not avaiable."));	
    1.74 +			iCF = NULL;
    1.75 +			iMan = NULL;
    1.76 +			}
    1.77 +		}
    1.78 +	else
    1.79 +		{
    1.80 +		INFO_PRINTF1(_L("plugin allocator not fully created - skiping step."));	
    1.81 +		iCF = NULL;
    1.82 +		iMan = NULL;
    1.83 +		}
    1.84 +	
    1.85 +	
    1.86 +	SetTestStepResult(EPass);
    1.87 +	return TestStepResult();
    1.88 +	}
    1.89 +
    1.90 +
    1.91 +TVerdict CUloggerServerTest4Step::doTestStepL()
    1.92 +/**
    1.93 + * @return - TVerdict code
    1.94 + * Override of base class pure virtual
    1.95 + * Our implementation only gets called if the base class doTestStepPreambleL() did
    1.96 + * not leave. That being the case, the current test result value will be EPass.
    1.97 + */
    1.98 +	{
    1.99 +	  iErrors = 0;
   1.100 +	  if (TestStepResult()==EPass)
   1.101 +	  {
   1.102 +	  if(iCF && iMan)
   1.103 +		  {
   1.104 +		  iErrors += Test1L(); //CControlFramework::StartReading + StopReading
   1.105 +		  iErrors += Test2L(); //CControlFramework:: testing functionality of passing and translating commands
   1.106 +		
   1.107 +		  //display results
   1.108 +		  TBuf<128> res;
   1.109 +		  res.AppendFormat(_L("%d errors"), iErrors);
   1.110 +		  INFO_PRINTF1(_L("****Results****"));
   1.111 +		  INFO_PRINTF1(res);
   1.112 +		  if(iErrors == 0)  
   1.113 +			  SetTestStepResult(EPass);
   1.114 +				else
   1.115 +					SetTestStepResult(EFail);
   1.116 +		  }
   1.117 +	  else
   1.118 +		  SetTestStepResult(EPass);
   1.119 +	  }
   1.120 +	  
   1.121 +	  return TestStepResult();
   1.122 +	}
   1.123 +
   1.124 +
   1.125 +
   1.126 +TVerdict CUloggerServerTest4Step::doTestStepPostambleL()
   1.127 +/**
   1.128 + * @return - TVerdict code
   1.129 + * Override of base class virtual
   1.130 + */
   1.131 +	{
   1.132 +	if(iCF)
   1.133 +		{
   1.134 +		iCF->StopReading();
   1.135 +		delete iCF;
   1.136 +		iCF = NULL;
   1.137 +		}
   1.138 +	delete iMan;
   1.139 +	
   1.140 +	delete iPluginAllocator;
   1.141 +	iPluginAllocator = NULL;
   1.142 +	
   1.143 +	delete iScheduler;
   1.144 +	iScheduler = NULL;
   1.145 +	
   1.146 +	return TestStepResult();
   1.147 +	}
   1.148 +
   1.149 +
   1.150 +ControlData* CUloggerServerTest4Step::ProcessCommandL(TCommand /*aOpCode*/, RArray<TPtrC8> &aArguments)
   1.151 +	{
   1.152 +	INFO_PRINTF1(_L("****Incominng parameters:****"));
   1.153 +	for(TInt i=0; i<aArguments.Count(); i++)
   1.154 +		{
   1.155 +		TBuf<256> b;
   1.156 +		b.Copy(aArguments[i]);
   1.157 +		INFO_PRINTF1(b);
   1.158 +		}
   1.159 +	
   1.160 +	return iMan->CreatePackage((void*)"-5",2);
   1.161 +	}
   1.162 +
   1.163 +void CUloggerServerTest4Step::DoPostProcessing(TCommand /*aCmd*/)
   1.164 +	{
   1.165 +	
   1.166 +	}
   1.167 +
   1.168 +TInt CUloggerServerTest4Step::Test1L()
   1.169 +	{
   1.170 +	TInt errors = 0;
   1.171 +	
   1.172 +	INFO_PRINTF1(_L("****Testing CControlFramework::StartReading****"));
   1.173 +	TInt errCode = iCF->StartReading();
   1.174 +	TBuf<32> buf;
   1.175 +	buf.AppendFormat(_L("code returned from method: %d"), errCode);
   1.176 +	INFO_PRINTF1(buf);
   1.177 +	
   1.178 +	INFO_PRINTF1(_L("****Testing CControlFramework::StopReading****"));
   1.179 +	iCF->StopReading();
   1.180 +	
   1.181 +	return errors;
   1.182 +	}
   1.183 +
   1.184 +
   1.185 +void CUloggerServerTest4Step::TestFunctionalityL(const TDesC8& aCommand)
   1.186 +	{
   1.187 +	ControlData* cData = NULL;
   1.188 +	cData = iMan->CreatePackage( (void*)aCommand.Ptr(), aCommand.Length());
   1.189 +	iCF->iDataPtr.Zero();
   1.190 +	iCF->iDataPtr.Copy((const TUint8*)cData, iMan->GetSize(cData));
   1.191 +	iCF->iStatus = KErrNone;
   1.192 +	iCF->RunL();
   1.193 +	delete [] cData;
   1.194 +	}
   1.195 +
   1.196 +
   1.197 +TInt CUloggerServerTest4Step::Test2L()
   1.198 +	{
   1.199 +	TInt errors = 0;
   1.200 +	INFO_PRINTF1(_L("****Testing CControlFramework functionality****"));
   1.201 +	
   1.202 +	INFO_PRINTF1(_L("start command:"));
   1.203 +	TestFunctionalityL(_L8("-r"));
   1.204 +	
   1.205 +	INFO_PRINTF1(_L("stop command:"));
   1.206 +	TestFunctionalityL(_L8("-q"));
   1.207 +	
   1.208 +	INFO_PRINTF1(_L("set f1 command:"));
   1.209 +	TestFunctionalityL(_L8("-ef 4 5 6 7"));
   1.210 +
   1.211 +	INFO_PRINTF1(_L("set f2 command:"));
   1.212 +	TestFunctionalityL(_L8("-es 114 115 1116 111117"));
   1.213 +
   1.214 +	INFO_PRINTF1(_L("set ps command:"));
   1.215 +	TestFunctionalityL(_L8("-ec uloggerfileplugin output_path e:\\test.ulog"));
   1.216 +
   1.217 +	INFO_PRINTF1(_L("set ia command:"));
   1.218 +	TestFunctionalityL(_L8("-ei uloggerusbplugin"));
   1.219 +
   1.220 +	
   1.221 +	return errors;
   1.222 +	}
   1.223 +
   1.224 +}