email/pop3andsmtpmtm/popservermtm/test/src/T_pops4.cpp
changeset 31 ebfee66fde93
parent 0 72b543305e3a
equal deleted inserted replaced
30:6a20128ce557 31:ebfee66fde93
       
     1 // Copyright (c) 1999-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 // T_IMCM04.CPP
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "emailtestutils.h"
       
    19 #include "miutlog.h"
       
    20 #include "miutmsg.h"
       
    21 #include <txtrich.h>
       
    22 #include <logcli.h>
       
    23 #include <logview.h>
       
    24 #include <cemailaccounts.h>
       
    25 
       
    26 // local variables etc //
       
    27 
       
    28 _LIT(KPopTest, "T_POPS4 - Testing Progress Reporting In POPS");
       
    29 RTest test(KPopTest);
       
    30 
       
    31 LOCAL_D TMsvId pop3Service;
       
    32 LOCAL_D TMsvId smtpService;
       
    33 LOCAL_D TMsvId newMessageId;
       
    34 
       
    35 LOCAL_D CTrapCleanup* theCleanup;
       
    36 LOCAL_D CImLog* log;
       
    37 LOCAL_D CEmailTestUtils* testUtils;
       
    38 LOCAL_D CActiveScheduler* scheduler;
       
    39 
       
    40 //
       
    41 
       
    42 LOCAL_C void Init()
       
    43 	{
       
    44 	CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
       
    45 	CActiveScheduler::Install(scheduler);	testUtils = CEmailTestUtils::NewLC(test);
       
    46 	CleanupStack::PushL(scheduler);
       
    47 
       
    48 	testUtils->CreateAllTestDirectories();
       
    49 	testUtils->FileSession().SetSessionPath(_L("C:\\"));
       
    50 	testUtils->CleanMessageFolderL();
       
    51 	testUtils->CopyScriptFileL(_L("c:\\mailtest\\scripts\\popprog.scr"), _L("110"));
       
    52 	testUtils->GoServerSideL();
       
    53 
       
    54 
       
    55 	log = CImLog::NewL(_L("c:\\logs\\email\\t_pops4.log"), EAppend);
       
    56 	CleanupStack::PushL(log);
       
    57 	TBuf8<80> buf;
       
    58 #if defined(__WINS__)
       
    59 	buf.Append(_L8("WINS "));
       
    60 #else
       
    61 	buf.Append(_L8("MARM "));
       
    62 #endif
       
    63 #if defined(_UNICODE)
       
    64 	buf.Append(_L8("U"));
       
    65 #endif
       
    66 #if defined(_DEBUG)
       
    67 	buf.Append(_L8("DEB"));
       
    68 #else
       
    69 	buf.Append(_L8("REL"));
       
    70 #endif
       
    71 	log->AppendComment(buf);
       
    72 	}
       
    73 	
       
    74 LOCAL_C void Closedown()
       
    75 	{
       
    76 	log->AppendComment(_L8("**********    T_POPS4 Tests Complete    **********"));
       
    77 	log->AppendComment(_L8(""));
       
    78 
       
    79 	CleanupStack::PopAndDestroy(2);  //testUtils, log
       
    80 	delete scheduler;
       
    81 	}
       
    82 
       
    83 //
       
    84 
       
    85 LOCAL_C void doMainL()
       
    86 	{
       
    87 	Init();
       
    88 	testUtils->FileSession().SetSessionPath(_L("c:\\"));
       
    89 
       
    90 //	smtpService = testUtils->CreateSmtpServiceL();
       
    91 	
       
    92 	// Create the POP3 service and set the settings for this test.
       
    93 	pop3Service = testUtils->CreatePopServiceL();
       
    94 
       
    95 	CImPop3Settings* settings = new(ELeave) CImPop3Settings();
       
    96 	CleanupStack::PushL(settings);
       
    97 	settings->Reset();
       
    98 	_LIT(KPopServer, "internet-test.plc.psion.com");
       
    99 	settings->SetServerAddressL(KPopServer);
       
   100 	settings->SetLoginNameL(testUtils->MachineName());
       
   101 	settings->SetPasswordL(testUtils->MachineName());
       
   102 	settings->SetPort(110);
       
   103 	
       
   104  	// Saving POP settings
       
   105 	CEmailAccounts* accounts = CEmailAccounts::NewLC();
       
   106  	TPopAccount popAccount;
       
   107  	accounts->GetPopAccountL(pop3Service, popAccount);						
       
   108  	accounts->SavePopSettingsL(popAccount, *settings);
       
   109 	CleanupStack::PopAndDestroy(2, settings); // accounts/store, settings
       
   110 
       
   111 	// Set the IAP to Demon (even though we're not going to dial up as such.)
       
   112 	User::LeaveIfError(testUtils->iServerEntry->SetEntry(pop3Service));
       
   113 	TMsvEntry entry = testUtils->iServerEntry->Entry();
       
   114 	entry.SetMtmData1(3);
       
   115 	User::LeaveIfError(testUtils->iServerEntry->ChangeEntry(entry));
       
   116 
       
   117 	test.Printf(_L("\nPerforming Tests\n"));
       
   118 
       
   119 	CTestActive* activeObjectTester = new (ELeave) CTestActive;
       
   120 	CleanupStack::PushL(activeObjectTester);
       
   121 	
       
   122 	// Get server MTM.
       
   123 	testUtils->InstantiatePopServerMtmL();
       
   124 	CBaseServerMtm* pop3ServerMtm = testUtils->iPopServerMtm;
       
   125 
       
   126 	// Get the POP3 server MTM to connect.
       
   127 	log->AppendComment(_L8("Connect to POP3 server"));
       
   128 	CMsvEntrySelection* serviceId = new (ELeave) CMsvEntrySelection;
       
   129 	CleanupStack::PushL(serviceId);
       
   130 	serviceId->AppendL(pop3Service);
       
   131 	TBuf8<1> parameters;
       
   132 	activeObjectTester->StartL();
       
   133 	User::LeaveIfError(testUtils->iServerEntry->SetEntry(pop3Service));
       
   134 
       
   135 	pop3ServerMtm->StartCommandL(*serviceId, KPOP3MTMConnect, parameters, activeObjectTester->iStatus);
       
   136 	CActiveScheduler::Start();
       
   137 
       
   138 	// Get the progress
       
   139 	TPop3Progress prog;	
       
   140 	TPckgC<TPop3Progress> paramPack(prog);
       
   141 	paramPack.Set(pop3ServerMtm->Progress());
       
   142 	TPop3Progress progress=paramPack();
       
   143 
       
   144 	// Check that the reported progress is EPopConnecting
       
   145 	test(progress.iPop3Progress == TPop3Progress::EPopConnecting);
       
   146 
       
   147 	CleanupStack::PopAndDestroy(); // serviceId
       
   148 
       
   149 	// Cleanup
       
   150 	CleanupStack::PopAndDestroy(); // activeObjectTester
       
   151 
       
   152 	Closedown();
       
   153 	}
       
   154 
       
   155 GLDEF_C TInt E32Main()
       
   156 	{	
       
   157 	__UHEAP_MARK;
       
   158 	test.Start(_L("T_POPS4 Testing Progress Reporting In POPS"));
       
   159 	theCleanup=CTrapCleanup::New();
       
   160 	TRAPD(ret,doMainL());		
       
   161 	test(ret==KErrNone);
       
   162 	delete theCleanup;	
       
   163 	test.End();
       
   164 	test.Close();
       
   165 	__UHEAP_MARKEND;
       
   166 	User::Heap().Check();
       
   167 	return(KErrNone);
       
   168 	}