messagingfw/msgtestfw/TestCases/NonScriptedTestCases/src/CMtfTestCaseCreateSendReceiveImap4Email.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2003-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  @file
       
    18 */
       
    19 
       
    20 
       
    21 #include "CMtfTestCaseCreateSendReceiveImap4Email.h"
       
    22 #include "CMtfTestActionParameters.h"
       
    23 
       
    24 #include "CMtfTestActionGetBaseConstants.h"
       
    25 #include "CMtfTestActionGetEntryPriorityEnums.h"
       
    26 #include "CMtfTestActionCreateSession.h"
       
    27 #include "CMtfTestActionResetMessageStore.h"
       
    28 #include "CMtfTestActionCreateRegistry.h"
       
    29 #include "CMtfTestActionCopyEntry.h"
       
    30 #include "CMtfTestActionFindEntryByName.h"
       
    31 #include "CMtfTestActionDeleteChildren.h"
       
    32 #include "CMtfTestActionCheckChildrenCount.h"
       
    33 #include "CMtfTestActionCreateChildrenSelection.h"
       
    34 #include "CMtfTestActionCopySelection.h"
       
    35 
       
    36 #include "CMtfTestActionInitNtRas.h"
       
    37 
       
    38 #include "CMtfTestActionCreateImap4Service.h"
       
    39 #include "CMtfTestActionCreateImap4Mtm.h"
       
    40 #include "CMtfTestActionSetImap4ServiceParameters.h"
       
    41 #include "CMtfTestActionConnectImap4Server.h"
       
    42 #include "CMtfTestActionDisconnectImap4Server.h"
       
    43 #include "CMtfTestActionDoFullImap4Synchronisation.h"
       
    44 
       
    45 #include "CMtfTestActionCreateSmtpService.h"
       
    46 #include "CMtfTestActionCreateSmtpMtm.h"
       
    47 #include "CMtfTestActionSetSmtpServiceParameters.h"
       
    48 #include "CMtfTestActionCreateSmtpMessageFromEmailFile.h"
       
    49 
       
    50 _LIT(KSession,"session");
       
    51 
       
    52 _LIT(KInboxFolderId,	"inboxFolderId");
       
    53 _LIT(KOutboxFolderId,	"outboxFolderId");
       
    54 _LIT(KDraftsFolderId,	"draftsFolderId");
       
    55 _LIT(KSentFolderId,		"sentFolderId");
       
    56 _LIT(KDeletedFolderId,	"deletedFolderId");
       
    57 
       
    58 _LIT(KClientMtmRegistry,"clientMtmRegistry");
       
    59 
       
    60 _LIT(KImap4Mtm,					"imap4Mtm");
       
    61 _LIT(KImap4ServiceId,			"imap4ServiceId");
       
    62 _LIT(KImap4InboxFolder,			"\"Inbox\"");
       
    63 _LIT(KImap4FolderId,			"imap4FolderId");
       
    64 _LIT(KImap4MessageId,			"imap4MessageId");
       
    65 _LIT(KImap4MessageDescription,	"\"SimpleEmail\"");
       
    66 _LIT(KImap4Details,				"\"Imap4Service\"");
       
    67 
       
    68 _LIT(KSmtpMtm,			"smtpMtm");
       
    69 _LIT(KSmtpServiceId,	"smtpServiceId");
       
    70 _LIT(KSmtpMessageId,	"smtpMessageId");
       
    71 _LIT(KSmtpDetails, 		"\"SmtpService\"");
       
    72 
       
    73 
       
    74 _LIT(KZero,	"0");
       
    75 _LIT(KOne, 	"1");
       
    76 	
       
    77 _LIT(KSelection,"selection");
       
    78 
       
    79 _LIT(KInboxMessageId,	"inboxMessageId");
       
    80 _LIT(KSentMessageId,	"sentMessageId");
       
    81 
       
    82 
       
    83 CMtfTestCase* CMtfTestCaseCreateSendReceiveImap4Email::NewL(const CMtfTestServer& aTestServer)
       
    84 	{
       
    85 	CMtfTestCaseCreateSendReceiveImap4Email* self = new (ELeave) CMtfTestCaseCreateSendReceiveImap4Email(aTestServer);
       
    86 	CleanupStack::PushL(self);
       
    87 	self->ConstructL();
       
    88 	CleanupStack::Pop();
       
    89 	return self;
       
    90 	}
       
    91 
       
    92 
       
    93 CMtfTestCaseCreateSendReceiveImap4Email::CMtfTestCaseCreateSendReceiveImap4Email(const CMtfTestServer& aTestServer)
       
    94 	: CMtfTestCase(aTestServer,EFalse,ETrue)
       
    95 	{
       
    96 	}
       
    97 
       
    98 
       
    99 void CMtfTestCaseCreateSendReceiveImap4Email::ConstructL()
       
   100 	{
       
   101 	CMtfTestCase::ConstructL();
       
   102 	}
       
   103 
       
   104 
       
   105 void CMtfTestCaseCreateSendReceiveImap4Email::SetupTestCaseL()
       
   106 	{
       
   107 	// Get constants and enums.
       
   108 	CMtfTestActionGetBaseConstants::NewL(*this,CMtfTestActionParameters::NewL(KInboxFolderId,KOutboxFolderId,KDraftsFolderId,KSentFolderId,KDeletedFolderId));
       
   109 
       
   110 	// Init NTRAS.
       
   111 	CMtfTestActionInitNtRas::NewL(*this,CMtfTestActionParameters::NewL());
       
   112 
       
   113 	// Create the session and reset the message store.
       
   114 	CMtfTestActionCreateSession::NewL(*this,CMtfTestActionParameters::NewL(KSession));
       
   115 	CMtfTestActionResetMessageStore::NewL(*this,CMtfTestActionParameters::NewL(KSession));
       
   116 
       
   117 	// Create the IMAP4 and SMTP services
       
   118 	CMtfTestActionCreateImap4Service::NewL(*this,CMtfTestActionParameters::NewL(KSession,_,_,_,_,KImap4Details,KImap4ServiceId));
       
   119 	CMtfTestActionCreateSmtpService::NewL(*this,CMtfTestActionParameters::NewL(KSession,_,_,_,_,KSmtpDetails,KSmtpServiceId));
       
   120 
       
   121 	// Create IMAP4 and SMTP client MTMs.
       
   122 	CMtfTestActionCreateRegistry::NewL(*this,CMtfTestActionParameters::NewL(KSession,KClientMtmRegistry));
       
   123 	CMtfTestActionCreateImap4Mtm::NewL(*this,CMtfTestActionParameters::NewL(KSession,KImap4ServiceId,KClientMtmRegistry,KImap4Mtm));
       
   124 	CMtfTestActionCreateSmtpMtm::NewL(*this,CMtfTestActionParameters::NewL(KSession,KSmtpServiceId,KClientMtmRegistry,KSmtpMtm));
       
   125 
       
   126 	// Set IMAP4 and SMTP service parameters.
       
   127 	CMtfTestActionSetImap4ServiceParameters::NewL(*this,CMtfTestActionParameters::NewL(KSession,KImap4ServiceId,_));
       
   128 	CMtfTestActionSetSmtpServiceParameters::NewL(*this,CMtfTestActionParameters::NewL(KSession,KSmtpServiceId,_));
       
   129 
       
   130 	// Connect and do full sync with IMAP4 server.
       
   131 	CMtfTestActionConnectImap4Server::NewL(*this,CMtfTestActionParameters::NewL(KImap4ServiceId,KImap4Mtm));
       
   132 	CMtfTestActionDoFullImap4Synchronisation::NewL(*this,CMtfTestActionParameters::NewL(KImap4ServiceId,KImap4Mtm));
       
   133 
       
   134 	// Get IMAP4 server Inbox id, delete all entries and verify that it has no entries.
       
   135 	CMtfTestActionFindEntryByName::NewL(*this,CMtfTestActionParameters::NewL(KSession,KImap4ServiceId,KImap4InboxFolder,KImap4FolderId));
       
   136 	CMtfTestActionDeleteChildren::NewL(*this,CMtfTestActionParameters::NewL(KSession,KImap4FolderId));
       
   137 	CMtfTestActionCheckChildrenCount::NewL(*this,CMtfTestActionParameters::NewL(KSession,KImap4FolderId,KZero));
       
   138 	
       
   139 	// Disconnect from IMAP4 server.
       
   140 	CMtfTestActionDisconnectImap4Server::NewL(*this,CMtfTestActionParameters::NewL(KImap4ServiceId,KImap4Mtm));
       
   141 	}
       
   142 
       
   143 
       
   144 void CMtfTestCaseCreateSendReceiveImap4Email::ExecuteTestCaseL()
       
   145 	{
       
   146 	// Create the email and send.
       
   147 	CMtfTestActionCreateSmtpMessageFromEmailFile::NewL(*this,CMtfTestActionParameters::NewL(KSession,KSmtpServiceId,KOutboxFolderId,_,KSmtpMessageId));
       
   148 	CMtfTestActionCopyEntry::NewL(*this,CMtfTestActionParameters::NewL(KSession,KSmtpMessageId,KSmtpServiceId));
       
   149 
       
   150 	// Connect and full sync with IMAP4 server.
       
   151 	CMtfTestActionConnectImap4Server::NewL(*this,CMtfTestActionParameters::NewL(KImap4ServiceId,KImap4Mtm));
       
   152 	CMtfTestActionDoFullImap4Synchronisation::NewL(*this,CMtfTestActionParameters::NewL(KImap4ServiceId,KImap4Mtm));
       
   153 
       
   154 	// Copy IMAP4 server Inbox entries to local Inbox.
       
   155 	CMtfTestActionCreateChildrenSelection::NewL(*this,CMtfTestActionParameters::NewL(KSession,KImap4FolderId,KSelection));
       
   156 	CMtfTestActionCopySelection::NewL(*this,CMtfTestActionParameters::NewL(KSession,KSelection,KInboxFolderId));
       
   157 
       
   158 	// Disconnect from IMAP4 server.
       
   159 	CMtfTestActionDisconnectImap4Server::NewL(*this,CMtfTestActionParameters::NewL(KImap4ServiceId,KImap4Mtm));
       
   160 	}
       
   161 
       
   162 
       
   163 void CMtfTestCaseCreateSendReceiveImap4Email::CheckPostConditionsL()
       
   164 	{
       
   165 	// Check if IMAP4 server Inbox has 1 entry.
       
   166 	CMtfTestActionCheckChildrenCount::NewL(*this,CMtfTestActionParameters::NewL(KSession,KImap4FolderId,KOne));
       
   167 
       
   168 	// Check if IMAP4 server Inbox entry is the one we have sent.
       
   169 	CMtfTestActionFindEntryByName::NewL(*this,CMtfTestActionParameters::NewL(KSession,KImap4FolderId,KImap4MessageDescription,KImap4MessageId));
       
   170 // COMPARE CONTENT OF THE MESSAGE
       
   171 
       
   172 	// Check if local Inbox has 1 entry.
       
   173 	CMtfTestActionCheckChildrenCount::NewL(*this,CMtfTestActionParameters::NewL(KSession,KInboxFolderId,KOne));
       
   174 
       
   175 	// Check if local Inbox entry is the one we have sent.
       
   176 	CMtfTestActionFindEntryByName::NewL(*this,CMtfTestActionParameters::NewL(KSession,KInboxFolderId,KImap4MessageDescription,KInboxMessageId));
       
   177 // COMPARE CONTENT OF THE MESSAGE
       
   178 
       
   179 	// Check if local Sent has 1 entry.
       
   180 	CMtfTestActionCheckChildrenCount::NewL(*this,CMtfTestActionParameters::NewL(KSession,KSentFolderId,KOne));
       
   181 
       
   182 	// Check if local Sent entry is the one we have sent.
       
   183 	CMtfTestActionFindEntryByName::NewL(*this,CMtfTestActionParameters::NewL(KSession,KSentFolderId,KImap4MessageDescription,KSentMessageId));
       
   184 // COMPARE CONTENT OF THE MESSAGE
       
   185 	}
       
   186 
       
   187