sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: /** sl@0: @file UloggerServerTest4Step.cpp sl@0: @internalTechnology sl@0: */ sl@0: sl@0: sl@0: #include "uloggerservertest4step.h" sl@0: #include "te_uloggerservertestsuitedefs.h" sl@0: #include "uloggerwatcher.h" sl@0: #include "uloggerdatatypes.h" sl@0: sl@0: namespace Ulogger sl@0: { sl@0: sl@0: CUloggerServerTest4Step::~CUloggerServerTest4Step() sl@0: /** sl@0: * Destructor sl@0: */ sl@0: { sl@0: sl@0: } sl@0: sl@0: CUloggerServerTest4Step::CUloggerServerTest4Step() sl@0: /** sl@0: * Constructor sl@0: */ sl@0: { sl@0: SetTestStepName(KUloggerServerTest4Step); sl@0: } sl@0: sl@0: TVerdict CUloggerServerTest4Step::doTestStepPreambleL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class virtual sl@0: */ sl@0: { sl@0: INFO_PRINTF1(_L("****This is unit test for CControlFramework class****")); sl@0: iScheduler = new (ELeave) CActiveScheduler(); sl@0: CActiveScheduler::Install(iScheduler); sl@0: sl@0: RPointerArray controlPluginSettings; sl@0: INFO_PRINTF1(_L("INFO: building plugin allocator with input plugin...")); sl@0: TRAPD(err, iPluginAllocator = CPluginAllocator::NewL(KFileTestPluginTest(), KUsbTestPluginTest())); sl@0: INFO_PRINTF1(_L("INFO: plugin allocator created")); sl@0: if(err == KErrNone) sl@0: { sl@0: MInputPlugin* inputPlugin = iPluginAllocator->GetInputPlugin(); sl@0: if(inputPlugin) sl@0: { sl@0: iCF = CInputFramework::NewL(inputPlugin, controlPluginSettings, this); sl@0: iMan = new CInputData(); sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("INFO: input pluigin not avaiable.")); sl@0: iCF = NULL; sl@0: iMan = NULL; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: INFO_PRINTF1(_L("plugin allocator not fully created - skiping step.")); sl@0: iCF = NULL; sl@0: iMan = NULL; sl@0: } sl@0: sl@0: sl@0: SetTestStepResult(EPass); sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: TVerdict CUloggerServerTest4Step::doTestStepL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class pure virtual sl@0: * Our implementation only gets called if the base class doTestStepPreambleL() did sl@0: * not leave. That being the case, the current test result value will be EPass. sl@0: */ sl@0: { sl@0: iErrors = 0; sl@0: if (TestStepResult()==EPass) sl@0: { sl@0: if(iCF && iMan) sl@0: { sl@0: iErrors += Test1L(); //CControlFramework::StartReading + StopReading sl@0: iErrors += Test2L(); //CControlFramework:: testing functionality of passing and translating commands sl@0: sl@0: //display results sl@0: TBuf<128> res; sl@0: res.AppendFormat(_L("%d errors"), iErrors); sl@0: INFO_PRINTF1(_L("****Results****")); sl@0: INFO_PRINTF1(res); sl@0: if(iErrors == 0) sl@0: SetTestStepResult(EPass); sl@0: else sl@0: SetTestStepResult(EFail); sl@0: } sl@0: else sl@0: SetTestStepResult(EPass); sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: sl@0: TVerdict CUloggerServerTest4Step::doTestStepPostambleL() sl@0: /** sl@0: * @return - TVerdict code sl@0: * Override of base class virtual sl@0: */ sl@0: { sl@0: if(iCF) sl@0: { sl@0: iCF->StopReading(); sl@0: delete iCF; sl@0: iCF = NULL; sl@0: } sl@0: delete iMan; sl@0: sl@0: delete iPluginAllocator; sl@0: iPluginAllocator = NULL; sl@0: sl@0: delete iScheduler; sl@0: iScheduler = NULL; sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: sl@0: sl@0: ControlData* CUloggerServerTest4Step::ProcessCommandL(TCommand /*aOpCode*/, RArray &aArguments) sl@0: { sl@0: INFO_PRINTF1(_L("****Incominng parameters:****")); sl@0: for(TInt i=0; i b; sl@0: b.Copy(aArguments[i]); sl@0: INFO_PRINTF1(b); sl@0: } sl@0: sl@0: return iMan->CreatePackage((void*)"-5",2); sl@0: } sl@0: sl@0: void CUloggerServerTest4Step::DoPostProcessing(TCommand /*aCmd*/) sl@0: { sl@0: sl@0: } sl@0: sl@0: TInt CUloggerServerTest4Step::Test1L() sl@0: { sl@0: TInt errors = 0; sl@0: sl@0: INFO_PRINTF1(_L("****Testing CControlFramework::StartReading****")); sl@0: TInt errCode = iCF->StartReading(); sl@0: TBuf<32> buf; sl@0: buf.AppendFormat(_L("code returned from method: %d"), errCode); sl@0: INFO_PRINTF1(buf); sl@0: sl@0: INFO_PRINTF1(_L("****Testing CControlFramework::StopReading****")); sl@0: iCF->StopReading(); sl@0: sl@0: return errors; sl@0: } sl@0: sl@0: sl@0: void CUloggerServerTest4Step::TestFunctionalityL(const TDesC8& aCommand) sl@0: { sl@0: ControlData* cData = NULL; sl@0: cData = iMan->CreatePackage( (void*)aCommand.Ptr(), aCommand.Length()); sl@0: iCF->iDataPtr.Zero(); sl@0: iCF->iDataPtr.Copy((const TUint8*)cData, iMan->GetSize(cData)); sl@0: iCF->iStatus = KErrNone; sl@0: iCF->RunL(); sl@0: delete [] cData; sl@0: } sl@0: sl@0: sl@0: TInt CUloggerServerTest4Step::Test2L() sl@0: { sl@0: TInt errors = 0; sl@0: INFO_PRINTF1(_L("****Testing CControlFramework functionality****")); sl@0: sl@0: INFO_PRINTF1(_L("start command:")); sl@0: TestFunctionalityL(_L8("-r")); sl@0: sl@0: INFO_PRINTF1(_L("stop command:")); sl@0: TestFunctionalityL(_L8("-q")); sl@0: sl@0: INFO_PRINTF1(_L("set f1 command:")); sl@0: TestFunctionalityL(_L8("-ef 4 5 6 7")); sl@0: sl@0: INFO_PRINTF1(_L("set f2 command:")); sl@0: TestFunctionalityL(_L8("-es 114 115 1116 111117")); sl@0: sl@0: INFO_PRINTF1(_L("set ps command:")); sl@0: TestFunctionalityL(_L8("-ec uloggerfileplugin output_path e:\\test.ulog")); sl@0: sl@0: INFO_PRINTF1(_L("set ia command:")); sl@0: TestFunctionalityL(_L8("-ei uloggerusbplugin")); sl@0: sl@0: sl@0: return errors; sl@0: } sl@0: sl@0: }