// --------------------------------------------------------- // CPosTp4723::SetupProxyPSYsL // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp4723::SetupProxyPSYsL() { CPosModules* db = CPosModules::OpenL(); CleanupStack::PushL(db); CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); moduleUpdate->SetUpdateAvailability(EFalse); CPosModuleIdList* prioList = db->ModuleIdListLC(); // Disable all PSY:s except PSYs used by this test case for (TInt i = 0 ; i < prioList->Count(); i++) { if ((*prioList)[i] != iUidMultiPsy && (*prioList)[i] != iUidSatInfoPsy) { db->UpdateModuleL((*prioList)[i], *moduleUpdate); } } moduleUpdate->SetUpdateAvailability(ETrue); db->UpdateModuleL(iUidMultiPsy, *moduleUpdate); db->UpdateModuleL(iUidSatInfoPsy, *moduleUpdate); db->SetModulePriorityL(iUidMultiPsy, 0); db->SetModulePriorityL(iUidSatInfoPsy, 1); CleanupStack::PopAndDestroy(prioList); CleanupStack::PopAndDestroy(moduleUpdate); CleanupStack::PopAndDestroy(db); }
void CTe_locsrvSuiteStepBase::SetupPsyPriorityL(TUid aPsyUid, TInt aPriority) { CPosModules* modules = CPosModules::OpenL(); CleanupStack::PushL(modules); CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); // enable module moduleUpdate->SetUpdateAvailability(ETrue); modules->UpdateModuleL(aPsyUid, *moduleUpdate); // set module priority modules->SetModulePriorityL(aPsyUid, aPriority); CleanupStack::PopAndDestroy(2, modules); // moduleUpdate, modules User::After(KSecond); }
// --------------------------------------------------------- // CT_LbsClientPosTp76::StartL // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp76::StartL() { // Open connection to Epos RPositionServer posServer; CleanupClosePushL(posServer); TInt err = posServer.Connect(); _LIT(KConnectError, "TP76. Unable to open connection to Epos, return code %d"); AssertTrueSecL(err == KErrNone, KConnectError, err); // Set priority for those psys that will be used in this tp. // The order will be testpsy1(externalgps),testpsy2,testpsy3 TUid uidPsy1 = iUidTestPsy1; TUid uidPsy2 = iUidTestPsy2; TUid uidPsy3 = iUidTestPsy3; SetupPsyL(uidPsy1); // will disable all except uidPsy1 CPosModules* db = CPosModules::OpenL(); CleanupStack::PushL(db); // Enable the PSY test psys CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); moduleUpdate -> SetUpdateAvailability(ETrue); db->SetModulePriorityL(uidPsy1, 0); db->SetModulePriorityL(uidPsy2, 1); db->SetModulePriorityL(uidPsy3, 1); db->UpdateModuleL(uidPsy1, *moduleUpdate); db->UpdateModuleL(uidPsy2, *moduleUpdate); db->UpdateModuleL(uidPsy3, *moduleUpdate); CleanupStack::PopAndDestroy(moduleUpdate); // Setup the PSY:s in the correct order CPosModuleIdList* prioList = db->ModuleIdListLC(); TInt numModules = prioList->Count(); TPositionModuleInfo modInfoPsy2; //used to comapre that the same result is returned. db -> GetModuleInfoL(uidPsy2, modInfoPsy2); CleanupStack::PopAndDestroy(2); // db, prioList // Get default positioning module info. (testpsy1 or externalgps) TPositionModuleInfo modInfo; TPositionModuleId defaultId; err = posServer.GetDefaultModuleId(defaultId); _LIT(KDefaultModuleId, "Not possible to get default module id"); AssertTrueSecL(err == KErrNone, KDefaultModuleId, err); // Check that the correct id was returned. if (defaultId != uidPsy1) { _LIT(KErrorWrongModule, "Default module was not returned in GetDefaultModuleId()"); LogErrorAndLeaveL(KErrorWrongModule); } // Get default module info by using the id returned. err = posServer.GetModuleInfoById(defaultId, modInfo); _LIT(KGetDefPosModInfoError, "TP76. Error occured at GetModuleInfoById, return code %d"); AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err); // Check if the received psy is the right one _LIT(KIncorrectPsyError, "TP76. Incorrect PSY returned from Epos."); AssertTrueL(uidPsy1 == modInfo.ModuleId(), KIncorrectPsyError); //END TEST DEFAULT// // // TestGetModuleInfoById // // // Get info from specific psy (testpsy2) _LIT(KGetPosModInfoError, "Wrong data received from Epos"); err = posServer.GetModuleInfoById(uidPsy2, modInfo); AssertTrueSecL(err == 0, KGetPosModInfoError, err); AssertTrueL(modInfo.ModuleId() == uidPsy2, KGetPosModInfoError); CheckModuleInfoL(modInfoPsy2, modInfo); //END TEST GetModuleInfoById// // // Test GetModuleInfoByIndex // // // Get info from the testpsys (testpsy1, testpsy2, testpsy3) TPositionModuleId id1; TPositionModuleId id2; TPositionModuleId id3; TUint count; err = posServer.GetNumModules(count); _LIT(KNumPosModInfoError, "TP76. Error occured at GetNumModules error code returned, return code %d"); AssertTrueSecL(err == 0,KNumPosModInfoError,err); _LIT(KIncorrectNoOfModules, "TP76. Incorrect number of modules."); TUint no = (TUint) numModules; //Bad API implementation AssertTrueL(count == no, KIncorrectNoOfModules); err = posServer.GetModuleInfoByIndex(0, modInfo); AssertTrueSecL(err == KErrNone, KGetDefPosModInfoError, err); id1 = modInfo.ModuleId(); if (!(id1 == uidPsy1 || id1 == uidPsy2 || id1 == uidPsy3)) { LogErrorAndLeaveL(KGetPosModInfoError); } err = posServer.GetModuleInfoByIndex(1, modInfo); AssertTrueSecL(err == 0, KGetDefPosModInfoError, err); id2 = modInfo.ModuleId(); if (!(id2 == uidPsy1 || id2 == uidPsy2 || id2 == uidPsy3)) { LogErrorAndLeaveL(KGetPosModInfoError); } err = posServer.GetModuleInfoByIndex(2, modInfo); AssertTrueSecL(err == 0, KGetDefPosModInfoError, err); id3 = modInfo.ModuleId(); if (!(id3 == uidPsy1 || id3 == uidPsy2 || id3 == uidPsy3)) { LogErrorAndLeaveL(KGetPosModInfoError); } // Assuming that only 3 PSYs are installed err = posServer.GetModuleInfoByIndex(3, modInfo); AssertTrueSecL(err == 0, KGetDefPosModInfoError, err); // END TEST GetModuleInfoByIndex // CleanupStack::PopAndDestroy(); //posServer }
// --------------------------------------------------------- // CT_LbsClientPosTp1::StartL // // (other items were commented in a header). // --------------------------------------------------------- // void CT_LbsClientPosTp1::StartL() { ConnectL(); CPosModules* db = CPosModules::OpenL(); CleanupStack::PushL(db); SetupPsyL(iUidMultiPsy); _LIT(KSetupPSY, "TP1: Has Setup Multi PSY"); INFO_PRINTF1(KSetupPSY); //setting priority TPositionModuleInfo moduleInfoHp;//Hp - high prio; TPositionModuleInfo moduleInfoLp;//Lp - low prio; CPosModuleIdList* prioList = db->ModuleIdListLC(); db->GetModuleInfoL(prioList->At(0), moduleInfoHp); CPosModuleUpdate* moduleUpdate = CPosModuleUpdate::NewLC(); moduleUpdate->SetUpdateAvailability(ETrue); if (iUidMultiPsy.iUid == moduleInfoHp.ModuleId().iUid) { // Case when Multi PSY has highest prio: // Ensuring it is enabled _LIT(KMultiHighest, "TP1: Case when Multi PSY has highest prio"); INFO_PRINTF1(KMultiHighest); db->UpdateModuleL((*prioList)[0], *moduleUpdate); } else { // Case when Multi PSY has not highest prio: // _LIT(KMultiNotHighest, "TP1: Case when Multi PSY has NOT highest prio"); INFO_PRINTF1(KMultiNotHighest); db->GetModuleInfoL(iUidMultiPsy, moduleInfoLp); // Ensuring it is enabled db->UpdateModuleL(iUidMultiPsy, *moduleUpdate); TUint hp = db->PriorityL(moduleInfoHp.ModuleId()); TUint lp = db->PriorityL(moduleInfoLp.ModuleId()); // Changing prio of highest prio PSY and Multi PSY. // Setting Multi PSY to highest prio db->SetModulePriorityL(iUidMultiPsy, hp); db->SetModulePriorityL((*prioList)[0], lp); } _LIT(KTestPSY1On, "TP1: Enabling Test PSY 1"); INFO_PRINTF1(KTestPSY1On); db -> UpdateModuleL(iUidTestPsy1, *moduleUpdate); _LIT(KTestPSY2On, "TP1: Enabling Test PSY 2"); INFO_PRINTF1(KTestPSY2On); db -> UpdateModuleL(iUidTestPsy2, *moduleUpdate); CleanupStack::PopAndDestroy(moduleUpdate); CleanupStack::PopAndDestroy(2, db); // db, prioList User::LeaveIfError(OpenPositioner()); // Request data from default psy should be Multi psy _LIT(KService, "service"); TPositionInfo posInfo = TPositionInfo(); TInt err = PerformSyncRequest(KService, &posInfo); if (err != KErrNone) { _LIT(KErrorRequest, "The request was not completed with KErrNone"); LogErrorAndLeaveL(KErrorRequest, err); } if (iUidMultiPsy.iUid != posInfo.ModuleId().iUid) { _LIT(KIncorrectPsyError, "TP1. Position from wrong PSY received"); LogErrorAndLeaveL(KIncorrectPsyError); } HPositionGenericInfo* genericInfo = HPositionGenericInfo::NewLC(); err = PerformSyncRequest(KService, &(*genericInfo)); if (err != KErrNone) { _LIT(KErrorRequest, "The request was not completed with KErrNone"); LogErrorAndLeaveL(KErrorRequest); } if (iUidMultiPsy.iUid != (genericInfo -> ModuleId()).iUid) { _LIT(KIncorrectPsyError, "TP1. Position from wrong PSY received"); LogErrorAndLeaveL(KIncorrectPsyError); } TPositionCourseInfo courseInfo = TPositionCourseInfo(); err = PerformSyncRequest(KService, &courseInfo); if (err != KErrNone) { _LIT(KErrorRequest, "Course info supported by default, but request failed"); LogErrorAndLeaveL(KErrorRequest); } TPositionSatelliteInfo satelliteInfo = TPositionSatelliteInfo(); err = PerformSyncRequest(KService, &satelliteInfo); if (err != KErrNone) { _LIT(KErrorRequest, "Satellite info supported by default, but request failed"); LogErrorAndLeaveL(KErrorRequest); } //Changing the priority and verifiy that it still possilbe //to request updated from a psy if basic position information //is used and that it is not possilbe to request sat or cource //any more. SetupPsyL(iUidTestPsy2); User::After(3000000); // Request data from default psy should be test psy 2 now err = PerformSyncRequest(KService, &posInfo); if (err != KErrNone) { _LIT(KErrorRequest, "The request was not completed with KErrNone"); LogErrorAndLeaveL(KErrorRequest); } if (iUidTestPsy2.iUid != posInfo.ModuleId().iUid) { _LIT(KIncorrectPsyError, "TP1. Position from wrong PSY received"); LogErrorAndLeaveL(KIncorrectPsyError); } err = PerformSyncRequest(KService, &(*genericInfo)); if (err != KErrNone) { _LIT(KErrorRequest, "The request was not completed with KErrNone"); LogErrorAndLeaveL(KErrorRequest); } if (iUidTestPsy2.iUid != (genericInfo -> ModuleId()).iUid) { _LIT(KIncorrectPsyError, "TP1. Position from wrong PSY received"); LogErrorAndLeaveL(KIncorrectPsyError); } err = PerformSyncRequest(KService, &courseInfo); if (err != KErrArgument) { _LIT(KErrorRequest, "Course info not supported by default, KErrArgument not returned"); LogErrorAndLeaveL(KErrorRequest); } err = PerformSyncRequest(KService, &satelliteInfo); if (err != KErrArgument) { _LIT(KErrorRequest, "Satellite info not supported by default, KErrArgument not returned"); LogErrorAndLeaveL(KErrorRequest); } //check that it is possilbe to change the different //type of class info during periodic request and //that the periodic update will fail if the class //type is incorrect. TTimeIntervalMicroSeconds interval = TTimeIntervalMicroSeconds(1000000); TPositionUpdateOptions posOption; posOption.SetUpdateInterval(interval); _LIT(KUpdateErr, "Error when setting update interval, %d"); err = iPositioner.SetUpdateOptions(posOption); AssertTrueL(err == KErrNone, KUpdateErr, err); _LIT(KErrPeriodic, "The periodic request did not return KErrNone, %d"); err = PerformSyncRequest(KService, &posInfo); AssertTrueL(err == KErrNone , KErrPeriodic, err); _LIT(KErrPeriodicArr, "The periodic request did not return KErrArgument, %d"); err = PerformSyncRequest(KService, &satelliteInfo); AssertTrueL(err == KErrArgument , KErrPeriodicArr, err); SetupPsyL(iUidMultiPsy); User::After(3000000); err = PerformSyncRequest(KService, &satelliteInfo); AssertTrueL(err == KErrNone , KErrPeriodic, err); CleanupStack::PopAndDestroy(genericInfo); ClosePositioner(); Disconnect(); }