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