void CPopsTestHarness::SetUpPopServiceL() { // Create the POP3 service and set the settings for this test. iPop3Service = iTestUtils->CreatePopServiceL(); CImPop3Settings* settings = new(ELeave) CImPop3Settings(); CleanupStack::PushL(settings); settings->Reset(); _LIT(KPopServer, "pop3.demon.co.uk"); settings->SetServerAddressL(KPopServer); settings->SetLoginNameL(iTestUtils->MachineName()); settings->SetPasswordL(iTestUtils->MachineName()); settings->SetPort(110); settings->SetDisconnectedUserMode(ETrue); // eh xxxx, must test this when set to EFalse CEmailAccounts* accounts = CEmailAccounts::NewLC(); TPopAccount popAccount; accounts->GetPopAccountL(iPop3Service, popAccount); accounts->SavePopSettingsL(popAccount, *settings); CleanupStack::PopAndDestroy(2, settings); // accounts/store, settings test.Printf(_L("\nPerforming Tests\n")); }
LOCAL_C void doMainL() { Init(); testUtils->FileSession().SetSessionPath(_L("c:\\")); // smtpService = testUtils->CreateSmtpServiceL(); // Create the POP3 service and set the settings for this test. pop3Service = testUtils->CreatePopServiceL(); CImPop3Settings* settings = new(ELeave) CImPop3Settings(); CleanupStack::PushL(settings); settings->Reset(); _LIT(KPopServer, "internet-test.plc.psion.com"); settings->SetServerAddressL(KPopServer); settings->SetLoginNameL(testUtils->MachineName()); settings->SetPasswordL(testUtils->MachineName()); settings->SetPort(110); // Saving POP settings CEmailAccounts* accounts = CEmailAccounts::NewLC(); TPopAccount popAccount; accounts->GetPopAccountL(pop3Service, popAccount); accounts->SavePopSettingsL(popAccount, *settings); CleanupStack::PopAndDestroy(2, settings); // accounts/store, settings // Set the IAP to Demon (even though we're not going to dial up as such.) User::LeaveIfError(testUtils->iServerEntry->SetEntry(pop3Service)); TMsvEntry entry = testUtils->iServerEntry->Entry(); entry.SetMtmData1(3); User::LeaveIfError(testUtils->iServerEntry->ChangeEntry(entry)); test.Printf(_L("\nPerforming Tests\n")); CTestActive* activeObjectTester = new (ELeave) CTestActive; CleanupStack::PushL(activeObjectTester); // Get server MTM. testUtils->InstantiatePopServerMtmL(); CBaseServerMtm* pop3ServerMtm = testUtils->iPopServerMtm; // Get the POP3 server MTM to connect. log->AppendComment(_L8("Connect to POP3 server")); CMsvEntrySelection* serviceId = new (ELeave) CMsvEntrySelection; CleanupStack::PushL(serviceId); serviceId->AppendL(pop3Service); TBuf8<1> parameters; activeObjectTester->StartL(); User::LeaveIfError(testUtils->iServerEntry->SetEntry(pop3Service)); pop3ServerMtm->StartCommandL(*serviceId, KPOP3MTMConnect, parameters, activeObjectTester->iStatus); CActiveScheduler::Start(); // Get the progress TPop3Progress prog; TPckgC<TPop3Progress> paramPack(prog); paramPack.Set(pop3ServerMtm->Progress()); TPop3Progress progress=paramPack(); // Check that the reported progress is EPopConnecting test(progress.iPop3Progress == TPop3Progress::EPopConnecting); CleanupStack::PopAndDestroy(); // serviceId // Cleanup CleanupStack::PopAndDestroy(); // activeObjectTester Closedown(); }
void CPopsTestHarness::SetUpPopServiceL() { // Handle command line arguments CCommandLineArguments* cmdLineArg=CCommandLineArguments::NewLC(); TInt count = cmdLineArg->Count(); TBool isCmdLine=FALSE; if (count>2) // Command line arguments? { if ((!(cmdLineArg->Arg(EArgTestParams).Compare(KTestParams))) && count==EArgEnd) isCmdLine=TRUE; } // Create the POP3 service and set the settings for this test. iPop3Service = iTestUtils.CreatePopServiceL(); CImPop3Settings* settings = new(ELeave) CImPop3Settings(); CleanupStack::PushL(settings); settings->Reset(); TBuf<100> buf; if (isCmdLine) { TLex lex(cmdLineArg->Arg(EArgServerAddress)); buf=lex.NextToken(); test.Printf(_L("Server address: %S\n"),&buf); } else { readConsoleLineBuf(_L("Server address: "),buf); } settings->SetServerAddressL(buf); buf.Zero(); if (isCmdLine) { TLex lex(cmdLineArg->Arg(EArgLogin)); buf=lex.NextToken(); test.Printf(_L("Login: %S\n"),&buf); } else { readConsoleLineBuf(_L("login: "******"Password: %S\n"),&buf); } else { readConsoleLineBuf(_L("password: "******"Use APOP: %c\n"),choice); if (choice=='y' || choice=='Y') settings->SetApop(ETrue); else settings->SetApop(EFalse); } else { test.Printf(_L("\n Use APOP? Enter (Y/N): ")); settings->SetApop(GetTrueOrFalse()); } if (isCmdLine) { TLex lex(cmdLineArg->Arg(EArgUseSecureSockets)); choice=lex.Get(); test.Printf(_L("Use secure sockets: %c\n"),choice); if (choice=='y' || choice=='Y') settings->SetSecureSockets(ETrue); else settings->SetSecureSockets(EFalse); } else { test.Printf(_L("\n Use secure sockets? Enter (Y/N): ")); settings->SetSecureSockets(GetTrueOrFalse()); } // Add IAP's to iIAPPreferences TImIAPChoice iap; CImIAPPreferences* prefs = CImIAPPreferences::NewLC(); TInt iapId = 0; CMDBSession* iDBSession = CMDBSession::NewL(CMDBSession::LatestVersion()); CCDConnectionPrefsRecord *connPrefRecord = static_cast<CCDConnectionPrefsRecord*>(CCDRecordBase::RecordFactoryL(KCDTIdConnectionPrefsRecord)); CleanupStack::PushL(connPrefRecord); connPrefRecord->iDirection = ECommDbConnectionDirectionOutgoing; if(!connPrefRecord->FindL(*iDBSession)) { User::Leave(KErrNotFound); } iapId = iap.iIAP = connPrefRecord->iDefaultIAP; CleanupStack::PopAndDestroy(connPrefRecord); delete iDBSession; iDBSession= NULL; iap.iDialogPref = ECommDbDialogPrefDoNotPrompt; prefs->AddIAPL(iap); iap.iIAP = iapId; iap.iDialogPref = ECommDbDialogPrefPrompt; prefs->AddIAPL(iap, 1); CEmailAccounts* accounts = CEmailAccounts::NewLC(); TPopAccount popAccount; accounts->GetPopAccountL(iPop3Service, popAccount); accounts->SavePopSettingsL(popAccount, *settings); accounts->SavePopIapSettingsL(popAccount, *prefs); CleanupStack::PopAndDestroy(4, cmdLineArg); // (accounts,) prefs, settings, (store,) cmdLineArg test.Printf(_L("\nPerforming Tests\n")); }