CTestStep* CR6SMSTestServer::CreateTestStep(const TDesC& aStepName) /** * @return - A CTestStep derived instance * Secure and non-secure variants * Implementation of CTestServer pure virtual */ { CTestStep* testStep = NULL; // // Here the test step is created when it is needed. Note that this // function is non-leaving so we cannot use new(ELeave). Therefore // the new could return NULL, but that is not a problem as it implies // the test step is missing and this will be marked in the log file. // if (aStepName == _L("CTestCSmsMessageAdditionalAttributes1")) { testStep = new CTestCSmsMessageAdditionalAttributes1; } else if (aStepName == _L("CTestCSmsMessageAdditionalAttributes2")) { testStep = new CTestCSmsMessageAdditionalAttributes2; } else if (aStepName == _L("CTestCSmsMessageAdditionalAttributes3")) { testStep = new CTestCSmsMessageAdditionalAttributes3; } else if (aStepName == _L("CTestR6CSmsMessage")) { testStep = new CTestR6CSmsMessage; } else if (aStepName == _L("CTestAddingIEsViaNewAndExistingInterfaces")) { testStep = new CTestAddingIEsViaNewAndExistingInterfaces; } else if (aStepName == _L("CTestIECategoryDefinitions")) { testStep = new CTestIECategoryDefinitions; } else if (aStepName == _L("CTestR6DCS")) { testStep = new CTestR6DCS; } // // Set the test step name here to save code!!! // if (testStep != NULL) { testStep->SetTestStepName(aStepName); } return testStep; }
void CTestMessSharedData::CMsgEntry::ConstructL(CTestStep& aStep) { TPtrC name; // Read in name tag if ( !aStep.GetStringFromConfig(aStep.ConfigSection(), KName, name) ) { aStep.ERR_PRINTF1(_L("Name not found")); aStep.SetTestStepResult(EFail); } else { aStep.INFO_PRINTF2(_L("Name : %S"), &name); iName.Copy(name); } }
TInt CTestSetPrClientMulCallFrDiffClt ::SecondThreadFunctiona(TAny* aThreadData2) { RTelServer server; CTestStep* testStep = static_cast<CTestStep*>(aThreadData2); CTrapCleanup* cleanup; if ((cleanup=CTrapCleanup::New())==NULL) { return KErrGeneral; } TInt ret = server.Connect(); testStep->TEST1(ret==KErrNone,ETrue); testStep->INFO_PRINTF2(_L("Thread2 RTelServer::Connect returned %d."),ret); ret=server.SetPriorityClient(); testStep->TEST1((ret == KErrNone) || (ret == KErrAlreadyExists),ETrue); testStep->INFO_PRINTF2(_L("Thread2 RTelServer::SetPriorityClient returned %d."),ret); server.Close(); delete cleanup; return ret; }
TInt CTestSetPrClientV2MulCallFrDiffClt ::FirstThreadFunctiona(TAny* aThreadData1) { RTelServer server; CTestStep* testStep = static_cast<CTestStep*>(aThreadData1); CTrapCleanup* cleanup; if ((cleanup=CTrapCleanup::New())==NULL) { return KErrGeneral; } TInt ret = server.Connect(); testStep->TEST1(ret==KErrNone,ETrue); testStep->INFO_PRINTF2(_L("Thread1 RTelServer::Connect returned %d."),ret); ret=server.SetPriorityClientV2(); testStep->TEST1(( (ret==KErrAlreadyExists) || (ret==KErrNone) ),ETrue); testStep->INFO_PRINTF2(_L("Thread1 RTelServer::SetPriorityClientV2 returned %d."),ret); User::After(KETelThreadShutdownGuardPeriod); server.Close(); delete cleanup; return ret; }
// __EDIT_ME__ - Use your own server class name CTestStep* CTgsmuStoreServer::CreateTestStep(const TDesC& aStepName) /** * @return - A CTestStep derived instance * Secure and non-secure variants * Implementation of CTestServer pure virtual */ { CTestStep* testStep = NULL; // // Here the test step is created when it is needed. Note that this // function is non-leaving so we cannot use new(ELeave). Therefore // the new could return NULL, but that is not a problem as it implies // the test step is missing and this will be marked in the log file. // if(aStepName == _L("TestGsmuStorFileOpenClose")) { testStep = new CTestGsmuStorFileOpenClose(); } else if(aStepName == _L("TestGsmuStorFileOpenAfterAccess")) { testStep = new CTestGsmuStorFileOpenAfterAccess(); } else if(aStepName == _L("TestGsmuStorTSAREntry")) { testStep = new CTestGsmuStorTSAREntry(); } // // Set the test step name here to save code!!! // if (testStep != NULL) { testStep->SetTestStepName(aStepName); } return testStep; }
TInt CTestMessSharedData::DeleteEntryL(CTestStep& aStep) { TInt ret=KErrNone; TPtrC name; if ( !aStep.GetStringFromConfig(aStep.ConfigSection(), KName, name) ) { aStep.ERR_PRINTF1(_L("Name not found")); aStep.SetTestStepResult(EFail); ret=KErrArgument; } else { aStep.INFO_PRINTF2(_L("Name : %S"), &name); CMsgEntry* msgParent=NULL; CMsgEntry* msgEntry=iList; TBool found=EFalse; while ( (msgEntry!=NULL) && !found ) { if ( msgEntry->iName.Compare(name) == 0 ) { if ( msgParent!=NULL ) { msgParent->iNext=msgEntry->iNext; } else { iList=msgEntry->iNext; } iDeleteTestStep=ETrue; iAnyPostStepToDo=msgEntry; found=ETrue; } else { msgParent=msgEntry; msgEntry=msgEntry->iNext; } } if ( !found ) { aStep.ERR_PRINTF1(_L("Message Entry not found")); aStep.SetTestStepResult(EFail); ret=KErrNotFound; } } return ret; }
/** function used to create the linked typefaces */ void CTLinkedTypefaceCreator::CreateL() { CFbsTypefaceStore* store = CFbsTypefaceStore::NewL(iDev); CleanupStack::PushL(store); for (TInt counter=0; counter< sizeof(KLinkedTypefaces)/sizeof(TTLinkedTypeface);counter++) { //creating the groups needs to be done for every typeface since ownwership is taken //after adding the group to one linked typeface specification //leave on any failure e.g. out of memory, which is not expected CreateGroupsL(KGroupList, sizeof(KGroupList)/sizeof(TTGroup*)); //create the linked typeface elements for this linked typeface CreateElementsL(KLinkedTypefaces[counter].iElements); //add the groups and elements, but first create the spec CLinkedTypefaceSpecification* spec = CLinkedTypefaceSpecification::NewLC(KLinkedTypefaces[counter].iTypefaceName); //add the groups for (TInt groupCounter=0; groupCounter<iGroups.Count();groupCounter++) { spec->AddLinkedTypefaceGroupL(*iGroups[groupCounter]);//ownership is taken iGroups[groupCounter]=NULL; } //add the elements for (TInt elementCounter=0; elementCounter<iElements.Count();elementCounter++) { spec->AddTypefaceAtBackL(*iElements[elementCounter]);//ownership is taken iElements[elementCounter]=NULL; } iElements.ResetAndDestroy(); iGroups.ResetAndDestroy(); //register TInt err=KErrNone; TRAP(err,spec->RegisterLinkedTypefaceL(*store)); //may fail if something is wrong with the tables, want to try to continue //do not report test failure if already registered iStep->testBooleanTrue(err==KErrNone || err==KErrAlreadyExists, (TText8*)__FILE__, __LINE__); //delete spec CleanupStack::PopAndDestroy(); } CleanupStack::PopAndDestroy();//store }
void CHttpClientTestParams::ConstructL(CTestStep& aTestCase) { TPtrC method; TPtrC uri; TPtrC rawRequest; TPtrC rawResponse; TPtrC rawEncodedAuthenticationRequest; TPtrC rawFinalResponse; if(!aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KMethod(), method) || !aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KUri(), uri) || !aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KStatusCode(), iStatusCode)) { User::Leave(KErrCorrupt); } aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawRequest(), rawRequest); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawResponse(), rawResponse); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawEncodedAuthenticationRequest(), rawEncodedAuthenticationRequest); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawFinalResponse(), rawFinalResponse); iMethod = EscapeUtils::ConvertFromUnicodeToUtf8L(method); iUri = EscapeUtils::ConvertFromUnicodeToUtf8L(uri); iRawRequest = EscapeUtils::ConvertFromUnicodeToUtf8L(rawRequest); iRawResponse = EscapeUtils::ConvertFromUnicodeToUtf8L(rawResponse); iEncodedAuthenticationRequest = EscapeUtils::ConvertFromUnicodeToUtf8L(rawEncodedAuthenticationRequest); iFinalResponse = EscapeUtils::ConvertFromUnicodeToUtf8L(rawFinalResponse); ParseAndReplaceCRLF(iRawRequest); ParseAndReplaceCRLF(iRawResponse); ParseAndReplaceCRLF(iEncodedAuthenticationRequest); ParseAndReplaceCRLF(iFinalResponse); TPtrC responseBody; if(aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KResponseBody(), responseBody)) { iResponseBody = EscapeUtils::ConvertFromUnicodeToUtf8L(responseBody); } TPtrC requestBody; if(aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRequestBody(), requestBody)) { iRequestBody = EscapeUtils::ConvertFromUnicodeToUtf8L(requestBody); } // Now read the headers // Read the number of headers TInt responseHeaderCount = 0; aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KResponseFieldCount(), responseHeaderCount); for(TInt i = 0; i < responseHeaderCount; ++i) { CHeaderInfo* headerInfo = new(ELeave) CHeaderInfo; CleanupStack::PushL(headerInfo); TBuf<32> headerFormat; headerFormat.Format(KHeader(), i + 1); TPtrC headerName; aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), headerFormat, headerName); headerInfo->iFieldName = EscapeUtils::ConvertFromUnicodeToUtf8L(headerName); TInt headerValueCount = 0; TBuf<32> headerValueCountStr; headerValueCountStr.Format(KHeaderValueCount(), i + 1); aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), headerValueCountStr, headerValueCount); for(TInt j = 0; j < headerValueCount; ++j) { TBuf<32> headerValueFormat; headerValueFormat.Format(KHeaderValue(), i + 1, j+ 1); TPtrC headerValue; aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), headerValueFormat, headerValue); CHeaderFieldInfo* fieldInfo = new(ELeave) CHeaderFieldInfo; CleanupStack::PushL(fieldInfo); fieldInfo->iFieldValue = EscapeUtils::ConvertFromUnicodeToUtf8L(headerValue); // Check this field has params. TBuf<32> headerFieldParamCount; headerFieldParamCount.Format(KFieldParamCount(), i + 1, j + 1); TInt paramCount = 0; aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), headerFieldParamCount, paramCount); for(TInt k = 0; k < paramCount; ++k) { TBuf<48> fieldParamName; TBuf<48> fieldParamValue; fieldParamName.Format(KFieldParamName, i + 1, j + 1, k + 1); fieldParamValue.Format(KFieldParamValue, i + 1, j + 1, k + 1); TPtrC paramName; TPtrC paramValue; aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), fieldParamName, paramName); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), fieldParamValue, paramValue); CHeaderFieldParamInfo* paramInfo = new(ELeave) CHeaderFieldParamInfo; CleanupStack::PushL(paramInfo); paramInfo->iParamName = EscapeUtils::ConvertFromUnicodeToUtf8L(paramName); paramInfo->iParamValue = EscapeUtils::ConvertFromUnicodeToUtf8L(paramValue); fieldInfo->iFieldParamInfos.AppendL(paramInfo); CleanupStack::Pop(); // paramInfo } headerInfo->iFieldInfos.AppendL(fieldInfo); CleanupStack::Pop(); // fieldInfo } // Check if the header has some params TBuf<48> headerParamCount; headerParamCount.Format(KHeaderParamCount(), i + 1); TInt hdrParamCount = 0; aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), headerParamCount, hdrParamCount); for(TInt x = 0; x < hdrParamCount; ++x) { TBuf<48> headerParamName; TBuf<48> headerParamValue; headerParamName.Format(KHeaderParamName(), i + 1, x + 1); headerParamValue.Format(KHeaderParamValue(), i + 1, x + 1); TPtrC paramName; TPtrC paramValue; aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), headerParamName, paramName); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), headerParamValue, paramValue); CHeaderFieldParamInfo* paramInfo = new (ELeave) CHeaderFieldParamInfo; CleanupStack::PushL(paramInfo); paramInfo->iParamName = EscapeUtils::ConvertFromUnicodeToUtf8L(paramName); paramInfo->iParamValue = EscapeUtils::ConvertFromUnicodeToUtf8L(paramValue); headerInfo->iParamInfos.AppendL(paramInfo); CleanupStack::Pop(); // paramInfo } iResponseHeaderInfos.AppendL(headerInfo); CleanupStack::Pop(); // headerInfo } TPtrC fileName; aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KResponseFileName(), fileName); if(fileName.Length() > 0) { iFileSender = CFileSender::NewL(fileName); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KResponseFileNameStore(), fileName); if(fileName.Length() == 0) { User::Leave(KErrCorrupt); } iFileReceiver = CFileReceiver::NewL(fileName); } TPtrC ulFileName; aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRequestFileName(), ulFileName); if(ulFileName.Length() > 0) { iFileSender = CFileSender::NewL(ulFileName); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRequestFileNameStore(), ulFileName); if(ulFileName.Length() == 0) { User::Leave(KErrCorrupt); } iFileReceiver = CFileReceiver::NewL(ulFileName); } // Read request headers TInt reqFieldCount = 0; aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KRequestFieldCount(), reqFieldCount); for(TInt ii = 0; ii < reqFieldCount; ++ii) { // Read the request header TBuf<64> reqHeaderStr; reqHeaderStr.Format(KRequestHeader(), ii + 1); TPtrC reqHeaderName; aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), reqHeaderStr, reqHeaderName); CHeaderInfo* headerInfo = new(ELeave) CHeaderInfo; CleanupStack::PushL(headerInfo); headerInfo->iFieldName = EscapeUtils::ConvertFromUnicodeToUtf8L(reqHeaderName); // Now read how many fields are present reqHeaderStr.Format(KRequestHeaderValueCount(), ii + 1); TInt reqHdrValueCount = 0; aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), reqHeaderStr, reqHdrValueCount); for(TInt jj = 0; jj < reqHdrValueCount; ++jj) { TPtrC reqHeaderVal; reqHeaderStr.Format(KRequestHeaderValue(), ii + 1, jj + 1); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), reqHeaderStr, reqHeaderVal); CHeaderFieldInfo* info = new (ELeave) CHeaderFieldInfo; CleanupStack::PushL(info); info->iFieldValue = EscapeUtils::ConvertFromUnicodeToUtf8L(reqHeaderVal); reqHeaderStr.Format(KRequestHeaderValueParamCount, ii + 1, jj + 1); TInt paramCount = 0; aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), reqHeaderStr, paramCount); for(TInt kk = 0; kk < paramCount; ++kk) { reqHeaderStr.Format(KRequestHeaderValueParamName(), ii + 1, jj + 1, kk + 1); TPtrC name; TPtrC value; aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), reqHeaderStr, name); reqHeaderStr.Format(KRequestHeaderValueParamValue(), ii + 1, jj + 1, kk + 1); aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), reqHeaderStr, value); CHeaderFieldParamInfo* paramInfo = new (ELeave) CHeaderFieldParamInfo; CleanupStack::PushL(paramInfo); paramInfo->iParamName = EscapeUtils::ConvertFromUnicodeToUtf8L(name); paramInfo->iParamValue = EscapeUtils::ConvertFromUnicodeToUtf8L(value); info->iFieldParamInfos.AppendL(paramInfo); CleanupStack::Pop(); // CHeaderFieldParamInfo } headerInfo->iFieldInfos.AppendL(info); CleanupStack::Pop(); // info } iRequestHeaderInfos.AppendL(headerInfo); CleanupStack::Pop(); } iConnDisconnect = EFalse; aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KConnDisconnect(), iConnDisconnect); iExpectedError = KErrNone; aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KExpectedError(), iExpectedError); iNoRetryOnDisconnect = EFalse; aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KNoRetryOnDisconnect(), iNoRetryOnDisconnect); iResponseDynamicAndStatic = EFalse; aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KResponseDynamicAndStatic(), iResponseDynamicAndStatic); iOnlineTest = EFalse; aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KOnlineTest(), iOnlineTest); iRedirection = EFalse; aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KRedirection(), iRedirection); iResponseTimeout = EFalse; aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KResponseTimeout(), iResponseTimeout); iNotifyTransferProgress = EFalse; aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KNotifyTransferProgress(), iNotifyTransferProgress); iSetAuthentication = EFalse; aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KSetAuthentication(), iSetAuthentication); TPtrC proxyAddress; if(aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KProxyAddress, proxyAddress)) { iProxyAddress = EscapeUtils::ConvertFromUnicodeToUtf8L(proxyAddress); } }