messagingappbase/smsmtm/clientmtm/test/src/smcmstepreplyemail.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @SYMTestCaseID MSG-SMSCLIENTMTM-0243-7
       
    18  @SYMTestType UT
       
    19  @SYMTestPriority High
       
    20  @SYMPREQ 234, other
       
    21  @SYMTestCaseDesc Creates an Email over SMS with locale UTC offset 0, sets UTC offset to -8, reply the Email over SMS
       
    22  @SYMTestActions  Checks the timestamps of original and replied Email over SMS. (also check original test actions of T_SMCM1)
       
    23  @SYMTestExpectedResults The timestamp of the original Email over SMS should be smaller than the timestamp of the replied Email over SMS.
       
    24 */
       
    25 
       
    26 #include "smcmstepreplyemail.h"
       
    27 
       
    28 #include <csmsemailfields.h>
       
    29 #include <smuthdr.h> 
       
    30 
       
    31 CSMCMStepReplyEmail::CSMCMStepReplyEmail( )
       
    32 	{
       
    33 	SetTestStepName( KSMCMStepReplyEmail );
       
    34 	}
       
    35 	
       
    36 CSMCMStepReplyEmail::~CSMCMStepReplyEmail( )
       
    37 	{
       
    38 	
       
    39 	}
       
    40 	
       
    41 TVerdict CSMCMStepReplyEmail::doTestStepL( )
       
    42 	{
       
    43 	INFO_PRINTF1( _L( "CSMCMStepReplyEmail::doTestStepL( )" ) );
       
    44 	
       
    45 	ChangeLocale( KUTC0 );
       
    46 	
       
    47 	SetSettingsL( );
       
    48 	
       
    49 	TVerdict result = EPass;
       
    50 	SetTestStepResult( result );
       
    51 	
       
    52 	_LIT( KTestEmailAddress1,	"user@domain1.domain2" );
       
    53  	_LIT( KTestEmailSubject1,	"Re: a subject" );
       
    54  	_LIT( KTestEmailMessage1,	"user@domain1.domain2##a subject#some body text" );
       
    55  	result = DoTestReplyEmailL( KTestEmailMessage1, KTestEmailAddress1, KTestEmailSubject1 );
       
    56  	if ( result == EFail )
       
    57  		{
       
    58  		SetTestStepResult( EFail );
       
    59  		}
       
    60  
       
    61  	// Reset Time to UTC0 for Next Test
       
    62  	ChangeLocale( KUTC0 );
       
    63  
       
    64  	_LIT( KTestEmailAddress2,	"user@domain1.domain2" );
       
    65  	_LIT( KTestEmailSubject2,	"" );
       
    66  	_LIT( KTestEmailMessage2,	"user@domain1.domain2 some body text" );
       
    67  	result = DoTestReplyEmailL( KTestEmailMessage2, KTestEmailAddress2, KTestEmailSubject2 );
       
    68  	if ( result == EFail )
       
    69  		{
       
    70  		SetTestStepResult( EFail );
       
    71  		}
       
    72  	
       
    73  	// if locale isn't changed the log file timestamps will be out of order 
       
    74 	// as they are in local time	
       
    75  	ChangeLocale( KUTC0 );
       
    76  
       
    77 	return TestStepResult( );
       
    78 	
       
    79 	}
       
    80 	
       
    81 TVerdict CSMCMStepReplyEmail::DoTestReplyEmailL( const TDesC& aEmailMessageData, 
       
    82 											 const TDesC& aAddress, 
       
    83 											 const TDesC& aSubject )
       
    84 	{
       
    85 	TVerdict result = EPass;
       
    86 	
       
    87 	TMsvId entrId = CreateEmailSmsMessageL( aEmailMessageData );
       
    88 
       
    89 	ChangeLocale( KUTCMin8 );
       
    90 	
       
    91 	iSmsTestUtils->SetEntryL( entrId );
       
    92  	iSmsClientMtm->SwitchCurrentEntryL( entrId ); 
       
    93  	iSmsClientMtm->LoadMessageL( );
       
    94  	// store the original entry (to compare UTC)
       
    95    	TMsvEntry originalEntry = iSmsClientMtm->Entry( ).Entry( );
       
    96    	
       
    97  	TMsvPartList part=0;
       
    98  	CMsvOperationWait* wait = CMsvOperationWait::NewLC( );
       
    99  	CMsvOperation* op = iSmsClientMtm->ReplyL( KMsvDraftEntryId, part, wait->iStatus );
       
   100  	CleanupStack::PushL( op );
       
   101  	wait->Start( );
       
   102  	CActiveScheduler::Start( );
       
   103 
       
   104 	TPckgBuf< TMsvId > pkg;
       
   105  	pkg.Copy( op->ProgressL() );
       
   106  	TMsvId reply = pkg();
       
   107  
       
   108  	CleanupStack::PopAndDestroy( 2, wait ); // op, wait
       
   109  	
       
   110  	// Switch and load the reply message
       
   111  	iSmsClientMtm->SwitchCurrentEntryL( reply );
       
   112  	iSmsClientMtm->LoadMessageL( );
       
   113  	
       
   114  	// Check the reply message...
       
   115  	const CSmsHeader& replyHeader = iSmsClientMtm->SmsHeader( );
       
   116 
       
   117 	// 1. Email fields...
       
   118  	const CSmsEmailFields& fields = replyHeader.EmailFields( );
       
   119  	if ( fields.Addresses( ).MdcaCount( ) != 1)
       
   120  		{
       
   121  		result = EFail;
       
   122  		ERR_PRINTF1( _L("CSmsEmailFields Address is not present or more than one is present" ) );
       
   123  		}
       
   124  	if ( fields.Addresses( ).MdcaPoint( 0 ).Compare( aAddress ) != 0 )
       
   125  		{
       
   126  		result = EFail;
       
   127  		ERR_PRINTF1( _L("CSmsEmailFields Address is different" ) );
       
   128  		}
       
   129  	if ( fields.Subject( ).Compare( aSubject ) != 0 )
       
   130  		{
       
   131  		result = EFail;
       
   132  		ERR_PRINTF1( _L("CSmsEmailFields Subject is not the expected one" ) );
       
   133  		}
       
   134  	
       
   135  	// 2. PID...
       
   136  	CSmsSettings* smsset = CSmsSettings::NewL( );
       
   137  	CleanupStack::PushL( smsset );
       
   138  	replyHeader.GetSmsSettingsL( *smsset );
       
   139  	if ( smsset->MessageConversion( ) != ESmsConvMail )
       
   140  		{
       
   141  		result = EFail;
       
   142  		ERR_PRINTF1( _L("Message Conversion is not ESmsConvMail" ) );
       
   143  		}
       
   144  		
       
   145  	CleanupStack::PopAndDestroy( smsset );
       
   146  	
       
   147  	// 3. Email <-> SMS gateway (i.e. the recipient)
       
   148  	const CArrayPtrFlat< CSmsNumber >& rcpts = replyHeader.Recipients( );
       
   149  	if ( rcpts.Count( ) != 1 )
       
   150  		{
       
   151  		result = EFail;
       
   152  		ERR_PRINTF1( _L("SMS Gateway count is wrong" ) );
       
   153  		}
       
   154  	const CSmsNumber& rcpt = *rcpts.At( 0 );
       
   155  	if ( rcpt.Address( ).Compare( KScriptItemRecipientsDef ) != 0 )
       
   156  		{
       
   157  		result = EFail;
       
   158  		ERR_PRINTF1( _L("SMS Gateway address is wrong" ) );
       
   159  		}
       
   160  
       
   161  	// 4. Description - should be the same as the subject.
       
   162  	TMsvEntry replyEntry = iSmsClientMtm->Entry( ).Entry( );
       
   163  	TInt maxDesLength = iSmsClientMtm->ServiceSettings( ).DescriptionLength( );
       
   164  	if ( replyEntry.iDescription.Compare( fields.Subject( ).Left( maxDesLength ) ) != 0 )
       
   165  		{
       
   166  		result = EFail;
       
   167  		ERR_PRINTF1( _L("Description does not match subject" ) );
       
   168  		}
       
   169  	
       
   170  	// 5. Details - should be the same as the address.
       
   171  	if ( replyEntry.iDetails.Compare( fields.Addresses( ).MdcaPoint( 0 ).Left( KSmsDetailsLength ) ) != 0 )
       
   172  		{
       
   173  		result = EFail;
       
   174  		ERR_PRINTF1( _L("Details do not match address" ) );
       
   175  		}
       
   176  		
       
   177  	// 6. UTC - UTC time of the original entry should be smaller than reply entry UTC time
       
   178  	if ( originalEntry.iDate >= replyEntry.iDate )
       
   179 		{
       
   180 		result = EFail;
       
   181 		ERR_PRINTF1( _L("UTC time is wrong" ) );
       
   182 		}
       
   183 
       
   184 	return result;
       
   185 	}
       
   186