void CTestCImPlainTextStore::TestStoreRichTextAsPlainTextL() { CreateNewPlaintextMessageL(); CMsvEntry* entry = testUtils->iMsvSession->GetEntryL(newMessageId); CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*entry); iCImPlainBodyTextStore = imEmailMessage->OpenPlainBodyTextForWriteL(); CParaFormatLayer* paraLayer = CParaFormatLayer::NewL(); CCharFormatLayer* charLayer = CCharFormatLayer::NewL(); CRichText* richText=CRichText::NewL(paraLayer, charLayer, CEditableText::EFlatStorage, KBufferGranularity); TBuf<50> theMessageContents = _L("Test message contents"); richText->InsertL(0, theMessageContents); TInt textLength = richText->DocumentLength(); iCImPlainBodyTextStore->StoreRichTextAsPlainTextL(*richText); iCImPlainBodyTextStore->CommitL(iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); delete richText; richText=CRichText::NewL(paraLayer, charLayer, CEditableText::EFlatStorage, KBufferGranularity); imEmailMessage->GetBodyTextL(newMessageId, CImEmailMessage::EThisMessageOnly, *richText, *paraLayer, *charLayer); richText->DocumentLength(); ASSERT_EQUALS(richText->DocumentLength(), textLength); delete richText; delete charLayer; delete paraLayer; CleanupStack::PopAndDestroy(imEmailMessage); }
void CTestCImPlainTextStore::TestStoreRestore16BitChunkAsyncL() { CreateNewPlaintextMessageL(); CMsvEntry* entry = testUtils->iMsvSession->GetEntryL(newMessageId); CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*entry); iCImPlainBodyTextStore = imEmailMessage->OpenPlainBodyTextForWriteL(); iCImPlainBodyTextStore->StoreChunkL(iFilebuf1->Des(),iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); TInt bodyTextSize = iFilebuf1->Length(); iCImPlainBodyTextStore->StoreChunkL(iFilebuf2->Des(),iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); bodyTextSize += iFilebuf2->Length(); iCImPlainBodyTextStore->StoreChunkL(iFilebuf3->Des(),iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); bodyTextSize += iFilebuf3->Length(); iCImPlainBodyTextStore->CommitL(iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); delete iCImPlainBodyTextStore; iCImPlainBodyTextStore = NULL; //Restore the data in chunks. HBufC16* filebuf11 = HBufC16::NewL(100+KTestStringLength); TInt origSize = bodyTextSize; TInt sizeOfRestoredText = 0; TPtr bufPtr = filebuf11->Des(); TInt pos = 0; iCImPlainBodyTextStore = imEmailMessage->OpenPlainBodyTextForReadL(CImEmailMessage::EThisMessageOnly,100); iCImPlainBodyTextStore->NextChunkL(bufPtr,iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); RArray<TPtr> chunkArray; chunkArray.Append(bufPtr); sizeOfRestoredText += bufPtr.Length(); while(bufPtr.Length() > 0 && bufPtr.Length() == 100) { iCImPlainBodyTextStore->NextChunkL(bufPtr,iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); // put retrived buffer in a array. chunkArray.Append(bufPtr); sizeOfRestoredText += bufPtr.Length(); } ASSERT_EQUALS(bodyTextSize, sizeOfRestoredText); for(TInt j=chunkArray.Count() - 1;j >0; --j ) { bufPtr.SetLength(0); iCImPlainBodyTextStore->PreviousChunkL(bufPtr,iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); // Compare chunk retrieved with chunk retrieved by NextChunkL TInt comp = bufPtr.Compare(chunkArray[j-1]); ASSERT_EQUALS(comp, 0); } CleanupStack::PopAndDestroy(imEmailMessage); }