void CMtfTestActionVerifyAttachmentInfo::ExecuteActionL()
	{
	TestCase().INFO_PRINTF2(_L("Test Action %S start..."), &KTestActionVerifyAttachmentInfo);
	CMsvAttachment* attachmentInfo = ObtainParameterReferenceL<CMsvAttachment>(TestCase(),ActionParameters().Parameter(0));
	HBufC*	paramFileName   = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(1));
	TInt	paramFileSize   = ObtainValueParameterL<TInt>(TestCase(),ActionParameters().Parameter(2));
	HBufC*	paramMimeType   = ObtainParameterReferenceL<HBufC>(TestCase(),ActionParameters().Parameter(3));

	
	TestCase().INFO_PRINTF1(_L("VerifyAttachmentInfo....."));

	TestCase().INFO_PRINTF2(_L("Attachment Name - %S"), &attachmentInfo->AttachmentName());
	TestCase().INFO_PRINTF2(_L("Size - %d"), attachmentInfo->Size());
	
	TBuf<KMimeTypeLength> mimeType;
	mimeType.Copy(attachmentInfo->MimeType());
	TestCase().INFO_PRINTF2(_L("MimeType - %S"), &mimeType);
	

	TestCase().INFO_PRINTF1(_L("With.."));

	TestCase().INFO_PRINTF2(_L("Attachment Name - %S"), paramFileName);
	TestCase().INFO_PRINTF2(_L("Size - %d"), paramFileSize);
	TestCase().INFO_PRINTF2(_L("MimeType - %S"), paramMimeType);

	if ( 
		(paramFileName->Compare(attachmentInfo->AttachmentName()) == 0) &&
		(paramMimeType->Compare(mimeType) == 0) &&
		(paramFileSize == attachmentInfo->Size())
	   )
		{		
		}
	else
		{
		User::Leave(KErrGeneral);
		}

	TestCase().INFO_PRINTF2(_L("Test Action %S completed."), &KTestActionVerifyAttachmentInfo);
	TestCase().ActionCompletedL(*this);
	}
예제 #2
0
TInt32 CSmtpClientMtm::GetAttachmentSizeL(CImEmailMessage& aMessage, TMsvId aMsvId)
	{
	// Calculate the total size of all attachments associated with this message
	TInt total=0;
	aMessage.GetAttachmentsListL(iWait->iStatus, aMsvId, CImEmailMessage::EAllAttachments,CImEmailMessage::EThisMessageOnly);
	iWait->Start();		// wait for the asynch operation to complete
	TInt numAttachments=aMessage.AttachmentManager().AttachmentCount();
	for (TInt n=0 ; n<numAttachments ; ++n)
		{
		CMsvAttachment* attachment = aMessage.AttachmentManager().GetAttachmentInfoL(n);
		total+=attachment->Size();
		delete attachment;
		}
	return total;
	}
void CheckNewAttachmentL(const TDesC& aFileName, TInt aFileSize, const TDesC8& aMimeType, TUint aCharset, TBool aLinkedAttachment)
	{
	// Check that file exists in the store and it matches our control file.
	CDummyObserver* ob1 = new(ELeave) CDummyObserver;
	CleanupStack::PushL(ob1);
	CMsvSession* session = CMsvSession::OpenSyncL(*ob1);
	CleanupStack::PushL(session);
	CMsvEntry* cEntry = CMsvEntry::NewL(*session, KMsvDraftEntryId, 
		TMsvSelectionOrdering(KMsvNoGrouping,EMsvSortByNone,ETrue));
	CleanupStack::PushL(cEntry);
	CMsvEntrySelection* selection = cEntry->ChildrenL();
	CleanupStack::PushL(selection);

	test(selection->Count() == 1);
	cEntry->SetEntryL((*selection)[0]);
	
	CMsvStore* store = cEntry->ReadStoreL();
	CleanupStack::PushL(store);
	
	MMsvAttachmentManager& attachmentMgr = store->AttachmentManagerL();
	TInt count = attachmentMgr.AttachmentCount();
	test(count > 0);
	
	TBool found = EFalse;
	
	while( count-- > 0 && !found )
		{
		CMsvAttachment* attachmentInfo = attachmentMgr.GetAttachmentInfoL(count);
		CleanupStack::PushL(attachmentInfo);

		// Check the attachment info is what we expect.
		TParse parser1;
		TParse parser2;
		parser1.Set(attachmentInfo->FilePath(), NULL, NULL);
		parser2.Set(aFileName, NULL, NULL);

		found = ETrue;
		if (aLinkedAttachment)
			{
			found = found && (attachmentInfo->Type() == CMsvAttachment::EMsvLinkedFile);  // Check it's a linked file.
			found = found && (parser1.DriveAndPath() == parser2.DriveAndPath());
			}
		else
			{
			found = found && (attachmentInfo->Type() == CMsvAttachment::EMsvFile);  // Check it's a file.
			found = found && (parser1.DriveAndPath() != parser2.DriveAndPath());
			}
			
		found = found && (attachmentInfo->MimeType().Match(aMimeType) == 0);  // Check mime type matches.
		found = found && (parser1.NameAndExt() == parser2.NameAndExt()); // This necessarily correct?
		found = found && (attachmentInfo->Size() == aFileSize); // Check size matches.
		
		// check charset matches
		CMsvMimeHeaders* mimeHeaders = CMsvMimeHeaders::NewLC();
		mimeHeaders->RestoreL(*attachmentInfo);
		found = found && (mimeHeaders->MimeCharset() == aCharset);
		
		CleanupStack::PopAndDestroy(2, attachmentInfo); // mimeHeaders, attachmentInfo
		}
	test(found);

	CleanupStack::PopAndDestroy(5, ob1); // store, selection, cEntry, sesion, ob1
	}