diff -r e8c1ea2c6496 -r 8758140453c0 lbs/lbsclient/src/ctlbsclientpostp256.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lbs/lbsclient/src/ctlbsclientpostp256.cpp Thu Jan 21 12:53:44 2010 +0000 @@ -0,0 +1,291 @@ +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +// All rights reserved. +// This component and the accompanying materials are made available +// under the terms of the License "Symbian Foundation License v1.0" +// which accompanies this distribution, and is available +// at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". +// +// Initial Contributors: +// Nokia Corporation - initial contribution. +// +// Contributors: +// +// Description: +// + + + +// INCLUDES +#include +#include +#include "ctlbsclientpostp256.h" +#include + +// CONSTANTS +const TInt KNoMultipleClients=2; +const TUint KMaxHeapSize=0x80000; + +// Structure for passing parameters to threads +struct MyThreadData + { + TBool iTestFlag; + }; + +// ================= MEMBER FUNCTIONS ======================= + +// --------------------------------------------------------- +// Constructor. +// --------------------------------------------------------- +CT_LbsClientPosTp256::CT_LbsClientPosTp256(CT_LbsServer& aParent): CT_LbsPortedStepBase(aParent) + { + _LIT(KTestName, "Tp256 - Location Settings and Multiple Clients"); + SetTestStepName(KTestName); + } + +// --------------------------------------------------------- +// Destructor. +// --------------------------------------------------------- +CT_LbsClientPosTp256::~CT_LbsClientPosTp256() + { + } + +// --------------------------------------------------------- +// CT_LbsClientPosTp256::StartL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CT_LbsClientPosTp256::StartL() + { + _LIT(KMultipleErr, "Error %d when multiple clients access the CPosModules, err from client:%d"); + _LIT(KSuccess, "Client %d is successful"); + _LIT(KAllErr, "All clients gets error when multiple clients access the CPosModules"); + _LIT(KPanicErr, "Panic when multiple clients access the CPosModules, Thread: %d panics"); + + TFixedArray statuses; + //make a request just to make sure att all databases are created. + + SetupPsyL(iUidMultiPsy); + + //synchronous request + ConnectL(); + + User::LeaveIfError(OpenPositionerByName(iUidMultiPsy)); + + TPositionInfo info = TPositionInfo(); + + RequestL(info); + + //potenial memory leak if above function leav + ClosePositioner(); + Disconnect(); + + //End first request. + + + TInt errorsFound = KErrNone; + CreateThreadsL(); + + for (TInt i=0; i buf; + if (exitReason != KErrNone) + { + buf.Format(KMultipleErr, exitReason, t); + INFO_PRINTF1(buf); + + errorsFound++; + } + else + { + buf.Format(KSuccess, t); + INFO_PRINTF1(buf); + } + AssertTrueL(iThreads[t].ExitType() != EExitPanic, KPanicErr, t); + } + + AssertTrueL(errorsFound < KNoMultipleClients, KAllErr, KErrGeneral); + + _LIT(KPass, "CT_LbsClientPosTp256 passed!!!"); + INFO_PRINTF1(KPass); + } + +// --------------------------------------------------------- +// CT_LbsClientPosTp256::CloseTest +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CT_LbsClientPosTp256::CloseTest() + { + for (TInt i=0; iResetAllModulesL(); + CPosModuleIdList* myDebugList = db->ModuleIdListLC(); + + nrOfModules = myDebugList->Count(); + TPositionModuleInfo debugModuleInfo; + TBuf<40> moduleName; + TPositionQuality quality; + + for (TInt i=0;iGetModuleInfoL(myDebugList->At(i), debugModuleInfo); + moduleName.Zero(); + debugModuleInfo.GetModuleName(moduleName); + debugModuleInfo.GetPositionQuality(quality); + } + CleanupStack::PopAndDestroy(myDebugList); + } + + for (i=0;iiTestFlag) + { + for (TInt j=0;jSetModulePriorityL(nrOfModules-j-1, j); + } + } + // And all the other thread does this + else + { + CPosModuleIdList* myDebugList = db->ModuleIdListLC(); + + TInt debugCount = myDebugList->Count(); + TPositionModuleInfo debugModuleInfo; + TBuf<20> moduleName; + TPositionQuality quality; + + for (TInt i=0;iGetModuleInfoL(myDebugList->At(i), debugModuleInfo); + moduleName.Zero(); + debugModuleInfo.GetModuleName(moduleName); + debugModuleInfo.GetPositionQuality(quality); + } + CleanupStack::PopAndDestroy(myDebugList); + } + } + + + CleanupStack::PopAndDestroy(db); + } + +// --------------------------------------------------------- +// LOCAL_C TInt ThreadFunction +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +LOCAL_C TInt ThreadFunction(TAny* aData) + { + __UHEAP_MARK; + CTrapCleanup* cleanup=CTrapCleanup::New(); // get clean-up stack + + if (cleanup == NULL) + { + return KErrNoMemory; + } + // we need an ActiveScheduler + CActiveScheduler scheduler; + CActiveScheduler::Install(&scheduler); + + TRAPD(err, RunTestL(aData)); + + delete cleanup; // destroy clean-up stack + __UHEAP_MARKEND; + return err; + } + +// --------------------------------------------------------- +// CT_LbsClientPosTp256::CreateThreadsL +// +// (other items were commented in a header). +// --------------------------------------------------------- +// +void CT_LbsClientPosTp256::CreateThreadsL() + { + _LIT(KThreadName, "TP256 test thread%d"); + _LIT(KCreateThreadErr, "Create thread failed with %d"); + + for (TInt i=0; i name; + name.Format(KThreadName, 1+iThreads.Count()); + + TInt err; + err = thread.Create(name, ThreadFunction, KDefaultStackSize, KMinHeapSize, KMaxHeapSize, reinterpret_cast(&info)); + AssertTrueL(err == KErrNone, KCreateThreadErr, err); + + iThreads.Append(thread); + } + } + + +void CT_LbsClientPosTp256::RequestL(TPositionInfoBase& aInfoBase) + { + _LIT(KService, "service"); + TInt err = PerformSyncRequest(KService, &aInfoBase); + + if (err != KErrNone) + { + _LIT(KErrorRequest, "The request was not completed with KErrorNone, errCode = %d"); + TBuf<100> buf; + buf.Format(KErrorRequest, err); + LogErrorAndLeaveL(buf); + } + + _LIT(KIncorrectPsySyncRequestError, + "TP2. Position from wrong PSY received (sync request)."); + if (iUidMultiPsy != aInfoBase.ModuleId()) + { + LogErrorAndLeaveL(KIncorrectPsySyncRequestError); + } + } + +// End of File