/** Function : RetriveSearchSortResultL Description : Retrieves the search/sort result @return : none */ void CT_MsgSearchSortByQueryObject::RetriveSearchSortResultL(const TInt aIterationLimit, TMsvSearchSortResultType aResultType) { // Get the number of messages satisfying the search/sort request TInt resultCount = iSharedDataCommon.iSearchSortOperation->GetResultCountL(); WriteIntToConfig(ConfigSection(), KCountOfResult, resultCount); // Get the search/sort result according to user preference TMsvId messageId, serviceId; TMsvEntry messageEntry; iSharedDataCommon.iSearchSortResultArray.Reset(); // Flush out the existing search/sort result if (aIterationLimit > 0 && aResultType == EMsvResultAsTMsvId) // Iteration limit is one and result type is TMsvId { for(TInt index = 0; index < resultCount; ++index) { iSharedDataCommon.iSearchSortOperation->GetNextResultL(messageId); // Get the corresponding index entry and append the same to array of entries. iSharedDataCommon.iSession->GetEntry(messageId, serviceId, messageEntry); iSharedDataCommon.iSearchSortResultArray.Append(messageEntry); } } else if(aIterationLimit > 0 && aResultType == EMsvResultAsTMsvEntry) // Iteration limit is one and result type is TMsvEntry { for(TInt index = 0; index < resultCount; ++index) { iSharedDataCommon.iSearchSortOperation->GetNextResultL(messageEntry); iSharedDataCommon.iSearchSortResultArray.Append(messageEntry); } } else if (aIterationLimit == 0 && aResultType == EMsvResultAsTMsvId) // No iteration and result type is TMsvId { RArray<TMsvId> idArray; TRAPD(error, iSharedDataCommon.iSearchSortOperation->GetResultsL(idArray)); if(error == KErrNone) { // Get the corresponding index entries and create an array of entries. for(TInt index = 0; index < idArray.Count(); ++index) { iSharedDataCommon.iSession->GetEntry(idArray[index], serviceId, messageEntry); iSharedDataCommon.iSearchSortResultArray.Append(messageEntry); } } else { SetTestStepError(error); } } else // No iteration and result type is TMsvEntry { // RArray<TMsvEntry> entryArray; TRAPD(error, iSharedDataCommon.iSearchSortOperation->GetResultsL(iSharedDataCommon.iSearchSortResultArray)); SetTestStepError(error); } // Ensure Number of Entries in iSharedDataCommon.iSearchSortResultArray is same as the result count if(iSharedDataCommon.iSearchSortResultArray.Count() != resultCount) { ERR_PRINTF1(_L("MisMatch in Result count and Entries retrieved")); ERR_PRINTF3(_L("Search-sort result count= %d Entries retrieved= %d"), resultCount, iSharedDataCommon.iSearchSortResultArray.Count()); SetTestStepResult(EFail); } }
/** Base class pure virtual. @return EPass or EFail indicating the result of the test step. */ TVerdict CTestCalInterimApiDeleteEntryByTimeRange::doTestStepL() { TPtrC startTime; TPtrC endTime; TInt filter; TPtrC timeMode; TESTL( GetStringFromConfig(ConfigSection(), KFilterStartDateTime, startTime) ); TESTL( GetStringFromConfig(ConfigSection(), KFilterEndDateTime, endTime) ); TESTL( GetIntFromConfig(ConfigSection(), KFilterType, filter) ); // Dont mind if it is not given in the ini file GetStringFromConfig(ConfigSection(), KTimeMode, timeMode); CCalEntryView* entryView = CCalEntryView::NewL(GetSession(), *this); CleanupStack::PushL(entryView); CActiveScheduler::Start(); // To convert TPtrc to TTime TTime filterStartDateTime; filterStartDateTime.Set(startTime); TTime filterEndDateTime; filterEndDateTime.Set(endTime); // To change TTime as TCalTime TCalTime calStartDateTime; // Sets the time mode to floating or Utc based on the time mode given SetCalTimeL(filterStartDateTime, calStartDateTime, SetTimeMode(timeMode)); TCalTime calEndDateTime; SetCalTimeL(filterEndDateTime, calEndDateTime, SetTimeMode(timeMode)); CalCommon::TCalTimeRange calTimeRange(calStartDateTime, calEndDateTime); TInt numOfTimes(0); do {// When we run multiple instances of this test step concurrently // for testing asynchronous operations, the server returns KErrServerBusy. // If so we try again and again SetTestStepError(KErrNone); entryView->DeleteL(calTimeRange, CalCommon::TCalViewFilter(filter), *this); CActiveScheduler::Start(); ++numOfTimes; //If any error occurs, step result is set to EFail in Completed() //If this is not done then later when test finishes without any error, Test will still fail. if(TestStepError() == KErrLocked) { SetTestStepResult(EPass); } } while((TestStepError() == KErrServerBusy || TestStepError()== KErrLocked) && numOfTimes < 40); CleanupStack::PopAndDestroy(entryView); if(TestStepError() == KErrServerBusy || TestStepError()== KErrLocked) { SetTestStepError(KErrNone); SetTestStepResult(EPass); } return TestStepResult(); }
/** Function : doTestStepL Description : Get the count of message entries satisfying serach-sort criteria and get the entries. @return : TVerdict - Test step result */ TVerdict CT_MsgSearchSortByQueryObject::doTestStepL() { INFO_PRINTF1(_L("Test Step : SearchSortByQueryObject")); // Read query marking option TBool markQuery = EFalse; GetBoolFromConfig(ConfigSection(), KMarkQuery, markQuery); markQuery ? INFO_PRINTF1(_L("Query is marked")) : INFO_PRINTF1(_L("Query is to not marked")); // Read the iteration limit for getting the results TInt iteratorLimit = 0; GetIntFromConfig(ConfigSection(), KIteratorLimit, iteratorLimit); // Execute the search/sort request iSharedDataCommon.iSearchSortOperation = CMsvSearchSortOperation::NewL(*iSharedDataCommon.iSession); CT_MsgActive& active=Active(); TRAPD(err, iSharedDataCommon.iSearchSortOperation->RequestL(iSharedDataCommon.iSearchSortQuery, markQuery, active.iStatus, iteratorLimit)); if(err == KErrNone) { active.Activate(); CActiveScheduler::Start(); //Check Search/Sort operation for errors TInt error = active.Result(); if (error != KErrNone) { ERR_PRINTF2(_L("Search/Sort request failed with %d error"), error); SetTestStepError(error); } else { // Get the query ID for the above search/sort request TInt quryId = iSharedDataCommon.iSearchSortOperation->GetQueryIdL(); TBool isRepetitionRequired = EFalse; GetBoolFromConfig(ConfigSection(), KIsRepetitionRequired, isRepetitionRequired); // Save the query ID to INI file isRepetitionRequired ? WriteIntToConfig(ConfigSection(), KRepeatedQueryID, quryId):WriteIntToConfig(ConfigSection(), KLastQueryID, quryId); TBool resInTMsvEntry = EFalse; GetBoolFromConfig(ConfigSection(), KResultAsTMsvEntry, resInTMsvEntry); TMsvSearchSortResultType resultType = EMsvResultAsTMsvId; if(resInTMsvEntry) { resultType = EMsvResultAsTMsvEntry; } RetriveSearchSortResultL(iteratorLimit, resultType); } } else { SetTestStepError(err); } return TestStepResult(); }
/** Function : doTestStepL Description : Get the count of message entries satisfying serach-sort criteria. @return : TVerdict - Test step result */ TVerdict CT_MsgSearchSortResultByQueryId::doTestStepL() { INFO_PRINTF1(_L("Test Step : SearchSortResultByQueryId")); TInt queryId = 0; if(!GetIntFromConfig(ConfigSection(), KRepeatedQueryID, queryId)) { ERR_PRINTF1(_L("Can not find any Query ID for Execution")); SetTestStepResult(EFail); } else { // Set the preferred result type flag, default value is TMsvId TBool resInTMsvEntry = EFalse; GetBoolFromConfig(ConfigSection(), KResultAsTMsvEntry, resInTMsvEntry); TMsvSearchSortResultType resultType = EMsvResultAsTMsvId; if(resInTMsvEntry) { resultType = EMsvResultAsTMsvEntry; } // Set the iteration limit for getting the results TInt iteratorLimit = 0; GetIntFromConfig(ConfigSection(), KIteratorLimit, iteratorLimit); // Execute the search/sort request iSharedDataCommon.iSearchSortOperation = CMsvSearchSortOperation::NewL(*iSharedDataCommon.iSession); CT_MsgActive& active=Active(); TRAPD(err, iSharedDataCommon.iSearchSortOperation->RequestL(queryId, active.iStatus, iteratorLimit)); if(err == KErrNone) { active.Activate(); CActiveScheduler::Start(); //Check Search/Sort operation for errors TInt error = active.Result(); if (error != KErrNone) { ERR_PRINTF2(_L("Search/Sort request failed with %d error"), error); SetTestStepError(error); } else { RetriveSearchSortResultL(iteratorLimit, resultType); } } else { SetTestStepError(err); } } return TestStepResult(); }
/** Checks that all properties are defined correctly and deletes them. @return KErrNone if successfull, error code - otherwise. */ TInt CTe_LbsSuplPushApiPropsStep::CheckProps() { TInt err = RProperty::Delete(KLbsSuplPushSmsBusyKey); if (err==KErrNone) { err = RProperty::Delete(KLbsSuplPushSmsInitKey); } if (err==KErrNone) { err = RProperty::Delete(KLbsSuplPushSmsAckKey); } if (err==KErrNone) { err = RProperty::Delete(KLbsSuplPushWapBusyKey); } if (err==KErrNone) { err = RProperty::Delete(KLbsSuplPushWapInitKey); } if (err==KErrNone) { err = RProperty::Delete(KLbsSuplPushWapAckKey); } if(err!=KErrNone) { SetTestStepError(err); SetTestStepResult(EFail); } return err; }
/** Override of the base class pure virtual function. Contains the test code to run. Our implementation only gets called if the base class doTestStepPreambleL() did not leave. That being the case, the current test result value will be EPass. This test step simulates the errors of the RProperty::Define calls. @return - The result of the test @leave If a error happens, it leaves with one of the system error codes. @see CTestStep::doTestStepL */ TVerdict CTe_LbsSuplPushApiPropsErrorStep::doTestStepL() { TInt count=1; do { RTe_LbsSuplErrorPattern::Reset(); RTe_LbsSuplErrorPattern::AppendNextErrorL(Te_LbsSuplErrorId::ERProperty_Define, count, KErrGeneral, EFalse); CTe_LbsSuplPushApiPropsStep::doTestStepPreambleL(); TRAPD(err, LbsSuplPushProps::InitializeL()); if(RTe_LbsSuplErrorPattern::ErrorReached()==1 && err!=KErrGeneral) { SetTestStepResult(EFail); SetTestStepError(err); return TestStepResult(); } count++; } while(RTe_LbsSuplErrorPattern::ErrorReached()==1); SetTestStepResult(EPass); return TestStepResult(); }
void CTestCalInterimApiSuiteStepBase::Completed(TInt aError) { if ( aError != KErrNone ) { ERR_PRINTF2(KErrCompleted, aError); SetTestStepResult(EFail); SetTestStepError(aError); } CActiveScheduler::Stop(); }
/** @SYMTestCaseID PIM-APP-ENGINES-CALINTERIMAPI-CIT-1098AP-13 @SYMTestType CIT @SYMTestPriority Medium @SYMPREQ 1098 @SYMFssID 3.2.1 002, 003, 006, 013 @SYMTestCaseDesc Creates and opens an calendar file on C:\ @SYMTestActions Conditionally create a new calendar File, and then open it @SYMTestExpectedResults CCalSession will create and open a new calendar file */ void CTestCalInterimApiSuiteStepBase::CreateAndOpenCalenderFileL(const TDesC& aFileName, TBool aCreateFile) { iCalenderFileName = aFileName; if ( (TestStepResult() == EPass) && (aCreateFile) ) { TRAPD(err, iSession->CreateCalFileL(iCalenderFileName)); switch ( err ) { case KErrNone: break; case KErrAlreadyExists: // In concurrent execution tests, it might turn out that another // thread has already deleted, when we try to delete, or another // thread might try to create when we have already created. We // ignore these errors. Any other error is propogated TRAPD(deleteErr, iSession->DeleteCalFileL(iCalenderFileName)); TRAPD(createErr, iSession->CreateCalFileL(iCalenderFileName)); if(deleteErr != KErrNotFound && createErr != KErrAlreadyExists) { User::LeaveIfError(deleteErr); User::LeaveIfError(createErr); } break; default: ERR_PRINTF2(KErrInCreateCalFileL, err); SetTestStepResult(EFail); SetTestStepError(err); } } if ( TestStepResult() == EPass ) { TRAPD(err, iSession->OpenL(iCalenderFileName)); if( err != KErrNone ) { ERR_PRINTF2(KErrInOpenL, err); SetTestStepResult(EFail); SetTestStepError(err); } } }
TVerdict CSocketSetOptionStep::doSingleTestStep() { TRequestStatus requestStatus; TBuf8<256> inputBuffer; inputBuffer.Copy(iParams.iOptionToSetText); TInt inputValue = iParams.iOptionToSetValue; TInt error; if(iParams.iTextSet) { error = iEsockTest->SetOptSocket(iParams, inputBuffer); } else { error = iEsockTest->SetOptSocket(iParams, inputValue); } if (error != KErrNone) { INFO_PRINTF3(_L("Socket set option error. socket:%S, error:%d"), &iParams.iSocketName, error); SetTestStepError(error); return EFail; } if(iParams.iTextSet) { // Convert the output to wide chars TBuf<256> inputConvertedToWideChars; CnvUtfConverter::ConvertToUnicodeFromUtf8(inputConvertedToWideChars, inputBuffer); // Log what was returned INFO_PRINTF2(_L("Socket set with opt text. value:%S"), &inputConvertedToWideChars); INFO_PRINTF2(_L("Text set by user. value:%S"), &iParams.iOptionToSetText); // Validate the output with that expected TVerdict verdict = (inputConvertedToWideChars == iParams.iOptionToSetText) ? EPass : EFail; SetTestStepResult(verdict); } else { // Log what was returned INFO_PRINTF2(_L("Socket returned get opt value. value:%d"), inputValue); INFO_PRINTF2(_L("Value set by user. value:%d"), iParams.iOptionToSetValue); // Validate the output with that expected TVerdict verdict = (inputValue == iParams.iOptionToSetValue) ? EPass : EFail; SetTestStepResult(verdict); } // Return the result return TestStepResult(); }
TVerdict COpenRSocketStep::doSingleTestStep() { TInt error = iEsockTest->OpenSocket(iParams); if (error!=KErrNone) { INFO_PRINTF2(_L("Could not open socket (%S)."),&iParams.iSocketName); INFO_PRINTF2(_L("Error: %d."),error); SetTestStepError(error); return EFail; } return EPass; }
TVerdict CSendReceiveRSocketStep::doSingleTestStep() { TRAPD(error,iEsockTest->SendAndReceiveDataL(iParams)); SetTestStepError(error); if (error!=KErrNone) { INFO_PRINTF2(_L("Could not send/receive on socket (%S)."),&iParams.iSocketName); INFO_PRINTF2(_L("Error: %d."),error); return EFail; } return EPass; }
/** * Create or open the contact database * @param aDbName database to be created/opened * @return CContactDatabase* */ CContactDatabase* CTestContactViewDatabaseUtilitiesStep::CreateAndOpenDataBaseL(const TPtrC& aDbName, TBool aCreateDataBase) { HBufC* dbName = HBufC::NewLC(aDbName.Length()); dbName->Des().Copy(aDbName); CContactDatabase* cntDb = NULL; if( aCreateDataBase ) { TInt err = 0; // Replace the existing database and opens it if( aDbName != KNullDesC() ) { TRAP(err, cntDb = CContactDatabase::ReplaceL(dbName->Des())); } else //if database name is not given then create and open the default DB { TRAP(err, cntDb = CContactDatabase::ReplaceL()); } if( err != KErrNone ) { ERR_PRINTF2(KErrInCreateDataBase, err); SetTestStepResult(EFail); SetTestStepError(err); } } else { TRAPD(err, cntDb = CContactDatabase::OpenL(dbName->Des())); if( err != KErrNone ) { ERR_PRINTF2(KErrInOpen, err); SetTestStepResult(EFail); SetTestStepError(err); } } CleanupStack::PopAndDestroy(dbName); return cntDb; }
/** Override of the base class pure virtual function. Contains the test code to run. This test step defines the props when they all are deleted and then again, when they all are defined. In both cases the function must succeed and the properties must be defined correctly. @return - The result of the test @leave If a error happens, it leaves with one of the system error codes. @see CTestStep::doTestStepL */ TVerdict CTe_LbsSuplPushApiPropsStep::doTestStepL() { TRAPD(err, LbsSuplPushProps::InitializeL()); if(err!=KErrNone) { SetTestStepResult(EFail); SetTestStepError(err); return TestStepResult(); } //Check that the properties are defined if (CheckProps()!=KErrNone) { return TestStepResult(); } //Define all props again TRAP(err, LbsSuplPushProps::InitializeL()); if(err!=KErrNone) { SetTestStepResult(EFail); SetTestStepError(err); return TestStepResult(); } //Try to define alreafy existing props TRAP(err, LbsSuplPushProps::InitializeL()); if(err!=KErrNone) { SetTestStepResult(EFail); SetTestStepError(err); return TestStepResult(); } //Check that the properties are defined CheckProps(); return TestStepResult(); }
/** doTestStepL() It establishes connection with the Pop server using a POP account. The account is identified by the account name that is read from the INI file. @return Returns the test step result */ TVerdict CT_MsgConnectPop3Server::doTestStepL() { INFO_PRINTF1(_L(" Test Step : ConnectPop3Server")); TPtrC popAccountName; if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName)) { ERR_PRINTF1(_L("Pop Account Name is not specified")); SetTestStepResult(EFail); } else { // Retrieving the Pop service Id for the given Pop account TMsvId popServiceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)popAccountName); INFO_PRINTF2(_L("Pop service id is %d"),popServiceId); // Change the current context iSharedDataPOP.iMtm->SwitchCurrentEntryL(popServiceId); CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(selection); // Appends the popServiceId onto the end of the array selection->AppendL(popServiceId); TBuf8<KMaxLenghtOfChar> param; CT_MsgActive& active=Active(); // Attempts to connect to the Pop3 Service iOperation = iSharedDataPOP.iMtm->InvokeAsyncFunctionL(KPOP3MTMConnect,*selection,param, active.iStatus); active.Activate(); CActiveScheduler::Start(); // Get the error code from TPop3Progress TPop3Progress temp; TPckgC<TPop3Progress> paramPack(temp); paramPack.Set(iOperation->ProgressL()); TPop3Progress progress=paramPack(); SetTestStepError(progress.iErrorCode); delete iOperation; iOperation=NULL; CleanupStack::PopAndDestroy(selection); //operation,selection // User::LeaveIfError(active.Result()); } return TestStepResult(); }
TVerdict CSampleStep4::doTestStepL() /** * @return - TVerdict code * Override of base class pure virtual * Demonstrates reading configuration parameters fom an ini file section */ { INFO_PRINTF1(_L("In Test Step of SampleStep4")); TDriveName scriptDrive(ScriptDriveName()); INFO_PRINTF2(_L("The Drive where script file is executed from is %S"), &scriptDrive); SetTestStepError(-43); SetTestStepResult(EPass); return TestStepResult(); }
/** Function : doTestStepL Description : Reads the Imap account name, folder name ,the entry name from the ini file. It the then searches for the given entry under the specified folder. The test passes if the entry is found else it fail. @return : TVerdict - Test step result */ TVerdict CT_MsgFindEntryByName::doTestStepL() { INFO_PRINTF1(_L(" TestStep : FindEntryByName")); /* Reads the IMAP account name from the ini file */ TPtrC imapAccountName; if(!GetStringFromConfig( ConfigSection(), KImapAccountName, imapAccountName)) { ERR_PRINTF1(_L("Imap Account Name is not specified")); SetTestStepResult(EFail); } else { /* Retrieves the IMAP service Id for the given IMAP account */ TMsvId imapServiceId = CT_MsgUtilsCentralRepository::GetImapServiceIdL((TDes&)imapAccountName); INFO_PRINTF2(_L("Imap service id is %d"),imapServiceId); /* Reads the name of the remote folder from the ini file */ TPtrC folderName; if(!GetStringFromConfig( ConfigSection(), KFolderName, folderName)) { ERR_PRINTF1(_L("Remote Parent Folder name is not specified")); SetTestStepResult(EFail); } else { /* Reads the entry name that is to be verified from the ini file */ TPtrC entryName; if(!GetStringFromConfig( ConfigSection(), KEntryName, entryName)) { ERR_PRINTF1(_L("Entry name to search is not specified")); SetTestStepResult(EFail); } else { TBool caseSensitive = EFalse; GetBoolFromConfig(ConfigSection(), KCaseSensitive, caseSensitive); /* Gets the Id of the given entry to be searched */ TMsvId entryId; TRAPD(err,entryId = CT_MsgUtils::GetRemoteFolderIdByNameL(iSharedDataIMAP.iSession,imapAccountName,entryName,folderName,caseSensitive)); INFO_PRINTF2(_L(" The entry Id is %d"),entryId); SetTestStepError(err); } } } return TestStepResult(); }
/** Checks for any field that should have not been exported @param aFile The vcs file to open */ TBool CTestCompareCntFiles::CheckForNoFieldL(const TDesC& aFile, const TDesC& aProperty) { RFile fileOutput; CleanupClosePushL(fileOutput); TInt err = fileOutput.Open(iFsSession, aFile, EFileRead); if (err != KErrNone) { ERR_PRINTF2(_L("Unable to open file: %S"), &aFile); SetTestStepResult(EFail); SetTestStepError(err); } RFileReadStream streamOutput(fileOutput); CleanupClosePushL(streamOutput); TBuf8<0x80> bufOutput; TBool result; TBuf8<KMaxLengthField> noField; noField.Copy(aProperty); do { TRAP(err, streamOutput.ReadL(bufOutput, TChar(KLinefeedChar))); result = IsPropertyPresent(bufOutput, noField); if(result) { break; } } while (err != KErrEof); CleanupStack::PopAndDestroy(2, &fileOutput); if(result) { return EFalse; } else { return ETrue; } }
/** Base class pure virtual. @return EPass or EFail indicating the result of the test step. @test */ TVerdict CTestCalInterimApiTZChange::doTestStepL() { TESTL(TestStepResult() == EPass); INFO_PRINTF1(_L("CTestCalInterimApiTZChange::doTestStepL() start")); iInstanceView = CCalInstanceView::NewL(GetSession(), *this); iField = KIsFloating; TESTL(GetBoolFromConfig(ConfigSection(), iField, iIsFloating)); CActiveScheduler::Start(); SetTimeRangeL(); CalCommon::TCalViewFilter filter = CalCommon::EIncludeAll; CalCommon::TCalTimeRange timeRange(iStartDate, iEndDate); RPointerArray<CCalInstance> fetchInstanceArray; CleanupStack::PushL(TCleanupItem(ResetAndDestroyInstanceArray, &fetchInstanceArray)); TRAPD(err, iInstanceView->FindInstanceL(fetchInstanceArray, filter, timeRange)); if (err == KErrNone) { for ( TInt index = 0; index < fetchInstanceArray.Count(); index++ ) { INFO_PRINTF2(_L("Instance:- %d"), index); CheckInstancesTimesL(fetchInstanceArray, index); } INFO_PRINTF1(KInstanceTimesCorrect); CheckEntryTimesL(fetchInstanceArray); } else { ERR_PRINTF1(_L("Instances not fetched successfully")); SetTestStepResult(EFail); SetTestStepError(err); } CleanupStack::PopAndDestroy(&fetchInstanceArray); // fetchInstanceArray.reset & fetchInstanceArray.destroy; INFO_PRINTF1(_L("CTestCalInterimApiTZChange::doTestStepL() finish")); return TestStepResult(); }
/** Check the GEO Property value stored in entry, with expected GEO Property value @param aCalEntry Pointer to CCalEntry @param aGeoLat Expected GEO latitude value @param aGeoLong Expected GEO longitude value */ void CTestCalInterimApiFetchEntryAndCheckData::CheckGEOPropertyL(CCalEntry* aCalEntry, const TDesC& aGeoLat, const TDesC& aGeoLong) { CCalGeoValue* geoValue = NULL; TRAPD(err, geoValue = aCalEntry->GeoValueL()); if (err != KErrNone) { ERR_PRINTF2(_L("GeoValuesL Error Code %d"), err); SetTestStepResult(EFail); SetTestStepError(err); } else { CleanupStack::PushL(geoValue); } TReal lat = 0.0; TReal longitude = 0.0; TBool hasGEO = geoValue->GetLatLong(lat,longitude); TESTL(hasGEO); TLex lex(aGeoLat); TReal expectLat = 0.0; lex.Val(expectLat); TLex lex1(aGeoLong); TReal expectLong = 0.0; lex1.Val(expectLong); INFO_PRINTF5(KExpectedAndFoundGEO, expectLat, lat, expectLong, longitude); TEST1(lat == expectLat, ETrue); TEST1(longitude == expectLong, ETrue); if (err == KErrNone) { CleanupStack::PopAndDestroy(geoValue); } }
/** Compares 2 vcf fie @param aExpectedFile The expected vcf file @param aFile This is the vcf file produced, and will be compared against aExpectedFile @param aProperty This is the property we are interested in */ void CTestCompareCntFiles::CompareFileL(const TDesC& aExpectedFile, const TDesC& aFile, TDes8& aProperty) { RFile fileExpected; RFile fileOutput; CleanupClosePushL(fileExpected); CleanupClosePushL(fileOutput); TInt err = KErrNone; err = fileExpected.Open(iFsSession, aExpectedFile, EFileRead); if (err != KErrNone) { ERR_PRINTF2(_L("Unable to open file: %S"), &aExpectedFile); SetTestStepResult(EFail); SetTestStepError(err); } err = fileOutput.Open(iFsSession, aFile, EFileRead); if (err != KErrNone) { ERR_PRINTF2(_L("Unable to open file: %S"), &aFile); SetTestStepResult(EFail); SetTestStepError(err); } RFileReadStream streamExpected(fileExpected); RFileReadStream streamOutput(fileOutput); CleanupClosePushL(streamExpected); CleanupClosePushL(streamOutput); TBuf8<0x80> bufExpected,bufOutput; TBool isProperty = EFalse; TBool isPropertyExpected = EFalse; TBool foundBothProperty = EFalse; TBool flag = EFalse; TInt err1 = KErrNone; do // This do loop iterates through both files, until the end of file is found { do // This do loop iterates thorugh both files until both properties are found and compares them { foundBothProperty = EFalse; if (!isProperty) { TRAP(err, streamExpected.ReadL(bufExpected, KLinefeedChar)); } if (!isPropertyExpected) { TRAP(err1, streamOutput.ReadL(bufOutput, KLinefeedChar)); } if (err != KErrEof || err1 != KErrEof) { isProperty = IsPropertyPresent(bufExpected, aProperty); // checks if aProperty if(isProperty && err1 == KErrEof) { break; } isPropertyExpected = IsPropertyPresent(bufOutput, aProperty); // checks if aProperty } else { break; } if ((isProperty) && (isPropertyExpected)) { foundBothProperty = ETrue; flag = ETrue; } } while (!foundBothProperty); // exit 2nd do loop when both properties found // Exists 2nd do loop, so both properties are found if (err != KErrEof && err1 != KErrEof) { if(aProperty != KRevision) { CompareLinesL(bufExpected, bufOutput); // compares both properties } else { break; } } // After comparing, gets the next property parameters in vcs file, if we have not reached end of file TRAP(err, streamExpected.ReadL(bufExpected, KLinefeedChar)); TRAP(err1, streamOutput.ReadL(bufOutput, KLinefeedChar)); } while (err != KErrEof || err1 != KErrEof); // exits 2nd do loop when its reached the end of either file TBuf<KMaxLengthField> buf; buf.Copy(aProperty); TPtrC ptr(buf); if(flag) { INFO_PRINTF2(_L("Property: %S Exported properly"), &ptr); } else { INFO_PRINTF2(_L("Property: %S not exported"), &ptr); SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(4, &fileExpected); }
/** Function : doTestStepL Description : Verify if message part(s) of the message entries returned by sort mechanism are in the intended order. @return : TVerdict - Test step result */ TVerdict CT_MsgVerifySortResult::doTestStepL() { INFO_PRINTF1(_L("Test Step : VerifySortResult")); TPtrC fieldName; TBuf<1> buf; TBool sortedByTo = ETrue; TBool sortedByFrom = ETrue; TBool sortedByCc = ETrue; TBool sortedByBcc = ETrue; TBool sortedBySubject = ETrue; TBool sortedByUnRead = ETrue; TBool sortedByDetails = ETrue; TBool sortedByDescription = ETrue; TBool sortedByDate = ETrue; TBool sortedBySize = ETrue; TBool sortedByAttachment = ETrue; TBool sortedByPriority = ETrue; TBool sortedById = ETrue; TBool sortedByNewFlag = ETrue; TInt expectedSearchResultCount = 0; GetIntFromConfig(ConfigSection(), KExpectedResultCount, expectedSearchResultCount); // Read search result count TInt resultCount = 0; GetIntFromConfig(ConfigSection(), KCountOfResult, resultCount); // Read search result count if(expectedSearchResultCount > 0 && resultCount == 0) { ERR_PRINTF2(_L("Expected SORT Result Count > 0 and Actual SORT result count = %d"), resultCount); SetTestStepResult(EFail); } else if(expectedSearchResultCount == 0 && resultCount == 0) { SetTestStepResult(EPass); } else { RArray<TMsvEntry> messageEntries = iSharedDataCommon.iSearchSortResultArray; INFO_PRINTF2(_L("Number of entries to be verified = %d"), messageEntries.Count()); DisplayMsgEntryList(messageEntries); // Log the message entry details if ( !GetStringFromConfig( ConfigSection(), KSortMsgPart, fieldName)) { ERR_PRINTF1(_L("Message part to be verified for is not specified")); SetTestStepResult (EFail); } TMsvMessagePart msgPartValue = CT_MsgUtilsEnumConverter::ConvertDesToMessagePart(fieldName); TPtrC sortOrder; GetStringFromConfig(ConfigSection(), KSortOrder, sortOrder); TMsvSortOrder sortOption = CT_MsgUtilsEnumConverter::ConvertDesToSortOrder(sortOrder); CMsvEntry *entry = CMsvEntry::NewL(*iSharedDataCommon.iSession, KMsvRootIndexEntryId, TMsvSelectionOrdering()); CleanupStack::PushL(entry); switch(msgPartValue) { case EMsvTo: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByTo; ++j) { entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header HBufC* address1=HBufC::NewL(50); if(header1->ToRecipients().Count()) { address1 = (header1->ToRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store1); entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header HBufC* address2=HBufC::NewL(50); // FIx when no fields are there if(header2->ToRecipients().Count()) { address2 = (header2->ToRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store2); if(address1->CompareF(*address2) > 0)// Checks if any messages is not in Ascending order w.r.t to TO field { ERR_PRINTF1(_L("Sorting by TO: Not in Ascending order")); sortedByTo = EFalse; SetTestStepResult(EFail); } delete address2; delete address1; } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByTo; ++j) { entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header HBufC* address1=HBufC::NewL(50); if(header1->ToRecipients().Count()) { address1 = (header1->ToRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store1); entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header HBufC* address2=HBufC::NewL(50); // FIx when no fields are there if(header2->ToRecipients().Count()) { address2 = (header2->ToRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store2); if(address1->CompareF(*address2) < 0)// Checks if any messages is not in Descending order w.r.t to TO field { ERR_PRINTF1(_L("Sorting by TO: Not in Descending order")); sortedByTo = EFalse; SetTestStepResult(EFail); } delete address2; delete address1; } break; } break; case EMsvFrom: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByFrom; ++j) { entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header HBufC* address1 = header1->From().AllocL(); CleanupStack::PopAndDestroy(2,store1); entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header HBufC* address2 = header2->From().AllocL(); CleanupStack::PopAndDestroy(2,store2); if(address1->CompareF(*address2) > 0)// Checks if any messages is not in Ascending order w.r.t to FROM field { ERR_PRINTF1(_L("Sorting by From: Not in Ascending order")); sortedByFrom = EFalse; SetTestStepResult(EFail); } delete address2; delete address1; } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByFrom; ++j) { entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header HBufC* address1 = header1->From().AllocL(); CleanupStack::PopAndDestroy(2,store1); entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header HBufC* address2 = header2->From().AllocL(); CleanupStack::PopAndDestroy(2,store2); if(address1->CompareF(*address2) < 0)// Checks if any messages is not in Descending order w.r.t to FROM field { ERR_PRINTF1(_L("Sorting by From: Not in Descending order")); sortedByFrom = EFalse; SetTestStepResult(EFail); } delete address2; delete address1; } break; } break; case EMsvCc: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByCc; ++j) { HBufC* address1 = HBufC::NewL(50); entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header if(header1->CcRecipients().Count()) { address1 = (header1->CcRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store1); HBufC* address2 = HBufC::NewL(50); entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header if(header2->CcRecipients().Count()) { address2 = (header2->CcRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store2); if(address1->CompareF(*address2) > 0)// Checks if any messages is not in Ascending order w.r.t to CC field { ERR_PRINTF1(_L("Sorting by CC: Not in Ascending order")); sortedByCc = EFalse; SetTestStepResult(EFail); } delete address2; delete address1; } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByCc; ++j) { HBufC* address1 = HBufC::NewL(50); entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header if(header1->CcRecipients().Count()) { address1 = (header1->CcRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store1); HBufC* address2 = HBufC::NewL(50); entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header if(header2->CcRecipients().Count()) { address2 = (header2->CcRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store2); if(address1->CompareF(*address2) < 0)// Checks if any messages is not in Descending order w.r.t to CC field { ERR_PRINTF1(_L("Sorting by CC: Not in Descending order")); sortedByCc = EFalse; SetTestStepResult(EFail); } delete address2; delete address1; } break; } break; case EMsvBcc: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByBcc; ++j) { HBufC* address1 = HBufC::NewL(50); if(messageEntries[j].iMtm != KUidMsgTypeSMS) { entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header if(header1->BccRecipients().Count()) { address1 = (header1->BccRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store1); } else { buf.Copy(_L("")); address1 = buf.AllocL(); } HBufC* address2 = HBufC::NewL(50); if(messageEntries[j+1].iMtm != KUidMsgTypeSMS) { entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header if(header2->BccRecipients().Count()) { address2 = (header2->BccRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store2); } else { buf.Copy(_L("")); address2 = buf.AllocL(); } if(address1->CompareF(*address2) > 0)// Checks if any messages is not in Ascending order w.r.t to BCC field { ERR_PRINTF1(_L("Sorting by BCC: Not in Ascending order")); sortedByBcc = EFalse; SetTestStepResult(EFail); } delete address2; delete address1; } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByBcc; ++j) { HBufC* address1 = HBufC::NewL(50); if(messageEntries[j].iMtm != KUidMsgTypeSMS) { entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header if(header1->BccRecipients().Count()) { address1 = (header1->BccRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store1); } else { buf.Copy(_L("")); address1 = buf.AllocL(); } HBufC* address2 = HBufC::NewL(50); if(messageEntries[j].iMtm != KUidMsgTypeSMS) { entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header if(header2->BccRecipients().Count()) { address2 = (header2->BccRecipients()[0]).AllocL(); } CleanupStack::PopAndDestroy(2,store2); } else { buf.Copy(_L("")); address2 = buf.AllocL(); } if(address1->CompareF(*address2) < 0)// Checks if any messages is not in Descending order w.r.t to BCC field { ERR_PRINTF1(_L("Sorting by BCC: Not in Descending order")); sortedByBcc = EFalse; SetTestStepResult(EFail); } delete address2; delete address1; } break; } break; case EMsvSubject: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedBySubject; ++j) { entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header HBufC* subject1 = header1->Subject().AllocL(); CleanupStack::PopAndDestroy(2,store1); entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header HBufC* subject2 = header2->Subject().AllocL(); CleanupStack::PopAndDestroy(2,store2); if(subject1->CompareF(*subject2) > 0)// Checks if any messages is not in Ascending order w.r.t to SUBJECT field { ERR_PRINTF1(_L("Sorting by Subject: Not in Ascending order")); sortedBySubject = EFalse; SetTestStepResult(EFail); } delete subject2; delete subject1; } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedBySubject; ++j) { entry->SetEntryL(messageEntries[j].Id()); CMsvStore* store1 = entry->ReadStoreL(); CleanupStack::PushL(store1); CImHeader* header1 = CImHeader::NewLC(); header1->RestoreL(*store1); // Retrieves the email message header entry->SetEntryL(messageEntries[j+1].Id()); CMsvStore* store2 = entry->ReadStoreL(); CleanupStack::PushL(store2); CImHeader* header2 = CImHeader::NewLC(); header2->RestoreL(*store2); // Retrieves the email message header if(header1->Subject().CompareF(header2->Subject()) < 0)// Checks if any messages is not in Descending order w.r.t to SUBJECT field { ERR_PRINTF1(_L("Sorting by Subject: Not in Descending order")); sortedBySubject = EFalse; SetTestStepResult(EFail); } CleanupStack::PopAndDestroy(4, store1); } break; } break; case EMsvUnreadMessages: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByUnRead; ++j) { if(messageEntries[j].Unread() > messageEntries[j+1].Unread()) // Checks if any messages is not in Ascending order { ERR_PRINTF1(_L("Sorting by UnReadFlag: Not in Ascending order")); sortedByUnRead = EFalse; SetTestStepResult(EFail); } } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByUnRead; ++j) { if(messageEntries[j].Unread() < messageEntries[j+1].Unread()) // Checks if any messages is not in Descending order { ERR_PRINTF1(_L("Sorting by UnReadFlag: Not in Descending order")); sortedByUnRead = EFalse; SetTestStepResult(EFail); } } } break; case EMsvDetails: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDetails; ++j) { if(messageEntries[j].iDetails.CompareF(messageEntries[j+1].iDetails) > 0)// Checks if any messages is not in Ascending order { ERR_PRINTF1(_L("Sorting by Details: Not in Ascending order")); sortedByDetails = EFalse; SetTestStepResult(EFail); } } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDetails; ++j) { if(messageEntries[j].iDetails.CompareF(messageEntries[j+1].iDetails) < 0) // Checks if any messages is not in Descending order { ERR_PRINTF1(_L("Sorting by Details: Not in Descending order")); sortedByDetails = EFalse; SetTestStepResult(EFail); } } } break; case EMsvDescription: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDescription; ++j) { if(messageEntries[j].iDescription.CompareF(messageEntries[j+1].iDescription) > 0)// Checks if any messages is not in Ascending order { ERR_PRINTF1(_L("Sorting by Description: Not in Ascending order")); sortedByDescription = EFalse; SetTestStepResult(EFail); } } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDescription; ++j) { if(messageEntries[j].iDescription.CompareF(messageEntries[j+1].iDescription) < 0) // Checks if any messages is not in Descending order { ERR_PRINTF1(_L("Sorting by Description: Not in Descending order")); sortedByDescription = EFalse; SetTestStepResult(EFail); } } } break; case EMsvDate: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDate; ++j) { if(messageEntries[j].iDate > messageEntries[j+1].iDate) // Checks if any messages is not in Ascending order { ERR_PRINTF1(_L("Sorting by Date: Not in Ascending order")); sortedByDate = EFalse; SetTestStepResult(EFail); } } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByDate; ++j) { if(messageEntries[j].iDate < messageEntries[j+1].iDate) // Checks if any messages is not in Descending order { ERR_PRINTF1(_L("Sorting by Date: Not in Descending order")); sortedByDate = EFalse; SetTestStepResult(EFail); } } } break; case EMsvSize: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedBySize; ++j) { if(messageEntries[j].iSize > messageEntries[j+1].iSize) // Checks if any messages is not in Ascending order { ERR_PRINTF1(_L("Sorting by Size: Not in Ascending order")); sortedBySize = EFalse; SetTestStepResult(EFail); } } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedBySize; ++j) { if(messageEntries[j].iSize < messageEntries[j+1].iSize) // Checks if any messages is not in Descending order { ERR_PRINTF1(_L("Sorting by Size: Not in Descending order")); sortedBySize = EFalse; SetTestStepResult(EFail); } } } break; case EMsvAttachment: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByAttachment; ++j) { if(messageEntries[j].Attachment() > messageEntries[j+1].Attachment()) // Checks if any messages is not in Ascending order { ERR_PRINTF1(_L("Sorting by AttachmentFlag: Not in Ascending order")); sortedByAttachment = EFalse; SetTestStepResult(EFail); } } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByAttachment; ++j) { if(messageEntries[j].Attachment() < messageEntries[j+1].Attachment()) // Checks if any messages is not in Descending order { ERR_PRINTF1(_L("Sorting by AttachmentFlag: Not in Descending order")); sortedByAttachment = EFalse; SetTestStepResult(EFail); } } } break; case EMsvNew: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByNewFlag; ++j) { if(messageEntries[j].New() < messageEntries[j+1].New()) // Checks if any messages is not in Ascending order { ERR_PRINTF1(_L("Sorting by NewFlag: Not in Ascending order")); sortedByNewFlag = EFalse; SetTestStepResult(EFail); } } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByNewFlag; ++j) { if(messageEntries[j].New() > messageEntries[j+1].New()) // Checks if any messages is not in Descending order { ERR_PRINTF1(_L("Sorting by NewFlag: Not in Descending order")); sortedByNewFlag = EFalse; SetTestStepResult(EFail); } } } break; case EMsvBody: SetTestStepError(KErrNotSupported); break; case EMsvPriority: switch(sortOption) { case EMsvSortAscending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByPriority; ++j) { if(messageEntries[j].Priority() < messageEntries[j+1].Priority()) // Checks if any messages is not in Ascending order { ERR_PRINTF1(_L("Sorting by AttachmentFlag: Not in Ascending order")); sortedByPriority = EFalse; SetTestStepResult(EFail); } } break; case EMsvSortDescending: for(TInt j = 0; j < messageEntries.Count() - 1 && sortedByPriority; ++j) { if(messageEntries[j].Priority() > messageEntries[j+1].Priority()) // Checks if any messages is not in Descending order { ERR_PRINTF1(_L("Sorting by AttachmentFlag: Not in Descending order")); sortedByPriority = EFalse; SetTestStepResult(EFail); } } } break; case EMsvMtmTypeUID: break; } CleanupStack::PopAndDestroy(1, entry); } return TestStepResult(); }
/** Function : doTestStepL Description : Reads the name of the IMAP account and the folder name to be synchronised from the ini file. Synchronises the current folder that is selected on the remote server. @return : TVerdict - Test step result @leave : KMsvNullIndexEntryId Invalid IMAP account name specified. Invalid Remote Folder name specified. */ TVerdict CT_MsgImap4Synchronisation::doTestStepL() { INFO_PRINTF1(_L("Test Step : Imap4Synchronisation ")); /* Reads the name of the IMAP account */ TPtrC imapAccountName; if(!GetStringFromConfig( ConfigSection(), KImapAccountName, imapAccountName)) { ERR_PRINTF1(_L("Imap Account Name is not specified")); SetTestStepResult(EFail); } else { /* Retrieves the Imap service Id for the given Imap account */ TMsvId imapServiceId = CT_MsgUtilsCentralRepository::GetImapServiceIdL((TDes&)imapAccountName); INFO_PRINTF2(_L("Imap service id is %d"),imapServiceId ); /* Fails the test if the account name is invalid */ if(imapServiceId == KMsvNullIndexEntryId) { ERR_PRINTF1(_L("Invalid IMAP account name specified")); SetTestStepResult(EFail); } else { /* Create a selection object */ CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(selection); /* Append the folder Id to the selection object created */ selection->AppendL(imapServiceId); TBuf8<1> param; CT_MsgActive& active=Active(); delete iOperation; iOperation=NULL; /* Synchronises the current folder that is selected on the remote server */ iOperation = iSharedDataIMAP.iMtm->InvokeAsyncFunctionL(KIMAP4MTMSynchronise,*selection,param,active.iStatus); active.Activate(); CActiveScheduler::Start(); User::LeaveIfError(active.Result()); CleanupStack::PopAndDestroy(selection); /* selection*/ TImap4GenericProgress temp; TPckgC<TImap4GenericProgress> paramPack(temp); paramPack.Set(iOperation->ProgressL()); TImap4GenericProgress progress=paramPack(); TBool err = progress.iErrorCode; if(err==KErrNone) { INFO_PRINTF1(_L("iErrorCode equals KErrNone")); } else { ERR_PRINTF2(_L("iErrorCode does not equal KErrNone; iErrorCode=%d"),err); SetTestStepError(err); } } } return TestStepResult(); }
void CTestContactsPBAPExport::ExportContactsL() { TInt err = KErrNone; // Retrieve the file name to which contact item is to be exported RFs fsSession; RFileWriteStream writeStream; // connect to file system User::LeaveIfError(fsSession.Connect()); CleanupClosePushL(fsSession); GetInputFromIni(); // Makes one or more directories. fsSession.MkDirAll(iExportTo); // Replaces a single file with another User::LeaveIfError(writeStream.Replace(fsSession, iExportTo, EFileWrite)); INFO_PRINTF1(_L("Exporting Contact.....")); // Existing database TPtrC databaseFile(_L("C:contactDb.cdb")); CContactDatabase* dBase = NULL; CContactIdArray* idArray = NULL; // Open the existing database dBase = CContactDatabase::OpenL(databaseFile); CleanupStack::PushL(dBase); // Create Utility class object, to export the contact from database CTestStep* self = static_cast<CTestStep*>(this); iExportObj = new(ELeave) CContactsPBAPExportUtilityClass(self); SetFilterL(); CCntFilter* exportFilter = CCntFilter::NewL(); CleanupStack::PushL(exportFilter); // Get all the contacts from the database to export exportFilter->SetContactFilterTypeCard(ETrue); dBase->FilterDatabaseL(*exportFilter); idArray = exportFilter->iIds; CleanupStack::PushL(idArray); if(iDamageDb) { #ifdef _DEBUG #ifndef __SYMBIAN_CNTMODEL_USE_SQLITE__ TRAPD(err1,dBase->DamageDatabaseL(0x666)); if(err1 == KErrNone) { TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter)); INFO_PRINTF2(_L("Err:%d"),err); if(err == KErrNotReady) { SetTestStepResult(EPass); } else { SetTestStepResult(EFail); } if(dBase->IsDamaged()) { dBase->RecoverL(); } } else { INFO_PRINTF2(_L("Could not damage database Err:"),err1); } #else SetTestStepResult(EPass); #endif #endif } else { if(iInvalidFileSystem) { #ifdef _DEBUG fsSession.SetErrorCondition(KErrNotReady); TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter)); if(err == KErrNotReady) { SetTestStepResult(EPass); } else { SetTestStepResult(EFail); } fsSession.SetErrorCondition(KErrNone); #endif } else { if(!iSetOOM) { if(idArray->Count() > 0) { for(TInt i=0; i<idArray->Count() ; i++) { TInt dCount = dBase->CountL(); if(i>=dCount) { break; } // temporary array used to export one contact at a time CContactIdArray* tempIdArray = CContactIdArray::NewL(); CleanupStack::PushL(tempIdArray); tempIdArray->AddL((*idArray)[i]); TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, tempIdArray, writeStream, iContactFilter)); if(err != KErrNone ) { if(err != KErrNotFound) { SetTestStepError(err); } } CleanupStack::PopAndDestroy(tempIdArray); } } else { if(idArray->Count()==0) { TRAPD(err,iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter)); if(err != KErrNone) { SetTestStepError(err); } } } } else { TInt tryCount = 1; for ( ;; ) { __UHEAP_SETFAIL(RHeap::EDeterministic, tryCount); TRAP(err, iExportObj->ExportvCardL(dBase, iStandard, idArray, writeStream, iContactFilter)); if ( err == KErrNone ) { __UHEAP_RESET; INFO_PRINTF1(_L("OOM testing of CContactDatabase::ExportSelectedContactsL Api is done")); break; } if ( err != KErrNoMemory ) { INFO_PRINTF2(_L("The unexpected error code is:%d"),err); SetTestStepResult(EFail); break; } __UHEAP_SETFAIL(RHeap::ENone, 0); tryCount++; } } } } CleanupStack::Pop(idArray); CleanupStack::PopAndDestroy(exportFilter); INFO_PRINTF1(_L("Exported Contact")); writeStream.CommitL(); writeStream.Close(); INFO_PRINTF2(_L("Total number of contacts in database %d "), dBase->CountL()); // Cleanup CleanupStack::PopAndDestroy(dBase); CleanupStack::PopAndDestroy(&fsSession); }
/** Function : doTestStepL Description : Reads the Pop account name and config file name from the .ini file and it then modifies the account with the settings read from the config file. @return : TVerdict - Test step result @leave : KMsvNullIndexEntryId Invalid POP account name specified */ TVerdict CT_MsgModifyPopSettings2::doTestStepL() { INFO_PRINTF1(_L("Test Step: ModifyPopSettings2")); // Read the POP account name from the ini file TPtrC popAccountName; if(!GetStringFromConfig(ConfigSection(), KPopAccountName, popAccountName)) { ERR_PRINTF1(_L("POP account name is not specified")); SetTestStepResult(EFail); } else { // Read the POP Config file name from the ini file TPtrC configFileName; if(!GetStringFromConfig(ConfigSection(), KPopConfigFileName, configFileName)) { ERR_PRINTF1(_L("Configuration file path is not specified")); SetTestStepResult(EFail); } else { // Retrieving the POP service Id for the given POP account TMsvId popServiceId = CT_MsgUtilsCentralRepository::GetPopServiceIdL((TDes&)popAccountName); INFO_PRINTF2(_L("POP service Id is %d"),popServiceId); if(popServiceId == KMsvNullIndexEntryId) { ERR_PRINTF1(_L("Invalid POP account name specified")); SetTestStepResult(EFail); } // Creates the settings object else { CEmailAccounts* emailAccounts = CEmailAccounts::NewLC(); CImPop3Settings* popSettings = new(ELeave) CImPop3Settings(); CleanupStack::PushL(popSettings); CImIAPPreferences* popIapPrefs = CImIAPPreferences::NewLC(); // Loads the settings for the account with the current settings TPopAccount popAccount; emailAccounts->GetPopAccountL(popServiceId, popAccount); emailAccounts->LoadPopSettingsL(popAccount, *popSettings); emailAccounts->LoadPopIapSettingsL(popAccount, *popIapPrefs); // Reads the settings from the config file TRAPD(err, CT_MsgUtilsReadEmailSettingsFromConfigFile::ReadPopSettingsFromConfigurationFileL(configFileName, *popSettings, *popIapPrefs)); if(err) { ERR_PRINTF2(_L("Failure while setting the POP setting parameters, failed with error %d"), err); SetTestStepError(err); } else { // Saves the new settings emailAccounts->SavePopSettingsL(popAccount, *popSettings); emailAccounts->SavePopIapSettingsL(popAccount, *popIapPrefs); } CleanupStack::PopAndDestroy(3, emailAccounts);// popIapPrefs,popSettings,emailAccounts } } } return TestStepResult(); }
/** Compares the properties of two geo values @param aEntry1 Pointer to the stored entry @param aEntry2 Pointer to the entry fetched from the database */ void CTestCalInterimApiSuiteStepBase::CompareGeoL(CCalEntry* aEntry1, CCalEntry* aEntry2) { TBool allocTest = EFalse; GetBoolFromConfig(ConfigSection(), KAllocTest, allocTest); TInt err = KErrNone; TInt errCode = KErrNone; CCalGeoValue* geoValue = NULL; if (allocTest) { err = OOMGeoValueL(aEntry1, geoValue); } else { TRAP(err, geoValue = aEntry1->GeoValueL()); } CCalGeoValue* storedGeoValue = NULL; if (allocTest) { errCode = OOMGeoValueL(aEntry2, storedGeoValue); } else { TRAP(errCode, storedGeoValue = aEntry2->GeoValueL()); } if (geoValue == NULL) { TESTL(storedGeoValue == NULL); INFO_PRINTF1(_L("GEO Property not set within entry")); } else { CleanupStack::PushL(geoValue); TESTL(storedGeoValue != NULL); CleanupStack::PushL(storedGeoValue); if (err != KErrNone) { ERR_PRINTF2(_L("GeoValuesL Error Code %d"), err); SetTestStepResult(EFail); SetTestStepError(err); } TReal lat = 0.0; TReal longitude = 0.0; TBool hasGEO = geoValue->GetLatLong(lat,longitude); TReal latTruncated = 0.0; Math::Round(latTruncated, lat, KMaxGEODecimalPoint); if (latTruncated != lat) { lat = latTruncated; } TReal longTruncated = 0.0; Math::Round(longTruncated, longitude, KMaxGEODecimalPoint); if (longTruncated != longitude) { longitude = longTruncated; } if (errCode != KErrNone) { ERR_PRINTF2(_L("GeoValuesL Error Code %d"), err); SetTestStepResult(EFail); SetTestStepError(err); } TReal storedLat = 0.0; TReal storedLong = 0.0; TBool storedHasGEO = storedGeoValue->GetLatLong(storedLat, storedLong); if ( KMinGEOLat > lat || lat > KMaxGEOLat || KMinGEOLong > longitude || longitude > KMaxGEOLong ) { TESTL(!hasGEO); TESTL(!storedHasGEO); TESTL(KDefaultGEOLatLong == storedLat); TESTL(KDefaultGEOLatLong == storedLong); INFO_PRINTF1(_L("GEO Property is set correctly to default value")); } else { TESTL(hasGEO); TESTL(storedHasGEO); TESTL(lat == storedLat); TESTL(longitude == storedLong); INFO_PRINTF1(_L("GEO Property is set correctly")); } CleanupStack::Pop(storedGeoValue); CleanupStack::Pop(geoValue); } }
/** Function : doTestStepL Description : Reads the Imap account name from the ini file. It establishes connection with the IMAP server. @return : TVerdict - Test step result */ TVerdict CT_MsgConnectImap4Server::doTestStepL() { INFO_PRINTF1(_L(" Test Step : ConnectIMAP4Server")); /* Reads the name of the account from the ini file */ TPtrC imapAccountName; if(!GetStringFromConfig( ConfigSection(), KImapAccountName, imapAccountName)) { ERR_PRINTF1(_L("Imap Account Name is not specified")); SetTestStepResult(EFail); } else { /* Retrieves the Imap service Id for the given Imap account*/ TMsvId imapServiceId = CT_MsgUtilsCentralRepository::GetImapServiceIdL((TDes&)imapAccountName); INFO_PRINTF2(_L("Imap service id is %d"),imapServiceId ); /* Changes the current context and switches to the IMAP service Id*/ iSharedDataIMAP.iMtm->SwitchCurrentEntryL(imapServiceId); /* Creates a selection object*/ CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(selection); /* Appends the IMAP ServiceId onto the end of the selection */ selection->AppendL(imapServiceId); // Get any expected error TInt expectedErr = 0; GetIntFromConfig(ConfigSection(), KExpectedErr, expectedErr); TBuf8<1> param; /* Attempts to connect to the IMAP server*/ CT_MsgActive& active=Active(); delete iOperation; iOperation=NULL; /* Attempts to establish connection with the IMAP server */ iOperation = iSharedDataIMAP.iMtm->InvokeAsyncFunctionL(KIMAP4MTMConnect, *selection,param, active.iStatus); active.Activate(); CActiveScheduler::Start(); if ((expectedErr != KErrNone) || (active.Result() != KErrNone)) { if(active.Result() == expectedErr) { INFO_PRINTF1(_L("Failed with Expected Error")); SetTestStepResult(EPass); } else { ERR_PRINTF2(_L("Failed with %d error"), active.Result()); SetTestStepResult(EFail); } } SetTestStepError(active.Result()); CleanupStack::PopAndDestroy(selection); /* selection */ } return TestStepResult(); }
/** Function : doTestStepL Description : Creates a serch-sort query object and facilitate the same to be shared across other teststeps. @return : TVerdict - Test step result */ TVerdict CT_MsgCreatePerfSearchSortQuery::doTestStepL() { INFO_PRINTF1(_L("Test Step : CreateSearchSortQuery")); /* Get the folder ID within a given service under which messages would be searched for. NOTE: Folder ID for the folder under remote service can be obatained only if the folder is subscried one or including the invisible entries in the children selection. */ TMsvId parentId = ParentIdForSearchSortL(); iSharedDataCommon.iSearchSortQuery = CMsvSearchSortQuery::NewL(); CleanupStack::PushL(iSharedDataCommon.iSearchSortQuery); parentId != KMsvNullIndexEntryIdValue ? iSharedDataCommon.iSearchSortQuery->SetParentId(parentId) : ERR_PRINTF1(_L("Invalid Parent ID")); if( TestStepResult() == EPass ) { TInt searchCriteriaNumber = 0; // Indicates the number of search criterias, if it is zero no search operation would be performed if (!GetIntFromConfig(ConfigSection(), KSearchCriteriaNumber, searchCriteriaNumber)) { ERR_PRINTF1(_L("Number of search fields not specified")); SetTestStepResult (EFail); } else { TBuf<256> param; TInt searchError = KErrNone; for(TInt i = 1; (i <= searchCriteriaNumber) && (searchError == KErrNone); i++) { param.Format(KMessagePart, i); TPtrC messagePart; TPtrC rel; if ( !GetStringFromConfig(ConfigSection(), param, messagePart)) { ERR_PRINTF1(_L("Message part to be searched is not specified")); SetTestStepResult (EFail); } else { // Converts the string into corresponding TMsvMessagePart enumeration TMsvMessagePart msgPartValue = CT_MsgUtilsEnumConverter::ConvertDesToMessagePart(messagePart); // Read the query String from the ini file param.Format(KQueryString, i); TPtrC queryString; TInt queryInt; TBool queryBool = EFalse; TMsvRelationOp relOp; switch(msgPartValue) { case EMsvAttachment: case EMsvUnreadMessages: case EMsvNew: if(!GetBoolFromConfig(ConfigSection(), param, queryBool)) { ERR_PRINTF1(_L("Query value to be searched for is not specified")); SetTestStepResult(EFail); } TRAP(searchError, iSharedDataCommon.iSearchSortQuery->AddSearchOptionL(msgPartValue, queryBool)); break; case EMsvPriority: case EMsvSize: case EMsvMtmTypeUID: if(!GetIntFromConfig(ConfigSection(), param, queryInt)) { ERR_PRINTF1(_L("Query value to be searched for is not specified")); SetTestStepResult(EFail); } // Read the relational operation to be performed for the query param.Format(KRelationOp, i); GetStringFromConfig( ConfigSection(), param, rel); relOp = CT_MsgUtilsEnumConverter::ConvertDesToMsgRelationOp(rel); TRAP(searchError, iSharedDataCommon.iSearchSortQuery->AddSearchOptionL(msgPartValue, queryInt, relOp)); break; case EMsvBcc: case EMsvBody: case EMsvCc: case EMsvDate: case EMsvDescription: case EMsvDetails: case EMsvFrom: case EMsvSubject: case EMsvTo: if(!GetStringFromConfig(ConfigSection(), param, queryString)) { ERR_PRINTF1(_L("String to be searched for is not specified")); SetTestStepResult(EFail); } param.Format(KRelationOp, i); GetStringFromConfig( ConfigSection(), param, rel); relOp = CT_MsgUtilsEnumConverter::ConvertDesToMsgRelationOp(rel); TRAP(searchError, iSharedDataCommon.iSearchSortQuery->AddSearchOptionL(msgPartValue, queryString, relOp)); break; default: SetTestStepResult(EFail); ERR_PRINTF1(_L("Invalid Message part for search")); } SetTestStepError(searchError); } } /*if( (TestStepResult() == EPass) && (searchError == KErrNone)) { // Add the message part accroding to which messages would be sorted, and the order of sorting. // If sorting is not required set KSortMsgPart to TMsvMessagePart::EMsvNone TPtrC sortMsgPart; if (!GetStringFromConfig(ConfigSection(), KSortMsgPart, sortMsgPart)) { INFO_PRINTF1(_L("Sorting operation is not requested")); } else { TPtrC sortOrder; TMsvSortOrder order = EMsvSortAscending; if(GetStringFromConfig(ConfigSection(), KSortOrder, sortOrder)) { order = CT_MsgUtilsEnumConverter::ConvertDesToSortOrder(sortOrder); } TMsvMessagePart sortPart = CT_MsgUtilsEnumConverter::ConvertDesToMessagePart(sortMsgPart); TRAPD(sortError, iSharedDataCommon.iSearchSortQuery->AddSortOptionL(sortPart, order)); SetTestStepError(sortError); } }*/ ModifyDefaultSearchSortOptions(); // Modify the default search/sort options } } CleanupStack::Pop(); // Ownership of CMsvSearchSortQuery object passed CMsvSearchSortOpeartion through RequestL function return TestStepResult(); }